skycaiji 1 year ago
parent
commit
8030eb59fc
  1. 26
      public/static/css/admin.css
  2. 43
      public/static/js/admin.js
  3. 78
      public/static/js/admin/collector.js
  4. 14
      public/static/js/admin/cpattern_test.js
  5. 7
      public/static/js/admin/index.js
  6. 2
      public/static/js/admin/release.js
  7. 14
      public/static/js/admin/setting.js
  8. 19
      public/static/js/admin/task.js
  9. 2
      public/static/js/langs/zh-cn.js
  10. 11
      skycaiji
  11. 4
      vendor/skycaiji/app/admin/behavior/Init.php
  12. 34
      vendor/skycaiji/app/admin/command/Collect.php
  13. 82
      vendor/skycaiji/app/admin/controller/Backstage.php
  14. 1
      vendor/skycaiji/app/admin/controller/CollectController.php
  15. 56
      vendor/skycaiji/app/admin/controller/Collector.php
  16. 40
      vendor/skycaiji/app/admin/controller/Cpattern.php
  17. 59
      vendor/skycaiji/app/admin/controller/CpatternTest.php
  18. 38
      vendor/skycaiji/app/admin/controller/Index.php
  19. 10
      vendor/skycaiji/app/admin/controller/Release.php
  20. 140
      vendor/skycaiji/app/admin/controller/Setting.php
  21. 34
      vendor/skycaiji/app/admin/controller/Task.php
  22. 25
      vendor/skycaiji/app/admin/event/CollectBase.php
  23. 91
      vendor/skycaiji/app/admin/event/Cpattern.php
  24. 68
      vendor/skycaiji/app/admin/event/CpatternBase.php
  25. 770
      vendor/skycaiji/app/admin/event/CpatternColl.php
  26. 23
      vendor/skycaiji/app/admin/event/CpatternEvent.php
  27. 2
      vendor/skycaiji/app/admin/event/Rapi.php
  28. 4
      vendor/skycaiji/app/admin/event/Rcms.php
  29. 5
      vendor/skycaiji/app/admin/event/Rdb.php
  30. 2
      vendor/skycaiji/app/admin/event/Rdiy.php
  31. 58
      vendor/skycaiji/app/admin/event/ReleaseBase.php
  32. 2
      vendor/skycaiji/app/admin/event/Rfile.php
  33. 3
      vendor/skycaiji/app/admin/event/Rtoapi.php
  34. 10
      vendor/skycaiji/app/admin/lang/zh-cn.php
  35. 41
      vendor/skycaiji/app/admin/model/Collector.php
  36. 185
      vendor/skycaiji/app/admin/model/Config.php
  37. 2
      vendor/skycaiji/app/admin/model/ReleaseApp.php
  38. 31
      vendor/skycaiji/app/admin/model/Task.php
  39. 7
      vendor/skycaiji/app/admin/model/User.php
  40. 7
      vendor/skycaiji/app/admin/view/backstage/index.html
  41. 28
      vendor/skycaiji/app/admin/view/collector/echo_url_msg.html
  42. 2
      vendor/skycaiji/app/admin/view/collector/set.html
  43. 2
      vendor/skycaiji/app/admin/view/common/header_public.html
  44. 5
      vendor/skycaiji/app/admin/view/common/main.html
  45. 44
      vendor/skycaiji/app/admin/view/cpattern/content_sign.html
  46. 14
      vendor/skycaiji/app/admin/view/cpattern/field.html
  47. 18
      vendor/skycaiji/app/admin/view/cpattern/process_module.html
  48. 4
      vendor/skycaiji/app/admin/view/cpattern/set.html
  49. 160
      vendor/skycaiji/app/admin/view/cpattern/set_page.html
  50. 9
      vendor/skycaiji/app/admin/view/cpattern/set_page_rule.html
  51. 202
      vendor/skycaiji/app/admin/view/cpattern/set_page_url.html
  52. 25
      vendor/skycaiji/app/admin/view/cpattern/set_pagination.html
  53. 14
      vendor/skycaiji/app/admin/view/cpattern/set_tpl.html
  54. 6
      vendor/skycaiji/app/admin/view/cpattern/test_source_urls.html
  55. 22
      vendor/skycaiji/app/admin/view/release/set.html
  56. 51
      vendor/skycaiji/app/admin/view/setting/caiji.html
  57. 47
      vendor/skycaiji/app/admin/view/setting/download_file.html
  58. 49
      vendor/skycaiji/app/admin/view/setting/download_file_func.html
  59. 47
      vendor/skycaiji/app/admin/view/setting/download_img.html
  60. 49
      vendor/skycaiji/app/admin/view/setting/download_img_func.html
  61. 91
      vendor/skycaiji/app/admin/view/task/save_form.html
  62. 2
      vendor/skycaiji/app/admin/view/user/add.html
  63. 2
      vendor/skycaiji/app/admin/view/user/edit.html
  64. 2
      vendor/skycaiji/app/command.php
  65. 2
      vendor/skycaiji/app/common.php
  66. 116
      vendor/skycaiji/app/common/command/SkycaijiCli.php
  67. 2
      vendor/skycaiji/app/common/model/Config.php
  68. 69
      vendor/skycaiji/app/extend/util/ChromeSocket.php
  69. 27
      vendor/skycaiji/app/extend/util/Funcs.php
  70. 25
      vendor/skycaiji/app/extend/util/Param.php
  71. 408
      vendor/skycaiji/app/extend/util/SwooleSocket.php
  72. 112
      vendor/skycaiji/app/extend/util/Tools.php
  73. 90
      vendor/skycaiji/app/extend/util/UnmaxPost.php
  74. 2
      vendor/skycaiji/app/install/data/check_db
  75. 2
      vendor/skycaiji/app/install/data/check_file
  76. 2
      vendor/skycaiji/app/public/think_exception.tpl
  77. 2
      vendor/skycaiji/tp/base.php

26
public/static/css/admin.css

@ -6,9 +6,33 @@
.info-box-content .info-box-number{font-weight:normal;line-height:25px;}
.info-box-content .info-box-number .tips{margin-left:5px;font-size:14px;display:inline;}
.help-block{color:#aaa;}
/*取消动画*/
.content-wrapper,
.main-footer,
.main-header .navbar,
.main-header .logo,
.main-sidebar,
.sidebar-menu li>a>.fa-angle-left,
.sidebar-menu li>a>.pull-right-container>.fa-angle-left,
.control-sidebar-bg,
.control-sidebar,
.small-box .icon,
.direct-chat-messages,
.direct-chat-contacts,
.fc-color-picker>li .fa,
#add-new-event {
-webkit-transition:none!important;
-moz-transition:none!important;
-o-transition:none!important;
transition:none!important;
}
/*全局*/
.modal-body .form-group:last-child{margin-bottom:0;}
.modal-body .form-group .help-block:last-child{margin-bottom:0;}
.panel .form-group:last-child{margin-bottom:0;}
.panel .form-group .help-block:last-child{margin-bottom:0;}
.panel .panel:last-child{margin-bottom:5px;}
.label-custom-opened{font-weight:normal;background-color:#dedede;color:#555;}
@ -72,7 +96,7 @@ div.in-line-mg{display:inline;margin-right:5px;}
.echo-msg-clear{width:100%;overflow:hidden;clear:both;}
.echo-msg-lt{float:left;}
.echo-msg-lurl{float:left;margin-right:3px;height:16px;max-width:70%;overflow:hidden;text-overflow:ellipsis;word-wrap:break-word;word-break:break-all;}
.echo-msg-lurl{float:left;margin-right:3px;height:17px;max-width:70%;overflow:hidden;text-overflow:ellipsis;word-wrap:break-word;word-break:break-all;}
/*皮肤*/
.skin-blue-light .treeview-skins,.skin-black-light .treeview-skins,.skin-red-light .treeview-skins,.skin-yellow-light .treeview-skins,.skin-purple-light .treeview-skins,.skin-green-light .treeview-skins{

43
public/static/js/admin.js

File diff suppressed because one or more lines are too long

78
public/static/js/admin/collector.js

@ -8,9 +8,14 @@
|--------------------------------------------------------------------------
*/
'use strict';function CollectorPattern(){this.formid='#form_coll';this.cpFrontUrl=null;this.cpLevelUrl=null;this.cpRelationUrl=null;this.cpUrlWeb=null;this.cpRenderer=null;this.cpContentSign=null;this.cpPagination=null;this.cpField=null;this.cpProcess=null}
CollectorPattern.prototype={constructor:CollectorPattern,init_test:function(){var $_o=this;$_o.formid='#win_form_cache';$_o.cpUrlWeb=new CpUrlWeb($_o);$_o.cpRenderer=new CpRenderer($_o);$_o.cpUrlWeb.page_init('test');$_o.cpRenderer.page_init('test')},init:function(){var $_o=this;$($_o.formid).bind('submit',function(){$('#coll_tab_content').find('.tab-pane[id^="coll_pattern_"]').each(function(){if($(this).hasClass('active')){$($_o.formid+' [name="tab_link"]').val($(this).attr('id'));return}});var settings=getFormAjaxSettings($(this));ajaxOpen(settings);return!1});$_o.cpFrontUrl=new CpFrontUrl($_o);$_o.cpLevelUrl=new CpLevelUrl($_o);$_o.cpRelationUrl=new CpRelationUrl($_o);$_o.cpUrlWeb=new CpUrlWeb($_o);$_o.cpRenderer=new CpRenderer($_o);$_o.cpContentSign=new CpContentSign($_o);$_o.cpPagination=new CpPagination($_o);$_o.cpField=new CpField($_o);$_o.cpProcess=new CpProcess($_o);inputSelectCustom($_o.formid+' select[name="config[charset]"]','config[charset_custom]',null,null,function(){$_o.cpUrlWeb.def_config_charset('')});inputSelectCustom($_o.formid+' select[name="config[encode]"]','config[encode_custom]',null,null,function(){$_o.cpUrlWeb.def_config_encode('')});$($_o.formid+' [name="config[page_render]"]').bind('click',function(){$_o.cpRenderer.def_config_renderer_open('')});$($_o.formid+' [name="config[request_headers][open]"]').bind('click',function(){$_o.cpUrlWeb.def_config_header_global('')});$($_o.formid+' #coll_pattern_request_headers .dm-useragent li a').bind('click',function(){$($_o.formid+' [name="config[request_headers][useragent]"]').val($(this).attr('data-useragent'))});$($_o.formid+' #coll_pattern_request_headers .add-request-header').bind('click',function(){$_o.add_request_header('','')});$($_o.formid+' #coll_pattern_request_headers .add-request-header-img').bind('click',function(){$_o.add_request_header_img('','')});$($_o.formid+' #coll_pattern_request_headers .add-request-header-file').bind('click',function(){$_o.add_request_header_file('','')});$($_o.formid+' .c-p-request-headers').on('click','.delete-request-header',function(){$(this).parents('tr').eq(0).remove()});$($_o.formid+' .c-p-request-headers-img').on('click','.delete-request-header-img',function(){$(this).parents('tr').eq(0).remove()});$($_o.formid+' .c-p-request-headers-file').on('click','.delete-request-header-file',function(){$(this).parents('tr').eq(0).remove()});$_o.init_page_list_op('front_url');$(this.formid+' #coll_pattern_source_url .add-source-url').bind('click',function(){windowModal('添加起始网址',ulink("cpattern/source"),{lg:1})});$(this.formid+' #coll_pattern_source_url .clear-source-url').bind('click',function(){$_o.source_op('clear_all')});$(this.formid+' #coll_pattern_source_url').on('click','.edit-source-url',function(){var parent=$(this).parents('[id^="source_url_"]').eq(0);var objid=parent.attr('id');var sourceUrl=parent.find('[name="config[source_url][]"]').val();sourceUrl=sourceUrl?sourceUrl:'';var url=ulink("cpattern/source");var options={lg:1};if(objid||sourceUrl){options.ajax={type:'post',data:{'source_url':sourceUrl,'objid':objid}}}
windowModal('添加起始网址',url,options)});$(this.formid+' #coll_pattern_source_url').on('click','.delete-source-url',function(){var obj=$(this);confirmRight(window.tpl_lang.confirm_delete,function(){obj.parents('[id^="source_url_"]').eq(0).remove()})});eleExchange(this.formid+' #coll_pattern_source_url','.icon-drag-move','[id^="source_url_"]');$(this.formid+' [name="config[source_is_url]"]').bind('click',function(){if($_o.source_is_url()){$('#alert_coll_pattern_link').show();$('#panel_coll_pattern_source_url_web').hide();$('#panel_coll_pattern_source_url_renderer').hide();$('#panel_coll_pattern_source_url_content_sign').hide();$('#panel_coll_pattern_source_url_pagination').hide();$('#panel_coll_pattern_level_url').hide();$('#panel_coll_pattern_url_content_sign').siblings('.panel').hide();$('#panel_coll_pattern_url_web').show();$('#panel_coll_pattern_url_renderer').show()}else{$('#alert_coll_pattern_link').hide();$('#panel_coll_pattern_source_url_web').show();$('#panel_coll_pattern_source_url_renderer').show();$('#panel_coll_pattern_source_url_content_sign').show();$('#panel_coll_pattern_source_url_pagination').show();$('#panel_coll_pattern_level_url').show();$('#panel_coll_pattern_url_content_sign').siblings('.panel').show()}});$_o.init_page('source_url');$_o.init_page('url');$($_o.formid).on('click','.c-p-url-page-signs .btn-page-signs',function(){$_o.parent_page_signs(this)});$_o.init_page_list_op('level_url');$_o.init_page_list_op('relation_url');$(this.formid+' #coll_pattern_field').on('click','.add-field',function(){$_o.field_editor(null,null)});$(this.formid+' #coll_pattern_field').on('click','.field-name',function(){$_o.field_editor($(this),null)});$(this.formid+' #coll_pattern_field').on('click','.add-field-default',function(){$_o.cpField.add_default()});$(this.formid+' #coll_pattern_field').on('click','.sort-field',function(){var fieldNames=$_o.get_field_names(!0);for(var i in fieldNames){var fieldTr=$($_o.formid+' #coll_pattern_field').find('.field-name[data-val="'+fieldNames[i]+'"]').parents('tr[id^="field_"]').eq(0);if(fieldTr.length>0){$($_o.formid+' #coll_pattern_field .c-p-field-list tbody').append(fieldTr)}}
toastr.success('调整完成')});$(this.formid+' #coll_pattern_field').on('click','.field-del',function(){var obj=$(this);confirmRight(window.tpl_lang.confirm_delete,function(){$_o.field_delete_tr(obj)})});$(this.formid+' #coll_pattern_field').on('click','.field-clone',function(){var tr=$(this).parents('tr[id^="field_"]').eq(0);var field=tr.find('[name="config[field_list][]"]').val();var process=tr.find('[name="config[field_process][]"]').val();confirmRight('确定复制字段?',function(){ajaxOpen({type:'POST',dataType:'json',url:ulink("cpattern/clone_field"),data:{field:field,process:process},success:function(data){if(data.code==1){data=data.data;var hasField=!1;do{data.field.name+='_1';hasField=$('#coll_pattern_field .c-p-field-list').find('.field-name[data-val="'+data.field.name+'"]');if(hasField&&hasField.length>0){hasField=!0}else{hasField=!1}}while(hasField);$_o.cpField.add(null,data.field,data.process);toastr.success('字段复制成功:'+data.field.name)}else{toastr.error(data.msg)}}})})});$(this.formid+' #coll_pattern_field').on('click','.field-process',function(){var process=$(this).parent().find('input[name="config[field_process][]"]').val();var prt=$(this).parents('tr[id^="field_"]').eq(0);var objid=prt.attr('id');var field=prt.find('.field-name').attr('data-val');var url=ulink("cpattern/process?task_id=_tid_&field=_field_",{'_tid_':$_o.get_task_id(),'_field_':field});windowModal('数据处理:'+field+'<small><a href="javascript:;" id="window_process_paste" title="粘贴" class="glyphicon glyphicon-paste" style="margin-left:7px;color:#888;"></a></small>',url,{lg:1,ajax:{type:'post',data:{objid:objid,process:process}}});$_o.process_paste()});$(this.formid+' #coll_pattern_process').on('click','.add-process',function(){var url=ulink("cpattern/process?task_id=_tid_&type=common",{'_tid_':$_o.get_task_id()});windowModal('数据处理(通用)<small><a href="javascript:;" id="window_process_paste" title="粘贴" class="glyphicon glyphicon-paste" style="color:#888;"></a></small>',url,{lg:1});$_o.process_paste()});eleExchange(this.formid+' #coll_pattern_field','.icon-drag-move','tr[id^="field_"]');$(this.formid+' [name="effective"]').val(1)},load:function(config){var $_o=this;if(config){$(this.formid+' [name="config[charset_custom]"]').val(config.charset_custom);$(this.formid+' [name="config[charset]"]').val(config.charset).trigger('change');$(this.formid+' [name="config[encode_custom]"]').val(config.encode_custom);$(this.formid+' [name="config[encode]"]').val(config.encode).trigger('change');$(this.formid+' [name="config[url_complete]"][value="'+toInt(config.url_complete)+'"]').prop('checked',!0);$(this.formid+' [name="config[url_reverse]"][value="'+toInt(config.url_reverse)+'"]').prop('checked',!0);$(this.formid+' [name="config[page_render]"][value="'+toInt(config.page_render)+'"]').prop('checked',!0).trigger('click');$(this.formid+' [name="config[url_repeat]"][value="'+toInt(config.url_repeat)+'"]').prop('checked',!0);$(this.formid+' [name="config[url_no_name]"][value="'+toInt(config.url_no_name)+'"]').prop('checked',!0);$(this.formid+' [name="config[url_encode]"][value="'+toInt(config.url_encode)+'"]').prop('checked',!0);if(config.regexp_flags){for(var i in config.regexp_flags){$(this.formid).find('[name="config[regexp_flags][]"][value="'+config.regexp_flags[i]+'"]').prop('checked',!0)}}
CollectorPattern.prototype={constructor:CollectorPattern,init:function(){var $_o=this;$($_o.formid).bind('submit',function(){$('#coll_tab_content').find('.tab-pane[id^="coll_pattern_"]').each(function(){if($(this).hasClass('active')){$($_o.formid+' [name="tab_link"]').val($(this).attr('id'));return}});var settings=getFormAjaxSettings($(this));settings.data={'_post_data_':settings.data};ajaxOpen(settings);return!1});$_o.cpFrontUrl=new CpFrontUrl($_o);$_o.cpLevelUrl=new CpLevelUrl($_o);$_o.cpRelationUrl=new CpRelationUrl($_o);$_o.cpUrlWeb=new CpUrlWeb($_o);$_o.cpRenderer=new CpRenderer($_o);$_o.cpContentSign=new CpContentSign($_o);$_o.cpPagination=new CpPagination($_o);$_o.cpField=new CpField($_o);$_o.cpProcess=new CpProcess($_o);inputSelectCustom($_o.formid+' select[name="config[charset]"]','config[charset_custom]',null,null,function(){$_o.cpUrlWeb.def_config_charset('')});inputSelectCustom($_o.formid+' select[name="config[encode]"]','config[encode_custom]',null,null,function(){$_o.cpUrlWeb.def_config_encode('')});$($_o.formid+' [name="config[page_render]"]').bind('click',function(){$_o.cpRenderer.def_config_renderer_open('')});$($_o.formid+' [name="config[request_headers][open]"]').bind('click',function(){$_o.cpUrlWeb.def_config_header_global('')});$($_o.formid+' #coll_pattern_request_headers .dm-useragent li a').bind('click',function(){$($_o.formid+' [name="config[request_headers][useragent]"]').val($(this).attr('data-useragent'))});$($_o.formid+' #coll_pattern_request_headers .add-request-header').bind('click',function(){$_o.add_request_header('','')});$($_o.formid+' #coll_pattern_request_headers .add-request-header-img').bind('click',function(){$_o.add_request_header_img('','')});$($_o.formid+' #coll_pattern_request_headers .add-request-header-file').bind('click',function(){$_o.add_request_header_file('','')});$($_o.formid+' .c-p-request-headers').on('click','.delete-request-header',function(){$(this).parents('tr').eq(0).remove()});$($_o.formid+' .c-p-request-headers-img').on('click','.delete-request-header-img',function(){$(this).parents('tr').eq(0).remove()});$($_o.formid+' .c-p-request-headers-file').on('click','.delete-request-header-file',function(){$(this).parents('tr').eq(0).remove()});$_o.init_page_list_op('front_url');$(this.formid+' #coll_pattern_source_url .add-source-url').bind('click',function(){windowModal('添加起始网址',ulink("cpattern/source"),{lg:1})});$(this.formid+' #coll_pattern_source_url .clear-source-url').bind('click',function(){$_o.source_op('clear_all')});$(this.formid+' #coll_pattern_source_url').on('click','.edit-source-url',function(){var parent=$(this).parents('[id^="source_url_"]').eq(0);var objid=parent.attr('id');var sourceUrl=parent.find('[name="config[source_url][]"]').val();sourceUrl=sourceUrl?sourceUrl:'';var url=ulink("cpattern/source");var options={lg:1};if(objid||sourceUrl){options.ajax={type:'post',data:{'source_url':sourceUrl,'objid':objid}}}
windowModal('添加起始网址',url,options)});$(this.formid+' #coll_pattern_source_url').on('click','.delete-source-url',function(){var obj=$(this);confirmRight(window.tpl_lang.confirm_delete,function(){obj.parents('[id^="source_url_"]').eq(0).remove()})});eleExchange(this.formid+' #coll_pattern_source_url','.icon-drag-move','[id^="source_url_"]');$(this.formid+' [name="config[source_is_url]"]').bind('click',function(){if($_o.source_is_url()){$('#coll_pattern_source_url').css('margin-bottom','0px');$('#alert_coll_pattern_link').show();$('#panel_coll_pattern_source_url_web').hide();$('#panel_coll_pattern_source_url_renderer').hide();$('#panel_coll_pattern_source_url_content_sign').hide();$('#panel_coll_pattern_source_url_pagination').hide();$('#panel_coll_pattern_level_url').hide();$('#panel_coll_pattern_url_content_sign').siblings('.panel').hide();$('#panel_coll_pattern_url_web').show();$('#panel_coll_pattern_url_renderer').show()}else{$('#coll_pattern_source_url').css('margin-bottom','15px');$('#alert_coll_pattern_link').hide();$('#panel_coll_pattern_source_url_web').show();$('#panel_coll_pattern_source_url_renderer').show();$('#panel_coll_pattern_source_url_content_sign').show();$('#panel_coll_pattern_source_url_pagination').show();$('#panel_coll_pattern_level_url').show();$('#panel_coll_pattern_url_content_sign').siblings('.panel').show()}});$_o.init_page('source_url');$_o.init_page('url');$($_o.formid).on('click','.c-p-url-page-signs .btn-page-signs',function(){$_o.parent_page_signs(this)});$_o.init_page_list_op('level_url');$_o.init_page_list_op('relation_url');$(this.formid+' #coll_pattern_field').on('click','.add-field',function(){$_o.field_editor(null,null)});$(this.formid+' #coll_pattern_field').on('click','.field-name',function(){$_o.field_editor($(this),null)});$(this.formid+' #coll_pattern_field').on('click','.add-field-default',function(){$_o.cpField.add_default()});$(this.formid+' #coll_pattern_field').on('click','.sort-field',function(){var fieldNames=$_o.get_field_names(!0);for(var i in fieldNames){var fieldTr=$($_o.formid+' #coll_pattern_field').find('.field-name[data-val="'+fieldNames[i]+'"]').parents('tr[id^="field_"]').eq(0);if(fieldTr.length>0){$($_o.formid+' #coll_pattern_field .c-p-field-list tbody').append(fieldTr)}}
toastr.success('调整完成')});$(this.formid+' #coll_pattern_field').on('click','.field-del',function(){var obj=$(this);confirmRight(window.tpl_lang.confirm_delete,function(){$_o.field_delete_tr(obj)})});$(this.formid+' #coll_pattern_field').on('click','.field-clone',function(){var tr=$(this).parents('tr[id^="field_"]').eq(0);var field=tr.find('[name="config[field_list][]"]').val();var process=tr.find('[name="config[field_process][]"]').val();confirmRight('确定复制字段?',function(){ajaxOpen({type:'POST',dataType:'json',url:ulink("cpattern/clone_field"),data:{field:field,process:process},success:function(data){if(data.code==1){data=data.data;var hasField=!1;do{data.field.name+='_1';hasField=$('#coll_pattern_field .c-p-field-list').find('.field-name[data-val="'+data.field.name+'"]');if(hasField&&hasField.length>0){hasField=!0}else{hasField=!1}}while(hasField);$_o.cpField.add(null,data.field,data.process);toastr.success('字段复制成功:'+data.field.name)}else{toastr.error(data.msg)}}})})});$(this.formid+' #coll_pattern_field').on('click','.field-process',function(){var process=$(this).parent().find('input[name="config[field_process][]"]').val();var prt=$(this).parents('tr[id^="field_"]').eq(0);var objid=prt.attr('id');var field=prt.find('.field-name').attr('data-val');var url=ulink("cpattern/process?task_id=_tid_&field=_field_",{'_tid_':$_o.get_task_id(),'_field_':field});windowModal('数据处理:'+field+'<small><a href="javascript:;" id="window_process_paste" title="粘贴" class="glyphicon glyphicon-paste" style="margin-left:7px;color:#888;"></a></small>',url,{lg:1,ajax:{type:'post',data:{objid:objid,process:process}}});$_o.process_paste()});$(this.formid+' #coll_pattern_process').on('click','.add-process',function(){var url=ulink("cpattern/process?task_id=_tid_&type=common",{'_tid_':$_o.get_task_id()});windowModal('数据处理(通用)<small><a href="javascript:;" id="window_process_paste" title="粘贴" class="glyphicon glyphicon-paste" style="color:#888;"></a></small>',url,{lg:1});$_o.process_paste()});eleExchange(this.formid+' #coll_pattern_field','.icon-drag-move','tr[id^="field_"]');$(this.formid+' [name="effective"]').val(1)},init_test:function(){var $_o=this;$_o.formid='#win_form_cache';$_o.cpUrlWeb=new CpUrlWeb($_o);$_o.cpRenderer=new CpRenderer($_o);$_o.cpUrlWeb.page_init('test');$_o.cpRenderer.page_init('test')},init_echo_url_msg:function(dataUrlWeb,dataRenderer){this.init_test();if(!isObject(dataUrlWeb)){dataUrlWeb={}}
if(!isObject(dataRenderer)){dataRenderer={}}
var hasUrlWeb=!1;for(var i in dataUrlWeb){hasUrlWeb=!0}
var hasRenderer=!1;for(var i in dataRenderer){hasRenderer=!0}
this.cpUrlWeb.page_load('test',dataUrlWeb);this.cpRenderer.page_load('test',dataRenderer);var urlWebForm=$('.c-p-url-web-form').parents('.form-group').eq(0);var urlWebBox=urlWebForm.parents('.panel[id]').eq(0);if(hasUrlWeb){urlWebBox=urlWebBox.find('.panel-body').eq(0);urlWebBox.html(urlWebForm)}else{urlWebBox.hide()}
var rendererList=$('.c-p-url-renderer-list').parents('.form-group').eq(0);var rendererBox=rendererList.parents('.panel[id]').eq(0);if(hasRenderer){rendererBox=rendererBox.find('.panel-body').eq(0);rendererBox.html(rendererList)}else{rendererBox.hide()}},load:function(config){var $_o=this;if(config){$(this.formid+' [name="config[charset_custom]"]').val(config.charset_custom);$(this.formid+' [name="config[charset]"]').val(config.charset).trigger('change');$(this.formid+' [name="config[encode_custom]"]').val(config.encode_custom);$(this.formid+' [name="config[encode]"]').val(config.encode).trigger('change');$(this.formid+' [name="config[url_complete]"][value="'+toInt(config.url_complete)+'"]').prop('checked',!0);$(this.formid+' [name="config[url_reverse]"][value="'+toInt(config.url_reverse)+'"]').prop('checked',!0);$(this.formid+' [name="config[page_render]"][value="'+toInt(config.page_render)+'"]').prop('checked',!0).trigger('click');$(this.formid+' [name="config[url_repeat]"][value="'+toInt(config.url_repeat)+'"]').prop('checked',!0);$(this.formid+' [name="config[url_no_name]"][value="'+toInt(config.url_no_name)+'"]').prop('checked',!0);$(this.formid+' [name="config[url_encode]"][value="'+toInt(config.url_encode)+'"]').prop('checked',!0);if(config.regexp_flags){for(var i in config.regexp_flags){$(this.formid).find('[name="config[regexp_flags][]"][value="'+config.regexp_flags[i]+'"]').prop('checked',!0)}}
if(isObject(config.front_urls)){for(var i in config.front_urls){$_o.cpFrontUrl.add(null,config.front_urls[i])}
showPanelCollapse('#coll_pattern_front_url')}
if(config.source_url){var source_url_html_list='';var sourceParams={get:1};for(var i in config.source_url){sourceParams.source_url=config.source_url[i];source_url_html_list+=this.source_op('add',sourceParams)}
@ -31,7 +36,8 @@ if(config.request_headers.img>0){showPanelCollapse('#coll_pattern_request_header
if(config.request_headers.img_names){var r_h_img_vals=config.request_headers.img_vals?config.request_headers.img_vals:{};for(var i in config.request_headers.img_names){$_o.add_request_header_img(config.request_headers.img_names[i],r_h_img_vals[i])}}
if(config.request_headers.file>0){showPanelCollapse('#coll_pattern_request_headers');showPanelCollapse('#c_p_request_headers_file')}
if(config.request_headers.file_names){var r_h_file_vals=config.request_headers.file_vals?config.request_headers.file_vals:{};for(var i in config.request_headers.file_names){$_o.add_request_header_file(config.request_headers.file_names[i],r_h_file_vals[i])}}}}
$(this.formid+' [name="effective_edit"]').val(1)},get_page_vars:function(pageType,returnKey){var title='';var boxId='';var namePre='';var formId='';if('front_url'==pageType){title='前置页';boxId='#c_p_front_url';namePre='front_url';formId=this.cpFrontUrl.formObj}else if('source_url'==pageType){title='起始页';boxId='#coll_pattern_source_url';namePre='config[source_config]';formId=this.formid}else if('level_url'==pageType){title='多级页';boxId='#c_p_level_url';namePre='level_url';formId=this.cpLevelUrl.formObj}else if('relation_url'==pageType){title='关联页';boxId='#c_p_relation_url';namePre='relation_url';formId=this.cpRelationUrl.formObj}else if('url'==pageType){title='内容页';boxId='#coll_pattern_url';namePre='config';formId=this.formid}else if('test'==pageType){title='';boxId='#win_coll_pattern_test';namePre='config';formId='#win_form_test'}
$(this.formid+' [name="effective_edit"]').val(1)},get_page_vars:function(pageType,returnKey,isPagination){var title='';var boxId='';var namePre='';var formId='';if('front_url'==pageType){title='前置页';boxId='#c_p_front_url';namePre='front_url';formId=this.cpFrontUrl.formObj}else if('source_url'==pageType){title='起始页';boxId='#coll_pattern_source_url';namePre='config[source_config]';formId=this.formid}else if('level_url'==pageType){title='多级页';boxId='#c_p_level_url';namePre='level_url';formId=this.cpLevelUrl.formObj}else if('relation_url'==pageType){title='关联页';boxId='#c_p_relation_url';namePre='relation_url';formId=this.cpRelationUrl.formObj}else if('url'==pageType){title='内容页';boxId='#coll_pattern_url';namePre='config';formId=this.formid}else if('test'==pageType){title='';boxId='#win_coll_pattern_test';namePre='config';formId='#win_form_test'}
if(isPagination){boxId+='_pagination';namePre+='[pagination]'}
var data={title:title,boxId:boxId,namePre:namePre,formId:formId};if(returnKey){return data[returnKey]}else{return data}},page_is_list:function(pageType){if(pageType=='front_url'||pageType=='level_url'||pageType=='relation_url'){return!0}else{return!1}},init_page_list_op:function(pageType){var $_o=this;if(!$_o.page_is_list(pageType)){return}
var pageVars=$_o.get_page_vars(pageType);var listObj='#c_p_'+pageType+'s';var parentObj='[id^="'+pageType+'_"]';$($_o.formid+' #coll_pattern_'+pageType+' .add-'+pageType.replace('_','-')).bind('click',function(){var url=ulink('cpattern/'+pageType);windowModal('添加'+pageVars.title+'规则',url,{lg:1})});$($_o.formid+' '+listObj).on('click','.name',function(){var parent=$(this).parents(parentObj).eq(0);var options={lg:1,ajax:{type:'post',data:{}}};options.ajax.data.objid=parent.attr('id');options.ajax.data[pageType]=parent.find('[name="config['+pageType+'s][]"]').val();windowModal('编辑'+pageVars.title+'规则',ulink('cpattern/'+pageType),options)});$($_o.formid+' '+listObj).on('click','.clone',function(){var parent=$(this).parents(parentObj).eq(0);var pageConfig=parent.find('[name="config['+pageType+'s][]"]').val();var postData={};postData[pageType]=pageConfig;confirmRight('确定复制'+pageVars.title+'?',function(){ajaxOpen({type:'POST',dataType:'json',url:ulink('cpattern/clone_'+pageType),data:postData,success:function(data){if(data.code==1){data=data.data;var hasName=!1;do{data[pageType].name+='_1';hasName=$($_o.formid+' '+listObj).find('.name[data-val="'+data[pageType].name+'"]');if(hasName&&hasName.length>0){hasName=!0}else{hasName=!1}}while(hasName);if(pageType=='front_url'){$_o.cpFrontUrl.add(null,data[pageType])}else if(pageType=='level_url'){$_o.cpLevelUrl.add(null,data[pageType])}else if(pageType=='relation_url'){$_o.cpRelationUrl.add(null,data[pageType])}
toastr.success(pageVars.title+'复制成功:'+data[pageType].name)}else{toastr.error(data.msg)}}})})});$($_o.formid+' '+listObj).on('click','.delete',function(){var curObj=$(this);confirmRight('确定删除?',function(){curObj.parents(parentObj).eq(0).remove()})});eleExchange($_o.formid+' '+listObj,'.icon-drag-move','tbody tr')},init_page:function(pageType){var $_o=this;var pageVars=$_o.get_page_vars(pageType);var formId=pageVars.formId;var boxId=pageVars.boxId;var namePre=pageVars.namePre;if(!formId||!boxId||!namePre){return}
@ -47,7 +53,8 @@ $_o.cpUrlWeb.page_load(pageType,config.url_web);$_o.cpRenderer.page_load(pageTyp
$(this).parents('div[source-param]').find('input[name="source[param]"]').prop('checked',!0)});if(params.source){$(formObj+' .nav-tabs').find('a[source-type="'+params.source.type+'"]').click();if(params.source.type=='custom'){$(formObj+' textarea[name="source[urls]"]').val(params.source.urls)}else if(params.source.type=='batch'){$(formObj+' input[name="source[url]"]').val(params.source.url);var param_type=params.source.param;if(param_type=='num'){$(formObj+' input[name="source[param_num_start]"]').val(params.source.param_num_start);$(formObj+' input[name="source[param_num_end]"]').val(params.source.param_num_end);$(formObj+' input[name="source[param_num_inc]"]').val(params.source.param_num_inc);if(params.source.param_num_desc){$(formObj+' input[name="source[param_num_desc]"]').prop('checked',!0)}}else if(param_type=='letter'){$(formObj+' input[name="source[param_letter_start]"]').val(params.source.param_letter_start);$(formObj+' input[name="source[param_letter_end]"]').val(params.source.param_letter_end);if(params.source.param_letter_desc){$(formObj+' input[name="source[param_letter_desc]"]').prop('checked',!0)}}else if(param_type=='custom'){$(formObj+' textarea[name="source[param_custom]"]').val(params.source.param_custom)}
$(formObj+' input[name="source[param]"][value="'+param_type+'"]').prop('checked',!0)}else if(params.source.type=='large'){$(formObj+' textarea[name="source[large_urls]"]').val(params.source.large_urls)}else if(params.source.type=='api'){$(formObj+' input[name="source[api]"]').val(params.source.api);$(formObj+' input[name="source[api_json]"]').val(params.source.api_json)}}}else if(op=='add'){var html='';if(params.html){html=params.html}else{var htmlObj=$_o.clone_tpl('#coll_tpl_source_url');htmlObj.find('[data-id="source_url_"]').attr('id','source_url_'+generateUUID()).removeAttr('data-id');var regLarge=/[\r\n]/;if(regLarge.test(params.source_url)){htmlObj.find('input[name="config[source_url][]"]').remove()}else{htmlObj.find('textarea[name="config[source_url][]"]').remove()}
html=htmlObj.html();html=html?html:'';html=html.replace('[_source_url_]',htmlspecialchars(params.source_url))}
if(params.get){return html}else{this.source_op('clear_null');$($_o.formid+' #coll_pattern_source_url .c-p-source-urls').append(html)}}else if(op=='add_sub'){ajaxOpen({type:'POST',dataType:'json',url:$(formObj).attr('action'),data:$(formObj).serialize(),success:function(data){var dataList=data.data?data.data:{};var objid=dataList.objid?dataList.objid:'';var addParams={};if(data.code==1){var source_type=$(formObj).find('input[name="source[type]"]').val();if(source_type=='custom'){$('#myModal').modal('hide');var urls=dataList.urls;var ix=0;var url_html_list='';for(var i in urls){addParams.get=1;addParams.source_url=urls[i];ix++;if(ix==1){if(objid){var newSource=$_o.source_op('add',addParams);$('#'+objid).replaceWith(newSource);continue}}
if(params.get){return html}else{this.source_op('clear_null');$($_o.formid+' #coll_pattern_source_url .c-p-source-urls').append(html)}}else if(op=='add_sub'){ajaxOpen({type:'POST',dataType:'json',url:$(formObj).attr('action'),data:$(formObj).serialize(),success:function(data){var dataList=data.data?data.data:{};var objid=dataList.objid?dataList.objid:'';var addParams={};if(data.code==1){var source_type=$(formObj).find('input[name="source[type]"]').val();if(source_type=='custom'&&isObject(dataList.urls)&&dataList.urls.length>20){source_type='large'}
if(source_type=='custom'){$('#myModal').modal('hide');var urls=dataList.urls;var ix=0;var url_html_list='';for(var i in urls){addParams.get=1;addParams.source_url=urls[i];ix++;if(ix==1){if(objid){var newSource=$_o.source_op('add',addParams);$('#'+objid).replaceWith(newSource);continue}}
url_html_list+=$_o.source_op('add',addParams)}
if(url_html_list){$_o.source_op('add',{html:url_html_list})}}else if(source_type=='batch'){if(params.preview==1){var urls=dataList.urls;var txt='';for(var i in urls){txt+=urls[i]+"\r\n"}
$(formObj).find('#source_preview').val(txt)}else{if(objid){addParams.get=1;addParams.source_url=dataList.url;var newSource=$_o.source_op('add',addParams);$('#'+objid).replaceWith(newSource)}else{addParams.source_url=dataList.url;$_o.source_op('add',addParams)}
@ -70,16 +77,18 @@ if(returnMergeSigns){var mergeSigns=[];for(var i in signs.area){var curSign=sign
for(var i in signs.url){var curSign=signs.url[i];if(mergeSigns.indexOf(curSign)<=-1&&signs.content.indexOf(curSign)<=-1){mergeSigns.push(curSign)}}
for(var i in signs.content){var curSign=signs.content[i];if(mergeSigns.indexOf(curSign)<=-1){mergeSigns.push(curSign)}}
return mergeSigns}else{return signs}},parent_page_signs:function(dropdownBtn){var $_o=this;var boxObj=$(dropdownBtn).parents('.c-p-url-page-signs').eq(0);if(!boxObj||boxObj.length<=0){return}
var pageType=boxObj.attr('data-page-type');var inputName=boxObj.attr('data-input-name');var pageVars=$_o.get_page_vars(pageType);var formId=pageVars.formId;var namePre=pageVars.namePre;if(!pageType||!inputName||!formId){return}
var pageType=boxObj.attr('data-page-type');var inputName=boxObj.attr('data-input-name');var isPagination=boxObj.attr('data-is-pagination');var pageVars=$_o.get_page_vars(pageType);var formId=pageVars.formId;var namePre=pageVars.namePre;if(!pageType||!inputName||!formId){return}
var dropdownMenu=boxObj.find('.dropdown-menu');if(dropdownMenu.length>0){$(dropdownMenu).html('')}
var iptObj=boxObj.find('[name="'+inputName+'"]');if(!iptObj||iptObj.length<=0){iptObj=null}
var frontUrls=new Array();$('#c_p_front_urls [id^="front_url_"]').each(function(){var frontUrl=$(this).find('[name="config[front_urls][]"]').val();frontUrls.push(frontUrl)});var levelUrls=new Array();$('#c_p_level_urls [id^="level_url_"]').each(function(){var levelUrl=$(this).find('[name="config[level_urls][]"]').val();levelUrls.push(levelUrl)});var relationUrls=new Array();$('#c_p_relation_urls [id^="relation_url_"]').each(function(){var relationUrl=$(this).find('[name="config[relation_urls][]"]').val();relationUrls.push(relationUrl)});var sourceConfig={};sourceConfig.area='';sourceConfig.url_rule='';sourceConfig.content_signs=$_o.get_content_signs($_o.formid+' [name="config[source_config][content_signs][]"]');var urlConfig={};urlConfig.area=$($_o.formid+' [name="config[area]').val();urlConfig.url_rule=$($_o.formid+' [name="config[url_rule]"]').val();urlConfig.content_signs=$_o.get_content_signs($_o.formid+' [name="config[content_signs][]"]');var pageConfig={name:'',area:'',url_rule:'',content_signs:''};var mergeType=iptObj.attr('data-merge-type');mergeType=mergeType?mergeType:'';if($_o.page_is_list(pageType)){var objid='';if(mergeType=='content_sign'){var csPageConfig=$_o.cpContentSign.curPageConfig;objid=csPageConfig.objid;if(pageType=='relation_url'){pageConfig.page=csPageConfig.relation_url.page}
var frontUrls=new Array();$('#c_p_front_urls [id^="front_url_"]').each(function(){var frontUrl=$(this).find('[name="config[front_urls][]"]').val();frontUrls.push(frontUrl)});var levelUrls=new Array();$('#c_p_level_urls [id^="level_url_"]').each(function(){var levelUrl=$(this).find('[name="config[level_urls][]"]').val();levelUrls.push(levelUrl)});var relationUrls=new Array();$('#c_p_relation_urls [id^="relation_url_"]').each(function(){var relationUrl=$(this).find('[name="config[relation_urls][]"]').val();relationUrls.push(relationUrl)});var sourceConfig={};sourceConfig.area='';sourceConfig.url_rule='';sourceConfig.content_signs=$_o.get_content_signs($_o.formid+' [name="config[source_config][content_signs][]"]');if(isPagination){sourceConfig.pagination={area:$($_o.formid).find('[name="config[source_config][pagination][area]"]').val(),url_rule:$($_o.formid).find('[name="config[source_config][pagination][url_rule]"]').val()}}
var urlConfig={};urlConfig.area=$($_o.formid+' [name="config[area]"]').val();urlConfig.url_rule=$($_o.formid+' [name="config[url_rule]"]').val();urlConfig.content_signs=$_o.get_content_signs($_o.formid+' [name="config[content_signs][]"]');if(isPagination){urlConfig.pagination={area:$($_o.formid).find('[name="config[pagination][area]"]').val(),url_rule:$($_o.formid).find('[name="config[pagination][url_rule]"]').val()}}
var pageConfig={name:'',area:'',url_rule:'',content_signs:''};var mergeType=iptObj.attr('data-merge-type');mergeType=mergeType?mergeType:'';if($_o.page_is_list(pageType)){var objid='';if(mergeType=='content_sign'){var csPageConfig=$_o.cpContentSign.curPageConfig;objid=csPageConfig.objid;if(pageType=='relation_url'){pageConfig.page=csPageConfig.relation_url.page}
pageConfig.area=csPageConfig[namePre].area;pageConfig.url_rule=csPageConfig[namePre].url_rule;pageConfig.content_signs=csPageConfig[namePre].content_signs}else{objid=$(formId).find('[name="objid"]').val();if(pageType=='relation_url'){pageConfig.page=$(formId).find('[name="relation_url[page]"]').val()}
pageConfig.area=$(formId).find('[name="'+namePre+'[area]"]').val();pageConfig.url_rule=$(formId).find('[name="'+namePre+'[url_rule]"]').val();pageConfig.content_signs=$_o.get_content_signs(formId+' [name="'+namePre+'[content_signs][]"]')}
if(objid){pageConfig.name=$('#'+objid).find('.name').attr('data-val')}
pageConfig.name=pageConfig.name?pageConfig.name:'';pageConfig.area=pageConfig.area?pageConfig.area:'';pageConfig.url_rule=pageConfig.url_rule?pageConfig.url_rule:''}
pageConfig.name=pageConfig.name?pageConfig.name:'';pageConfig.area=pageConfig.area?pageConfig.area:'';pageConfig.url_rule=pageConfig.url_rule?pageConfig.url_rule:'';if(isPagination){pageConfig.pagination={area:$(formId).find('[name="'+namePre+'[pagination][area]"]').val(),url_rule:$(formId).find('[name="'+namePre+'[pagination][url_rule]"]').val()}}}
if(mergeType=='content_sign'){mergeType+=':'+$($_o.cpContentSign.formObj+' [name="objid"]').attr('data-identity')}
var sourceIsUrl=$_o.source_is_url();ajaxOpen({type:'POST',dataType:'json',url:ulink("cpattern/page_signs"),data:{front_urls:frontUrls,source_config:sourceConfig,level_urls:levelUrls,relation_urls:relationUrls,url_config:urlConfig,page_config:pageConfig,page_type:pageType,merge_type:mergeType,source_is_url:sourceIsUrl},success:function(data){if(data.code==1){data=data.data;var pageSort=data.sort;var allSigns=data.signs;var html='';var valSigns=null;if(iptObj){valSigns=ruleInsertSign.matchN(null,null,{rule:iptObj.val()})}
var sourceIsUrl=$_o.source_is_url();ajaxOpen({type:'POST',dataType:'json',url:ulink("cpattern/page_signs"),data:{front_urls:frontUrls,source_config:sourceConfig,level_urls:levelUrls,relation_urls:relationUrls,url_config:urlConfig,page_config:pageConfig,page_type:pageType,merge_type:mergeType,source_is_url:sourceIsUrl,is_pagination:isPagination},success:function(data){if(data.code==1){data=data.data;var pageSort=data.sort;var allSigns=data.signs;var html='';var valSigns=null;if(iptObj){valSigns=ruleInsertSign.matchN(null,null,{rule:iptObj.val()})}
if(!valSigns||typeof(valSigns)!='object'){valSigns=new Array()}
var nullTips='';if(sourceIsUrl){nullTips='起始页已设为内容页'}
for(var asi in allSigns){var pageSigns=allSigns[asi]?allSigns[asi]:{};var pageName=pageSigns.name;var signs=pageSigns.signs;signs=signs?signs:{};html+='<tr><td>'+pageName+'</td>';var signKeys=['area','url','content'];for(var ski in signKeys){html+='<td>';var signKey=signKeys[ski];var keySigns=signs[signKey];if(keySigns&&keySigns.length>0){var keyGlobalSigns=signs[signKey+'_global'];for(var ksi in keySigns){var sign=keySigns[ksi];var signHtml=htmlspecialchars(sign);if(keyGlobalSigns&&keyGlobalSigns.indexOf(sign)>-1){var color=valSigns.indexOf(sign)>-1?'color:green;':'';html+='<a href="javascript:;" data-val="'+signHtml+'" style="'+color+'">'+signHtml+'</a>'}else{html+='<span style="color:#999;" title="被覆盖">'+signHtml+'</span>'}}}else{html+='<span style="color:#999;" title="'+nullTips+'">无</span>'}
@ -111,9 +120,9 @@ objEle.find('.name').attr('data-val',relation_url.name).text(relation_url.name);
if(checkName){var hasName=!1;$('#c_p_relation_urls [id^="relation_url_"] .name').each(function(){if($($_o.formObj+' [name="relation_url[name]"]').val()==$(this).attr('data-val')){hasName=!0;return!1}});if(hasName){toastr.error('该名称已存在!');return!1}}
ajaxOpen({type:'POST',dataType:'json',url:$($_o.formObj).attr('action'),data:$($_o.formObj).serialize(),success:function(data){if(data.code==1){$('#myModal').modal('hide');data=data.data;if(data){$_o.add(data.objid,data.relation_url)}}else{toastr.error(data.msg)}},error:function(data){toastr.error(data)}});return!1}}
function CpUrlWeb(cpClass){this.$_cp=cpClass}
CpUrlWeb.prototype={constructor:CpUrlWeb,page_init:function(pageType){var $_o=this;var pageVars=$_o.$_cp.get_page_vars(pageType);var boxId=pageVars.boxId;var namePre=pageVars.namePre;if(!boxId||!namePre){return}
CpUrlWeb.prototype={constructor:CpUrlWeb,page_init:function(pageType,isPagination){var $_o=this;var pageVars=$_o.$_cp.get_page_vars(pageType,null,isPagination);var boxId=pageVars.boxId;var namePre=pageVars.namePre;if(!boxId||!namePre){return}
var boxUrlWebId=boxId+'_web';$(boxUrlWebId+' [name="'+namePre+'[url_web][open]"]').bind('click',function(){if($(this).val()==1){$(boxUrlWebId+'_open').show()}else{$(boxUrlWebId+'_open').hide()}
$_o.def_config_use_url_web(pageType)});inputSelectCustom(boxUrlWebId+' select[name="'+namePre+'[url_web][charset]"]',namePre+'[url_web][charset_custom]');inputSelectCustom(boxUrlWebId+' select[name="'+namePre+'[url_web][encode]"]',namePre+'[url_web][encode_custom]');$_o.def_config_charset(pageType);$_o.def_config_encode(pageType);$(boxUrlWebId+' select[name="'+namePre+'[url_web][form_method]"]').bind('change',function(){var obj=$(boxUrlWebId+' .c-p-url-web-content-type');if($(this).val()=='post'){obj.show()}else{obj.hide()}});$_o.def_config_header_global(pageType);$(boxUrlWebId+' .add-url-web-form').bind('click',function(){$_o.add_page_url_web(pageType,'form','','')});$(boxUrlWebId+' .c-p-url-web-form').on('click','.delete-url-web-form',function(){$(this).parents('tr').eq(0).remove()});$(boxUrlWebId+' .add-url-web-header').bind('click',function(){$_o.add_page_url_web(pageType,'header','','')});$(boxUrlWebId+' .c-p-url-web-header').on('click','.delete-url-web-header',function(){$(this).parents('tr').eq(0).remove()})},page_load:function(pageType,urlWebConfig){var $_o=this;var pageVars=$_o.$_cp.get_page_vars(pageType);var formId=pageVars.formId;var boxId=pageVars.boxId;var namePre=pageVars.namePre;if(!formId||!boxId||!namePre){return}
$_o.def_config_use_url_web(pageType)});inputSelectCustom(boxUrlWebId+' select[name="'+namePre+'[url_web][charset]"]',namePre+'[url_web][charset_custom]');inputSelectCustom(boxUrlWebId+' select[name="'+namePre+'[url_web][encode]"]',namePre+'[url_web][encode_custom]');$_o.def_config_charset(pageType);$_o.def_config_encode(pageType);$(boxUrlWebId+' select[name="'+namePre+'[url_web][form_method]"]').bind('change',function(){var obj=$(boxUrlWebId+' .c-p-url-web-content-type');if($(this).val()=='post'){obj.show()}else{obj.hide()}});$_o.def_config_header_global(pageType);$(boxUrlWebId+' .add-url-web-form').bind('click',function(){$_o.add_page_url_web(pageType,isPagination,'form','','')});$(boxUrlWebId+' .c-p-url-web-form').on('click','.delete-url-web-form',function(){$(this).parents('tr').eq(0).remove()});$(boxUrlWebId+' .add-url-web-header').bind('click',function(){$_o.add_page_url_web(pageType,isPagination,'header','','')});$(boxUrlWebId+' .c-p-url-web-header').on('click','.delete-url-web-header',function(){$(this).parents('tr').eq(0).remove()})},page_load:function(pageType,urlWebConfig,isPagination){var $_o=this;var pageVars=$_o.$_cp.get_page_vars(pageType,null,isPagination);var formId=pageVars.formId;var boxId=pageVars.boxId;var namePre=pageVars.namePre;if(!formId||!boxId||!namePre){return}
if(!isObject(urlWebConfig)){urlWebConfig={}}
var urlWebNamePre=namePre+'[url_web]';urlWebConfig.open=toInt(urlWebConfig.open);$(formId+' [name="'+urlWebNamePre+'[open]"][value="'+urlWebConfig.open+'"]').trigger('click');if(urlWebConfig.open>0){showPanelCollapse(boxId+'_web')}
if(urlWebConfig.charset){$(formId+' select[name="'+urlWebNamePre+'[charset]"]').val(urlWebConfig.charset).trigger('change')}
@ -122,10 +131,10 @@ if(urlWebConfig.encode){$(formId+' select[name="'+urlWebNamePre+'[encode]"]').va
if(urlWebConfig.encode_custom){$(formId+' [name="'+urlWebNamePre+'[encode_custom]"]').val(urlWebConfig.encode_custom)}
if(urlWebConfig.form_method){$(formId+' [name="'+urlWebNamePre+'[form_method]"]').val(urlWebConfig.form_method).trigger('change')}
if(urlWebConfig.content_type){$(formId+' [name="'+urlWebNamePre+'[content_type]"]').val(urlWebConfig.content_type)}
if(urlWebConfig.form_names){var urlWebFormVals=urlWebConfig.form_vals?urlWebConfig.form_vals:{};for(var i in urlWebConfig.form_names){$_o.add_page_url_web(pageType,'form',urlWebConfig.form_names[i],urlWebFormVals[i])}}
if(urlWebConfig.form_names){var urlWebFormVals=urlWebConfig.form_vals?urlWebConfig.form_vals:{};for(var i in urlWebConfig.form_names){$_o.add_page_url_web(pageType,isPagination,'form',urlWebConfig.form_names[i],urlWebFormVals[i])}}
if(urlWebConfig.header_global){$(formId+' [name="'+urlWebNamePre+'[header_global]"][value="'+urlWebConfig.header_global+'"]').prop('checked',!0)}
if(urlWebConfig.header_names){var urlWebHeaderVals=urlWebConfig.header_vals?urlWebConfig.header_vals:{};for(var i in urlWebConfig.header_names){$_o.add_page_url_web(pageType,'header',urlWebConfig.header_names[i],urlWebHeaderVals[i])}}},add_page_url_web:function(pageType,type,name,val){var $_o=this;var pageVars=$_o.$_cp.get_page_vars(pageType);var boxId=pageVars.boxId;var namePre=pageVars.namePre;if(!boxId||!namePre||!type){return}
boxId+='_web';name=name?name:'';val=val?val:'';var tr=$_o.$_cp.clone_tpl('#coll_tpl_url_web_'+type,namePre);tr.find('[name="'+namePre+'[url_web]['+type+'_names][]"]').val(name);tr.find('[name="'+namePre+'[url_web]['+type+'_vals][]"]').val(val);tr.find('.c-p-url-page-signs').each(function(){$(this).attr('data-page-type',pageType).attr('data-input-name',namePre+$(this).attr('data-input-name'))});$(boxId).find('.c-p-url-web-'+type+' tbody').append(tr)},def_config_charset:function(pageType){var $_o=this;var val=$($_o.$_cp.formid+' [name="config[charset]"]').val();var formid=$_o.$_cp.formid;if(pageType){formid=$_o.$_cp.get_page_vars(pageType,'formId')}
if(urlWebConfig.header_names){var urlWebHeaderVals=urlWebConfig.header_vals?urlWebConfig.header_vals:{};for(var i in urlWebConfig.header_names){$_o.add_page_url_web(pageType,isPagination,'header',urlWebConfig.header_names[i],urlWebHeaderVals[i])}}},add_page_url_web:function(pageType,isPagination,type,name,val){var $_o=this;var pageVars=$_o.$_cp.get_page_vars(pageType,null,isPagination);var boxId=pageVars.boxId;var namePre=pageVars.namePre;if(!boxId||!namePre||!type){return}
boxId+='_web';name=name?name:'';val=val?val:'';var tr=$_o.$_cp.clone_tpl('#coll_tpl_url_web_'+type,namePre);tr.find('[name="'+namePre+'[url_web]['+type+'_names][]"]').val(name);tr.find('[name="'+namePre+'[url_web]['+type+'_vals][]"]').val(val);tr.find('.c-p-url-page-signs').each(function(){$(this).attr('data-page-type',pageType).attr('data-input-name',namePre+$(this).attr('data-input-name'));if(isPagination){$(this).attr('data-is-pagination',1)}});$(boxId).find('.c-p-url-web-'+type+' tbody').append(tr)},def_config_charset:function(pageType){var $_o=this;var val=$($_o.$_cp.formid+' [name="config[charset]"]').val();var formid=$_o.$_cp.formid;if(pageType){formid=$_o.$_cp.get_page_vars(pageType,'formId')}
if(!val||val=='auto'){val='自动检测'}else if(val=='custom'){if($_o.$_cp.page_is_list(pageType)){val=$($_o.$_cp.formid+' [name="config[charset_custom]"]').val();val=val?val:''}else{val=''}
val='自定义'+(val?('»'+htmlspecialchars(val)):'')}
$(formid).find('.def-config-charset').html('默认:'+val)},def_config_encode:function(pageType){var $_o=this;var val=$($_o.$_cp.formid+' [name="config[encode]"]').val();var formid=$_o.$_cp.formid;if(pageType){formid=$_o.$_cp.get_page_vars(pageType,'formId')}
@ -135,22 +144,26 @@ $(formid).find('.def-config-encode').html('默认:'+val)},def_config_header_gl
$(formid).find('.def-config-request-headers-open').html(val>0?'是':'否')},def_config_use_url_web:function(pageType){var $_o=this;var pageVars=$_o.$_cp.get_page_vars(pageType);var formId=pageVars.formId;var boxId=pageVars.boxId;var namePre=pageVars.namePre;if(!formId||!boxId||!namePre){return}
var urlWebOpen=$(formId).find('[name="'+namePre+'[url_web][open]"]:checked').val();urlWebOpen=toInt(urlWebOpen);$(boxId+'_pagination').find('.def-config-url-web-open').html(urlWebOpen>0?'是':'否')}}
function CpRenderer(cpClass){this.$_cp=cpClass}
CpRenderer.prototype={constructor:CpRenderer,page_init:function(pageType){var $_o=this;var pageVars=$_o.$_cp.get_page_vars(pageType);var boxId=pageVars.boxId;var namePre=pageVars.namePre;if(!boxId||!namePre){return}
$_o.def_config_renderer_open(pageType);var rdBoxId=boxId+'_renderer';$(rdBoxId+' .add-url-renderer').bind('click',function(){$_o.add(pageType)});$(rdBoxId+' [name="'+namePre+'[renderer][open]"]').bind('click',function(){$_o.def_config_use_renderer(pageType)});$(rdBoxId+' .c-p-url-renderer-list').on('change','select[name="'+namePre+'[renderer][types][]"]',function(){var type=$(this).val();var tr=$(this).parents('tr').eq(0);var types={'wait_time':{content:1,content_tips:'输入数字'},'scroll_top':{content:1,content_tips:'输入数字'},'click':{element:1},'val':{element:1,content:1,content_tips:'输入值'}};var tdTypeCols=3;tr.find('.td-renderer-element,.td-renderer-content').hide();tr.find('input[name="'+namePre+'[renderer][contents][]"]').attr('placeholder','');var curType=types[type];if(isObject(curType)){if(curType.element){tr.find('.td-renderer-element').show();tdTypeCols-=1}
CpRenderer.prototype={constructor:CpRenderer,page_init:function(pageType,isPagination){var $_o=this;var pageVars=$_o.$_cp.get_page_vars(pageType,null,isPagination);var boxId=pageVars.boxId;var namePre=pageVars.namePre;if(!boxId||!namePre){return}
$_o.def_config_renderer_open(pageType);var rdBoxId=boxId+'_renderer';$(rdBoxId+' .add-url-renderer').bind('click',function(){$_o.add(pageType,isPagination)});$(rdBoxId+' [name="'+namePre+'[renderer][open]"]').bind('click',function(){$_o.def_config_use_renderer(pageType)});if(isPagination){$(rdBoxId+' [name="'+namePre+'[renderer][open_pn]"]').bind('click',function(){if($(this).val()==1){$(rdBoxId+'_open_pn').show()}else{$(rdBoxId+'_open_pn').hide()}})}
$(rdBoxId+' .c-p-url-renderer-list').on('change','select[name="'+namePre+'[renderer][types][]"]',function(){var type=$(this).val();var tr=$(this).parents('tr').eq(0);var types={'wait_time':{content:1,content_tips:'输入数字'},'scroll_top':{content:1,content_tips:'输入数字'},'click':{element:1},'val':{element:1,content:1,content_tips:'输入值'}};var tdTypeCols=3;tr.find('.td-renderer-element,.td-renderer-content').hide();tr.find('input[name="'+namePre+'[renderer][contents][]"]').attr('placeholder','');var curType=types[type];if(isObject(curType)){if(curType.element){tr.find('.td-renderer-element').show();tdTypeCols-=1}
if(curType.content){tr.find('.td-renderer-content').show();tdTypeCols-=1;if(curType.content_tips){tr.find('input[name="'+namePre+'[renderer][contents][]"]').attr('placeholder',curType.content_tips)}}}
tr.find('.td-renderer-type').attr('colspan',tdTypeCols)});$(rdBoxId+' .c-p-url-renderer-list').on('click','.delete-url-renderer',function(){$(this).parents('tr').eq(0).remove()});eleExchange(rdBoxId+' .c-p-url-renderer-list','.icon-drag-move','tr')},page_load:function(pageType,rdConfig){var $_o=this;var pageVars=$_o.$_cp.get_page_vars(pageType);var boxId=pageVars.boxId;var namePre=pageVars.namePre;if(!boxId||!namePre){return}
var rdBoxId=boxId+'_renderer';if(isObject(rdConfig)){$(rdBoxId).find('[name="'+namePre+'[renderer][open]"][value="'+rdConfig.open+'"]').prop('checked',!0).trigger('click');var rdTypes=isObject(rdConfig.types)?rdConfig.types:[];var rdElements=isObject(rdConfig.elements)?rdConfig.elements:[];var rdContents=isObject(rdConfig.contents)?rdConfig.contents:[];var showPanel=!1;var openVal=rdConfig.open=='y'?true:!1;var openDef=$($_o.$_cp.formid+' [name="config[page_render]"]:checked').val();openDef=toInt(openDef);openDef=openDef>0?true:!1;if(rdTypes&&rdTypes.length>0){for(var i in rdTypes){$_o.add(pageType,rdTypes[i],rdElements[i],rdContents[i])}
tr.find('.td-renderer-type').attr('colspan',tdTypeCols)});$(rdBoxId+' .c-p-url-renderer-list').on('click','.delete-url-renderer',function(){$(this).parents('tr').eq(0).remove()});eleExchange(rdBoxId+' .c-p-url-renderer-list','.icon-drag-move','tr')},page_load:function(pageType,rdConfig,isPagination){var $_o=this;var pageVars=$_o.$_cp.get_page_vars(pageType,null,isPagination);var boxId=pageVars.boxId;var namePre=pageVars.namePre;if(!boxId||!namePre){return}
var rdBoxId=boxId+'_renderer';if(isObject(rdConfig)){$(rdBoxId).find('[name="'+namePre+'[renderer][open]"][value="'+rdConfig.open+'"]').prop('checked',!0).trigger('click');var rdTypes=isObject(rdConfig.types)?rdConfig.types:[];var rdElements=isObject(rdConfig.elements)?rdConfig.elements:[];var rdContents=isObject(rdConfig.contents)?rdConfig.contents:[];var showPanel=!1;var openVal=rdConfig.open=='y'?true:!1;var openDef=$($_o.$_cp.formid+' [name="config[page_render]"]:checked').val();openDef=toInt(openDef);openDef=openDef>0?true:!1;if(rdTypes&&rdTypes.length>0){for(var i in rdTypes){$_o.add(pageType,isPagination,rdTypes[i],rdElements[i],rdContents[i])}
if((!rdConfig.open&&openDef)||openVal){showPanel=!0}}else{if(rdConfig.open){if(openVal!=openDef){showPanel=!0}}}
if(showPanel){showPanelCollapse(rdBoxId)}}},add:function(pageType,rdType,rdElement,rdContent){var $_o=this;var pageVars=$_o.$_cp.get_page_vars(pageType);var boxId=pageVars.boxId;var namePre=pageVars.namePre;if(!boxId||!namePre){return}
if(isPagination){$(rdBoxId+' [name="'+namePre+'[renderer][open_pn]"][value="'+rdConfig.open_pn+'"]').prop('checked',!0).trigger('click');if(rdConfig.open_pn){showPanel=!0}else{showPanel=!1}}
if(showPanel){showPanelCollapse(rdBoxId)}}},add:function(pageType,isPagination,rdType,rdElement,rdContent){var $_o=this;var pageVars=$_o.$_cp.get_page_vars(pageType,null,isPagination);var boxId=pageVars.boxId;var namePre=pageVars.namePre;if(!boxId||!namePre){return}
var rdBoxId=boxId+'_renderer';var tr=$_o.$_cp.clone_tpl('#coll_tpl_url_renderer',namePre);if(rdType){tr.find('[name*="[renderer][types]"]').val(rdType);tr.find('[name*="[renderer][elements]"]').val(rdElement);tr.find('[name*="[renderer][contents]"]').val(rdContent)}
tr.find('.c-p-url-page-signs').each(function(){$(this).attr('data-page-type',pageType).attr('data-input-name',namePre+$(this).attr('data-input-name'))});$(rdBoxId+' .c-p-url-renderer-list table').append(tr);if(rdType){$(rdBoxId+' .c-p-url-renderer-list').find('[name*="[renderer][types]"]:last-child').trigger('change')}},def_config_renderer_open:function(pageType){var $_o=this;var val=$($_o.$_cp.formid+' [name="config[page_render]"]:checked').val();val=toInt(val);var formid=$_o.$_cp.formid;if(pageType){formid=$_o.$_cp.get_page_vars(pageType,'formId')}
tr.find('.c-p-url-page-signs').each(function(){$(this).attr('data-page-type',pageType).attr('data-input-name',namePre+$(this).attr('data-input-name'));if(isPagination){$(this).attr('data-is-pagination',1)}});$(rdBoxId+' .c-p-url-renderer-list table').append(tr);if(rdType){$(rdBoxId+' .c-p-url-renderer-list').find('[name*="[renderer][types]"]:last-child').trigger('change')}},def_config_renderer_open:function(pageType){var $_o=this;var val=$($_o.$_cp.formid+' [name="config[page_render]"]:checked').val();val=toInt(val);var formid=$_o.$_cp.formid;if(pageType){formid=$_o.$_cp.get_page_vars(pageType,'formId')}
$(formid).find('.def-config-page-render').html(val>0?'是':'否')},def_config_use_renderer:function(pageType){var $_o=this;var pageVars=$_o.$_cp.get_page_vars(pageType);var formId=pageVars.formId;var boxId=pageVars.boxId;var namePre=pageVars.namePre;if(!formId||!boxId||!namePre){return}
var defConfigObj=$(boxId+'_pagination').find('.def-config-renderer-open');var rendererOpen=$(formId).find('[name="'+namePre+'[renderer][open]"]:checked').val();if(rendererOpen){defConfigObj.html(rendererOpen=='y'?'是':'否').show();defConfigObj.parent().find('.def-config-page-render').hide()}else{defConfigObj.parent().find('.def-config-page-render').show();defConfigObj.hide()}},}
var defConfigObj=$(boxId+'_pagination').find('.def-config-renderer-open');var rendererOpen=$(formId).find('[name="'+namePre+'[renderer][open]"]:checked').val();if(rendererOpen){defConfigObj.html(rendererOpen=='y'?'是':'否').show();defConfigObj.parent().find('.def-config-page-render').hide()}else{defConfigObj.parent().find('.def-config-page-render').show();defConfigObj.hide()}}}
function CpPagination(cpClass){this.$_cp=cpClass}
CpPagination.prototype={constructor:CpPagination,page_init:function(pageType){var $_o=this;if(pageType=='source_url'||pageType=='level_url'||pageType=='url'){var pageVars=$_o.$_cp.get_page_vars(pageType);var formId=pageVars.formId;var boxId=pageVars.boxId;var namePre=pageVars.namePre;if(!formId||!boxId||!namePre){return}
var pnBoxId=boxId+'_pagination';var pnNamePre=namePre+'[pagination]';$(formId+' select[name="'+pnNamePre+'[area_module]"],select[name="'+pnNamePre+'[url_rule_module]"]').bind('click',function(){$_o.$_cp.rule_module_slt(this)});$(pnBoxId+' [name="'+pnNamePre+'[open]"]').bind('click',function(){if($(this).val()==1){$(pnBoxId+'_open').show()}else{$(pnBoxId+'_open').hide()}});if(pageType=='url'){$(pnBoxId).on('click','.add-url-pagination-field',function(){var url=ulink("cpattern/pagination_field?is_loop=_is_loop_",{'_is_loop_':$_o.$_cp.field_is_loop()});windowModal('分页字段',url)});$(pnBoxId+' .c-p-url-pagination-fields').on('click','.field',function(){var parent=$(this).parents('[id^="pagination_field_"]').eq(0);var objid=parent.attr('id');var pnField=parent.find('[name="'+pnNamePre+'[fields][]"]').val();var url=ulink("cpattern/pagination_field?objid=_objid_&pagination_field=_pnfield_&is_loop=_is_loop_",{'_objid_':objid,'_pnfield_':pnField,'_is_loop_':$_o.$_cp.field_is_loop()});windowModal('分页字段',url)});$(pnBoxId+' .c-p-url-pagination-fields').on('click','.delete',function(){var parent=$(this).parents('[id^="pagination_field_"]').eq(0);confirmRight('确定删除?',function(){parent.remove()})})}}},page_load:function(pageType,pnConfig){var $_o=this;if(pageType=='source_url'||pageType=='level_url'||pageType=='url'){var pageVars=$_o.$_cp.get_page_vars(pageType);if(!pageVars.boxId||!pageVars.namePre){return}
CpPagination.prototype={constructor:CpPagination,page_has_pn:function(pageType){if(pageType=='source_url'||pageType=='level_url'||pageType=='url'){return!0}else{return!1}},page_init:function(pageType){var $_o=this;if($_o.page_has_pn(pageType)){var pageVars=$_o.$_cp.get_page_vars(pageType);var formId=pageVars.formId;var boxId=pageVars.boxId;var namePre=pageVars.namePre;if(!formId||!boxId||!namePre){return}
var pnBoxId=boxId+'_pagination';var pnNamePre=namePre+'[pagination]';$(formId+' select[name="'+pnNamePre+'[area_module]"],select[name="'+pnNamePre+'[url_rule_module]"]').bind('click',function(){$_o.$_cp.rule_module_slt(this)});$(pnBoxId+' [name="'+pnNamePre+'[open]"]').bind('click',function(){if($(this).val()==1){$(pnBoxId+'_open').show()}else{$(pnBoxId+'_open').hide()}});if(pageType=='url'){$(pnBoxId).on('click','.add-url-pagination-field',function(){var url=ulink("cpattern/pagination_field?is_loop=_is_loop_",{'_is_loop_':$_o.$_cp.field_is_loop()});windowModal('分页字段',url)});$(pnBoxId+' .c-p-url-pagination-fields').on('click','.field',function(){var parent=$(this).parents('[id^="pagination_field_"]').eq(0);var objid=parent.attr('id');var pnField=parent.find('[name="'+pnNamePre+'[fields][]"]').val();var url=ulink("cpattern/pagination_field?objid=_objid_&pagination_field=_pnfield_&is_loop=_is_loop_",{'_objid_':objid,'_pnfield_':pnField,'_is_loop_':$_o.$_cp.field_is_loop()});windowModal('分页字段',url)});$(pnBoxId+' .c-p-url-pagination-fields').on('click','.delete',function(){var parent=$(this).parents('[id^="pagination_field_"]').eq(0);confirmRight('确定删除?',function(){parent.remove()})})}
$_o.$_cp.cpUrlWeb.page_init(pageType,!0);$_o.$_cp.cpRenderer.page_init(pageType,!0)}},page_load:function(pageType,pnConfig){var $_o=this;if($_o.page_has_pn(pageType)){var pageVars=$_o.$_cp.get_page_vars(pageType);if(!pageVars.boxId||!pageVars.namePre){return}
var pnBoxId=pageVars.boxId+'_pagination';var pnNamePre=pageVars.namePre+'[pagination]';if(isObject(pnConfig)){$_o.$_cp.load_page_rule(pageType,pnConfig,!0);$(pnBoxId+' [name="'+pnNamePre+'[max]"]').val(toInt(pnConfig.max));$(pnBoxId+' [name="'+pnNamePre+'[use_url_web]"][value="'+pnConfig.use_url_web+'"]').prop('checked',!0);$(pnBoxId+' [name="'+pnNamePre+'[use_renderer]"][value="'+pnConfig.use_renderer+'"]').prop('checked',!0);pnConfig.open=toInt(pnConfig.open);if(pnConfig.open){$(pnBoxId+' [name="'+pnNamePre+'[open]"][value="'+pnConfig.open+'"]').trigger('click');if(pnConfig.open>0){showPanelCollapse(pnBoxId)}}
if(pageType=='url'){if(pnConfig.fields){for(var i in pnConfig.fields){$_o.field_op(pageType,'add',{pagination_field:pnConfig.fields[i]})}}}}}},field_op:function(pageType,op,params){var $_o=this;if(pageType!='url'){return}
if(pageType=='url'){if(pnConfig.fields){for(var i in pnConfig.fields){$_o.field_op(pageType,'add',{pagination_field:pnConfig.fields[i]})}}}
$_o.$_cp.cpUrlWeb.page_load(pageType,pnConfig.url_web,!0);$_o.$_cp.cpRenderer.page_load(pageType,pnConfig.renderer,!0)}}},field_op:function(pageType,op,params){var $_o=this;if(pageType!='url'){return}
params=params?params:{};var formObj=params.formObj?params.formObj:'#form_pagination_field';var pageVars=$_o.$_cp.get_page_vars(pageType);if(!pageVars.boxId||!pageVars.namePre){return}
var pnBoxId=pageVars.boxId+'_pagination';var pnNamePre=pageVars.namePre+'[pagination]';if(op=='init'){var fieldNames=$_o.$_cp.get_field_names();var fieldOptions='<option value="">--请选择--</option><option value="::all">-全部字段-</option>';for(var i in fieldNames){fieldOptions+='<option value="'+fieldNames[i]+'">'+fieldNames[i]+'</option>'}
$(formObj+' select[name="pagination_field[field]"]').html(fieldOptions);$(formObj).bind('submit',function(){$_o.field_op(pageType,'add_sub');return!1});if(isObject(params.pagination_field)){$(formObj+' select[name="pagination_field[field]"]').val(params.pagination_field.field);$(formObj+' [name="pagination_field[delimiter]"]').val(params.pagination_field.delimiter)}}else if(op=='add'){params.pagination_field=isObject(params.pagination_field)?params.pagination_field:{};var tpl='<a href="javascript:;" class="field" data-field="__field__">__field_name__</a><em class="glyphicon glyphicon-remove-circle delete"></em><input type="hidden" name="'+pnNamePre+'[fields][]" value="__pn_field__" />';var fieldName=params.pagination_field.field=='::all'?'-全部字段-':params.pagination_field.field;tpl=tpl.replace(/__field__/ig,params.pagination_field.field).replace(/__field_name__/ig,htmlspecialchars(fieldName)).replace(/__pn_field__/ig,encode_json2urlbase(params.pagination_field));var objid=params.objid;if(!objid){objid='pagination_field_'+pageType+'_'+generateUUID();$(pnBoxId+' .c-p-url-pagination-fields').append('<div class="param-label" id="'+objid+'"></div>')}
@ -168,9 +181,10 @@ signHtml+='</div>';$(signListId).append(signHtml)}}
$(signListId).off('click','a[data-val]').on('click','a[data-val]',function(){insertAtCaret($($_o.formObj+' [name="field[sign]"]'),$(this).attr('data-val'))})});$($_o.formObj+' select[name="field[module]"]').bind('change',function(){$($_o.formObj+' .c-p-field-module').hide();$($_o.formObj+' .c-p-field-module[module="'+$(this).val()+'"]').show();var source_module=new Array('rule','xpath','json','auto','sign');var in_module=!1;for(var i in source_module){if($(this).val()==source_module[i]){in_module=!0;break}}
if(in_module){$($_o.formObj+' .c-p-field-source').show()}else{$($_o.formObj+' select[name="field[source]"]').val('');$($_o.formObj+' .c-p-field-source').hide()}});$($_o.formObj+' select[name="field[extract_module]"]').bind('change',function(){$('.c-p-field-extract-module').hide();$('.c-p-field-extract-module[extract-module="'+$(this).val()+'"]').show()});var fieldNames=$_o.$_cp.get_field_names();for(var i in fieldNames){if(fieldData&&fieldData.name==fieldNames[i]){continue}
$($_o.formObj+' #c_p_field_merge_list').append('<a href="javascript:;" style="margin-right:10px;" data-val="[字段:'+fieldNames[i]+']">[字段:'+fieldNames[i]+']</a>');$($_o.formObj+' [name="field[extract]"]').append('<option value="'+fieldNames[i]+'">'+fieldNames[i]+'</option>')}
$($_o.formObj+' #c_p_field_time_format_list').on('click','a[data-val]',function(){insertAtCaret($($_o.formObj+' [name="field[time_format]"]'),$(this).attr('data-val'))});$($_o.formObj+' #c_p_field_merge_list').on('click','a[data-val]',function(){insertAtCaret($($_o.formObj+' [name="field[merge]"]'),$(this).attr('data-val'))});$.datetimepicker.setLocale('zh');$($_o.formObj+' input[name="field[time_start]"],#form_field input[name="field[time_end]"]').datetimepicker();$($_o.formObj).bind('submit',function(){$_o.add_sub();return!1});cpRuleModuleInit($_o.formObj,'field','');cpRuleModuleInit($_o.formObj,'field','extract_');if(fieldData){for(var i in fieldData){var fieldEle=$($_o.formObj+' [name="field['+i+']"]');if(fieldEle.is('input:text')){fieldEle.val(fieldData[i])}else if(fieldEle.is('select')){fieldEle.val(fieldData[i]).trigger("change")}}
$($_o.formObj+' #c_p_field_time_format_list').on('click','a[data-val]',function(){insertAtCaret($($_o.formObj+' [name="field[time_format]"]'),$(this).attr('data-val'))});$($_o.formObj+' #c_p_field_merge_list').on('click','a[data-val]',function(){insertAtCaret($($_o.formObj+' [name="field[merge]"]'),$(this).attr('data-val'))});$.datetimepicker.setLocale('zh');$($_o.formObj+' input[name="field[time_start]"],#form_field input[name="field[time_end]"]').datetimepicker();$($_o.formObj).bind('submit',function(){$_o.add_sub();return!1});cpRuleModuleInit($_o.formObj,'field','');cpRuleModuleInit($_o.formObj,'field','extract_');if(fieldData){for(var i in fieldData){var fieldEle=$($_o.formObj+' [name="field['+i+']"]');if(fieldEle.is('input:text')||fieldEle.is('textarea')){fieldEle.val(fieldData[i])}else if(fieldEle.is('select')){fieldEle.val(fieldData[i]).trigger("change")}}
if(!fieldData.hasOwnProperty('source')){$($_o.formObj+' [name="field[source]"]').trigger("change")}
$($_o.formObj+' [name="field[auto]"][value="'+fieldData.auto+'"]').prop('checked',!0);cpRuleModuleLoad($_o.formObj,'field','',fieldData);cpRuleModuleLoad($_o.formObj,'field','extract_',fieldData)}},add:function(objid,fieldData,processData){var $_o=this;var fieldSource='内容页';if(fieldData.source){var fsource=fieldData.source.split(':');fieldSource=$_o.$_cp.get_page_vars(fsource[0],'title');if(fsource[1]){fieldSource+=':'+fsource[1]}}
$($_o.formObj+' [name="field[num_start]"]').val(toInt(fieldData.num_start));$($_o.formObj+' [name="field[num_end]"]').val(toInt(fieldData.num_end));$($_o.formObj+' [name="field[auto]"][value="'+fieldData.auto+'"]').prop('checked',!0);if(fieldData.time_stamp){$($_o.formObj+' [name="field[time_stamp]"]').prop('checked',!0)}
cpRuleModuleLoad($_o.formObj,'field','',fieldData);cpRuleModuleLoad($_o.formObj,'field','extract_',fieldData)}},add:function(objid,fieldData,processData){var $_o=this;var fieldSource='内容页';if(fieldData.source){var fsource=fieldData.source.split(':');fieldSource=$_o.$_cp.get_page_vars(fsource[0],'title');if(fsource[1]){fieldSource+=':'+fsource[1]}}
var isLoop='';if(fieldData.module=='rule'){if(fieldData.rule_multi&&fieldData.rule_multi_type=='loop'){isLoop=' - 循环入库'}}else if(fieldData.module=='xpath'){if(fieldData.xpath_multi&&fieldData.xpath_multi_type=='loop'){isLoop=' - 循环入库'}}else if(fieldData.module=='json'){if(fieldData.json_loop){isLoop=' - 循环入库'}}else if(fieldData.module=='extract'||fieldData.module=='merge'){$($_o.$_cp.formid+' #coll_pattern_field').find('.sort-field').show()}
if(isLoop){$('#c_p_field_loop_tips').show()}
if(objid){var eleObj=$($_o.$_cp.formid+' #'+objid);eleObj.find('.field-name').attr('data-val',fieldData.name).text(fieldData.name);eleObj.find('.field-source').attr('data-val',fieldData.source).text(fieldSource);eleObj.find('.field-module').attr('data-val',fieldData.module).text(window.tpl_lang['field_module_'+fieldData.module]+isLoop);if(isLoop){eleObj.find('.field-module').attr('data-is-loop',1)}else{eleObj.find('.field-module').removeAttr('data-is-loop')}
@ -188,20 +202,20 @@ CpProcess.prototype={constructor:CpProcess,init:function(processData,isCommon,is
if($($_o.processForm).is('form')){$($_o.processForm).bind('submit',function(){$_o.add_sub();return!1})}
$($_o.processBox+' .process-add').bind('click',function(){var module=$($_o.processBox+' select[name="process[module]"]').val();$_o.add({'add_new':1,'module':module})});if($($_o.processForm).prop('inited')==1){return!0}
$($_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}
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(){pluginFuncOp.tips('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.txt_insert_field($_o.processForm,'.p-m-api-url-field select',function(sltObj){return $(sltObj).parents('section').eq(0).find('[data-process="api:api_url"]')});$($_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_rule_module"]',function(){var ruleModule=$(this).val();ruleModule=ruleModule?ruleModule:'';var obj=$(this).parents('section').eq(0);obj.find('.p-m-api-rule-module').hide();obj.find('.p-m-api-rule-module[data-rule-module="'+ruleModule+'"]').show()});cpRuleModuleInit($_o.processForm,'data-process','api:api_');$($_o.processForm).on('change','[data-process="download:download_op"]',function(){var obj=$(this).parents('section').eq(0);var val=$(this).val();obj.find('.p-m-download-op').hide();obj.find('.p-m-download-op[data-op="'+val+'"]').show()});$($_o.processForm).on('click','.p-m-download-file-tag .dropdown-menu a[data-val]',function(){var prt=$(this).parents('.p-m-download-file-tag').eq(0);var obj=prt.find('[data-process="download:download_file_tag"]');var val=obj.val();if(val){val=val.split(',')}else{val=new Array()}
val.push($(this).attr('data-val'));val=val.join(',');obj.val(val)});$($_o.processForm).on('click','.c-p-process-sign-wildcard',function(){var toObj=$(this).parent().siblings('[data-process]');ruleInsertSign.wildcard(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}
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;pluginFuncOp.load({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}
params.module=htmlspecialchars(params.module);params.title=params.title?htmlspecialchars(params.title):'';var parentid=$($_o.processForm+' .c-p-process-accordion').attr('id');if(!parentid){parentid='p_accordion_'+generateUUID();$($_o.processForm+' .c-p-process-accordion').attr('id',parentid)}
var dataParent=parentid?('data-parent="#'+parentid+'"'):'';var moduleHtml=$($_o.processBox+' .c-p-process-module[module="'+params.module+'"]').html();if(params.module=='html'){moduleHtml=moduleHtml.replace(/p_m_html_allow/ig,'p_m_html_allow_'+generateUUID());moduleHtml=moduleHtml.replace(/p_m_html_filter/ig,'p_m_html_filter_'+generateUUID())}
var processName='process[i_'+generateUUID()+']';moduleHtml='<input type="hidden" name="'+processName+'[module]" value="'+params.module+'" />'+moduleHtml;var collapseId='p_collapse_'+generateUUID();var html=$_o.$_cp.clone_tpl('#coll_tpl_process');html.attr('data-name',processName);html.find('a[data-toggle="collapse"]').attr('data-parent','#'+parentid).attr('href','#'+collapseId);if(params.title){html.find('.panel-title > a[data-toggle="collapse"]').text(window.tpl_lang['process_module_'+params.module]+':');html.find('.panel-title-title > a[data-toggle="collapse"]').text(params.title).show()}else{html.find('.panel-title > a[data-toggle="collapse"]').text(window.tpl_lang['process_module_'+params.module]);html.find('.panel-title-title > a[data-toggle="collapse"]').hide()}
html.find('.panel-title-title > input:text').attr('name',processName+'[title]').val(params.title?params.title:'');html.find('.panel-collapse').attr('id',collapseId);if(params.add_new){html.find('.panel-collapse').addClass('in')}
html.find('.panel-body').html(moduleHtml);$($_o.processForm+' .c-p-process-accordion').append(html);$($_o.processForm).show();var curCollapse=$_o.processForm+' #'+collapseId;$(curCollapse).find('[data-process]').each(function(){var eleName=$(this).attr('data-process').split(':');eleName[1]=processName+'['+eleName[1]+']';if(eleName.length>=3){eleName[1]+=eleName[2]?('['+eleName[2]+']'):'[]'}
if(eleName.length>=4){eleName[1]+=eleName[3]?('['+eleName[3]+']'):'[]'}
$(this).attr('name',eleName[1])});if(params.module=='html'){$(curCollapse).find('[data-process="html:html_allow"]').val(params.html_allow?params.html_allow:'');$(curCollapse).find('[data-process="html:html_filter"]').val(params.html_filter?params.html_filter:'');if(params.html_filter){$(curCollapse).find('a[href^="#p_m_html_filter"]').tab('show')}}else if(params.module=='insert'){$(curCollapse).find('[data-process="insert:insert_loc"]').val(params.insert_loc?params.insert_loc:'').trigger('change');$(curCollapse).find('[data-process="insert:insert_txt"]').val(params.insert_txt?params.insert_txt:'')}else if(params.module=='replace'){$(curCollapse).find('[data-process="replace:replace_from"]').val(params.replace_from?params.replace_from:'');$(curCollapse).find('[data-process="replace:replace_to"]').val(params.replace_to?params.replace_to:'')}else if(params.module=='filter'){$(curCollapse).find('[data-process="filter:filter_list"]').val(params.filter_list?params.filter_list:'');$(curCollapse).find('[data-process="filter:filter_replace"]').val(params.filter_replace?params.filter_replace:'');$(curCollapse).find('[data-process="filter:filter_pass"][value="'+params.filter_pass+'"]').prop('checked',!0)}else if(params.module=='tool'){$(curCollapse).find('[data-process="tool:tool_list"]').attr('name',processName+'[tool_list][]');if(params.tool_list){for(var ti in params.tool_list){$(curCollapse).find('[data-process="tool:tool_list"][value="'+params.tool_list[ti]+'"]').prop('checked',!0)}}}else if(params.module=='download'){$(curCollapse).find('[data-process="download:download_op"]').val(params.download_op?params.download_op:'').trigger('change');$(curCollapse).find('[data-process="download:download_file_tag"]').val(params.download_file_tag?params.download_file_tag:'');$(curCollapse).find('[data-process="download:download_file_must"]').val(params.download_file_must?params.download_file_must:'');$(curCollapse).find('[data-process="download:download_file_ban"]').val(params.download_file_ban?params.download_file_ban:'')}else if(params.module=='translate'){$(curCollapse).find('[data-process="translate:translate_from"]').val(params.translate_from?params.translate_from:'').trigger('change');$(curCollapse).find('[data-process="translate:translate_to"]').val(params.translate_to?params.translate_to:'').trigger('change');$(curCollapse).find('[data-process="translate:translate_from_custom"]').val(params.translate_from_custom?params.translate_from_custom:'');$(curCollapse).find('[data-process="translate:translate_to_custom"]').val(params.translate_to_custom?params.translate_to_custom:'')}else if(params.module=='batch'){$(curCollapse).find('[data-process="batch:batch_list"]').val(params.batch_list?params.batch_list:'')}else if(params.module=='substr'){$(curCollapse).find('[data-process="substr:substr_len"]').val(params.substr_len?params.substr_len:'');$(curCollapse).find('[data-process="substr:substr_end"]').val(params.substr_end?params.substr_end:'')}else if(params.module=='func'){$(curCollapse).find('[data-process="func:func_param"]').val(params.func_param?params.func_param:'');loadPluginFunc({module:'process',boxObj:$(curCollapse),funcObj:'[data-process="func:func_name"]',paramObj:'[data-process="func:func_param"]',funcVal:params.func_name,cache:!0})}else if(params.module=='if'){var ifTrTpl=$(curCollapse).find('.p-m-if-table-tpl');var ifTable=$(curCollapse).find('.p-m-if-table');ifTable.attr('data-tpl',ifTrTpl.html());ifTrTpl.remove();if(params.if_type){$(curCollapse).find('[data-process="if:if_type"]').val(params.if_type)}
$(this).attr('name',eleName[1])});if(params.module=='html'){$(curCollapse).find('[data-process="html:html_allow"]').val(params.html_allow?params.html_allow:'');$(curCollapse).find('[data-process="html:html_filter"]').val(params.html_filter?params.html_filter:'');if(params.html_filter){$(curCollapse).find('a[href^="#p_m_html_filter"]').tab('show')}}else if(params.module=='insert'){$(curCollapse).find('[data-process="insert:insert_loc"]').val(params.insert_loc?params.insert_loc:'').trigger('change');$(curCollapse).find('[data-process="insert:insert_txt"]').val(params.insert_txt?params.insert_txt:'')}else if(params.module=='replace'){$(curCollapse).find('[data-process="replace:replace_from"]').val(params.replace_from?params.replace_from:'');$(curCollapse).find('[data-process="replace:replace_to"]').val(params.replace_to?params.replace_to:'')}else if(params.module=='filter'){$(curCollapse).find('[data-process="filter:filter_list"]').val(params.filter_list?params.filter_list:'');$(curCollapse).find('[data-process="filter:filter_replace"]').val(params.filter_replace?params.filter_replace:'');$(curCollapse).find('[data-process="filter:filter_pass"][value="'+params.filter_pass+'"]').prop('checked',!0)}else if(params.module=='tool'){$(curCollapse).find('[data-process="tool:tool_list"]').attr('name',processName+'[tool_list][]');if(params.tool_list){for(var ti in params.tool_list){$(curCollapse).find('[data-process="tool:tool_list"][value="'+params.tool_list[ti]+'"]').prop('checked',!0)}}}else if(params.module=='download'){$(curCollapse).find('[data-process="download:download_op"]').val(params.download_op?params.download_op:'').trigger('change');$(curCollapse).find('[data-process="download:download_file_tag"]').val(params.download_file_tag?params.download_file_tag:'');$(curCollapse).find('[data-process="download:download_file_must"]').val(params.download_file_must?params.download_file_must:'');$(curCollapse).find('[data-process="download:download_file_ban"]').val(params.download_file_ban?params.download_file_ban:'')}else if(params.module=='translate'){$(curCollapse).find('[data-process="translate:translate_from"]').val(params.translate_from?params.translate_from:'').trigger('change');$(curCollapse).find('[data-process="translate:translate_to"]').val(params.translate_to?params.translate_to:'').trigger('change');$(curCollapse).find('[data-process="translate:translate_from_custom"]').val(params.translate_from_custom?params.translate_from_custom:'');$(curCollapse).find('[data-process="translate:translate_to_custom"]').val(params.translate_to_custom?params.translate_to_custom:'')}else if(params.module=='batch'){$(curCollapse).find('[data-process="batch:batch_list"]').val(params.batch_list?params.batch_list:'');$(curCollapse).find('[data-process="batch:batch_sign"]').val(params.batch_sign?params.batch_sign:'')}else if(params.module=='substr'){$(curCollapse).find('[data-process="substr:substr_len"]').val(params.substr_len?params.substr_len:'');$(curCollapse).find('[data-process="substr:substr_end"]').val(params.substr_end?params.substr_end:'')}else if(params.module=='func'){$(curCollapse).find('[data-process="func:func_param"]').val(params.func_param?params.func_param:'');pluginFuncOp.load({module:'process',boxObj:$(curCollapse),funcObj:'[data-process="func:func_name"]',paramObj:'[data-process="func:func_param"]',funcVal:params.func_name,cache:!0})}else if(params.module=='if'){var ifTrTpl=$(curCollapse).find('.p-m-if-table-tpl');var ifTable=$(curCollapse).find('.p-m-if-table');ifTable.attr('data-tpl',ifTrTpl.html());ifTrTpl.remove();if(params.if_type){$(curCollapse).find('[data-process="if:if_type"]').val(params.if_type)}
if(params.if_logic&&params.if_cond&&params.if_val){params.if_addon=params.if_addon?params.if_addon:{};for(var i in params.if_logic){ifTable.find('tbody').append('<tr data-if-id="'+i+'">'+ifTable.attr('data-tpl')+'</tr>');var curIfTr=ifTable.find('tr[data-if-id="'+i+'"]');curIfTr.find('[data-process="if:if_logic:"]').val(params.if_logic[i]);curIfTr.find('[data-process="if:if_cond:"]').val(params.if_cond[i]).trigger('change');curIfTr.find('[data-process="if:if_val:"]').val(params.if_val[i]);if(params.if_cond[i]=='func'){var ifFuncVal='';if(params.if_addon.func){ifFuncVal=params.if_addon.func[i]}
$_o.load_if_func(curIfTr,ifFuncVal);if(params.if_addon.turn){curIfTr.find('[data-process="if:if_addon:turn:"]').val(params.if_addon.turn[i])}}}}
eleExchange(curCollapse+' .p-m-if-table','.icon-drag-move','tbody tr')}else if(params.module=='api'){var apiTrTpl=$(curCollapse).find('.p-m-api-table-tpl');var apiTable=$(curCollapse).find('.p-m-api-table table');apiTable.attr('data-tpl',apiTrTpl.html());apiTrTpl.remove();var apiHdTrTpl=$(curCollapse).find('.p-m-api-header-table-tpl');var apiHdTable=$(curCollapse).find('.p-m-api-header-table table');apiHdTable.attr('data-tpl',apiHdTrTpl.html());apiHdTrTpl.remove();if(params.api_params){params.api_params.name=params.api_params.name?params.api_params.name:{};params.api_params.val=params.api_params.val?params.api_params.val:{};params.api_params.addon=params.api_params.addon?params.api_params.addon:{};for(var i in params.api_params.name){var trId='p-m-api-param_'+generateUUID();var trTpl='<tr id="'+trId+'">'+apiTable.attr('data-tpl')+'</tr>';apiTable.find('tbody').append(trTpl);apiTable.find('#'+trId+' [data-process="api:api_params:name:"]').val(params.api_params.name[i]);apiTable.find('#'+trId+' [data-process="api:api_params:val:"]').val(params.api_params.val[i]?params.api_params.val[i]:'').trigger('change');apiTable.find('#'+trId+' [data-process="api:api_params:addon:"]').val(params.api_params.addon[i]?params.api_params.addon[i]:'')}}
@ -228,10 +242,8 @@ $('#'+eleId).html(tpl);if(objid&&objid!=eleId){if(document.getElementById(objid)
$($_o.formObj).bind('submit',function(){$_o.add_sub();return!1});if(!isObject(pageConfig)){pageConfig={}}
if(!isObject(pageConfig[namePre])){pageConfig[namePre]={}}
$_o.curPageType=pageType;$_o.curPageConfig=pageConfig;if($_o.$_cp.page_is_list($_o.curPageType)){$('#myModal').on('hidden.bs.modal',function(e){if($_o.$_cp.page_is_list($_o.curPageType)){var curPageVars=$_o.$_cp.get_page_vars($_o.curPageType);var namePre=curPageVars.namePre;var options={'ajax_scroll_top':window.modal_scroll_top,lg:1,ajax:{type:'post',data:{}}};options.ajax.data.objid=$_o.curPageConfig.objid;options.ajax.data[namePre]=encode_json2urlbase($_o.curPageConfig[namePre]);windowModal('编辑'+curPageVars.title+'规则',ulink('cpattern/'+$_o.curPageType),options)}})}
$($_o.formObj+' select[name="content_sign[module]"]').bind('change',function(){$($_o.formObj+' .c-p-content-sign-module').hide();$($_o.formObj+' .c-p-content-sign-module[data-module="'+$(this).val()+'"]').show()});cpRuleModuleInit($_o.formObj,'content_sign','');var contentSignFunc='';if(contentSign){$($_o.formObj+' [name="objid"]').attr('data-identity',contentSign.identity);for(var i in contentSign){var csEle=$($_o.formObj+' [name="content_sign['+i+']"]');if(csEle.is('input:text')){csEle.val(contentSign[i])}else if(csEle.is('select')){csEle.val(contentSign[i]).trigger("change")}}
cpRuleModuleLoad($_o.formObj,'content_sign','',contentSign);contentSignFunc=contentSign.func;if(contentSign.func_param){$($_o.formObj+' [name="content_sign[func_param]"]').val(contentSign.func_param)}}
if(contentSignFunc){showPanelCollapse('#panel_content_sign_func')}
loadPluginFunc({module:'contentSign',boxObj:$_o.formObj,funcObj:'[name="content_sign[func]"]',funcVal:contentSignFunc,paramObj:'[name="content_sign[func_param]"]'});$($_o.formObj+' .c-p-content-sign-add-cur').bind('click',function(){insertAtCaret($($_o.formObj).find('[name="content_sign[func_param]"]'),'###')});$($_o.formObj).on('click','.c-p-url-page-signs .btn-page-signs',function(){$_o.$_cp.parent_page_signs(this)})},add_sub:function(){var $_o=this;ajaxOpen({type:'POST',dataType:'json',url:$($_o.formObj).attr('action'),data:$($_o.formObj).serialize(),success:function(data){if(data.code==1){data=data.data;if(data&&data.content_sign){var contentSign=data.content_sign;if($_o.$_cp.page_is_list($_o.curPageType)){var namePre=$_o.$_cp.get_page_vars($_o.curPageType,'namePre');var pageTypeConfig=$_o.curPageConfig[namePre];if(!isObject(pageTypeConfig.content_signs)){pageTypeConfig.content_signs=[]}
$($_o.formObj+' select[name="content_sign[module]"]').bind('change',function(){$($_o.formObj+' .c-p-content-sign-module').hide();$($_o.formObj+' .c-p-content-sign-module[data-module="'+$(this).val()+'"]').show()});$($_o.formObj+' #c_p_content_sign_add_func').bind('click',function(){$_o.add_func(null)});pluginFuncOp.initHtml($_o.formObj+' #c_p_content_sign_funcs');cpRuleModuleInit($_o.formObj,'content_sign','');if(contentSign){$($_o.formObj+' [name="objid"]').attr('data-identity',contentSign.identity);for(var i in contentSign){var csEle=$($_o.formObj+' [name="content_sign['+i+']"]');if(csEle.is('input:text')){csEle.val(contentSign[i])}else if(csEle.is('select')){csEle.val(contentSign[i]).trigger("change")}}
cpRuleModuleLoad($_o.formObj,'content_sign','',contentSign);if(isObject(contentSign.funcs)){for(var i in contentSign.funcs){$_o.add_func(contentSign.funcs[i])}}}},add_func:function(contentSignFunc){var $_o=this;pluginFuncOp.addHtml({funcData:contentSignFunc,funcName:'content_sign[funcs][{id}][func]',funcParamName:'content_sign[funcs][{id}][func_param]',tplId:'c_p_content_sign_tpl_func',listId:'c_p_content_sign_funcs',funcId:'c_p_content_sign_func_{id}'},{module:'contentSign',boxObj:$_o.formObj})},add_sub:function(){var $_o=this;ajaxOpen({type:'POST',dataType:'json',url:$($_o.formObj).attr('action'),data:$($_o.formObj).serialize(),success:function(data){if(data.code==1){data=data.data;if(data&&data.content_sign){var contentSign=data.content_sign;if($_o.$_cp.page_is_list($_o.curPageType)){var namePre=$_o.$_cp.get_page_vars($_o.curPageType,'namePre');var pageTypeConfig=$_o.curPageConfig[namePre];if(!isObject(pageTypeConfig.content_signs)){pageTypeConfig.content_signs=[]}
contentSign._objid=data.objid;pageTypeConfig.content_signs.push(contentSign);$_o.curPageConfig[namePre]=pageTypeConfig}else{$_o.page_add($_o.curPageType,data.objid,contentSign)}}
$('#myModal').modal('hide')}else{toastr.error(data.msg)}},error:function(data){toastr.error(data)}});return!1}}
function cpRuleModuleInit(boxId,name,namePre){namePre=namePre?namePre:'';var isProcess=(name=='data-process')?true:!1;if(isProcess){$(boxId).on('change','[data-process="'+namePre+'rule_multi"]',function(){var prt=$(this).parents('.p-m-api-rule-module').eq(0);if($(this).is(':checked')){prt.find('.p-m-api-rule-multi-str').show()}else{prt.find('.p-m-api-rule-multi-str').hide()}});inputSelectCustom(null,null,{box:boxId,slt:'[data-process="'+namePre+'xpath_attr"]',ipt:'[data-process="'+namePre+'xpath_attr_custom"]'});$(boxId).on('change','[data-process="'+namePre+'xpath_multi"]',function(){var prt=$(this).parents('.p-m-api-rule-module').eq(0);if($(this).is(':checked')){prt.find('.p-m-api-xpath-multi-str').show()}else{prt.find('.p-m-api-xpath-multi-str').hide()}});$(boxId).on('change','select[data-process="'+namePre+'json_arr"]',function(){var prt=$(this).parents('.p-m-api-rule-module').eq(0);if($(this).val()=='implode'){prt.find('.p-m-api-json-arr-implode').show()}else{prt.find('.p-m-api-json-arr-implode').hide()}});$(boxId).on('click','a[data-rule-sign]',function(){var prt=$(this).parents('.p-m-api-rule-module').eq(0);var obj=prt.find('[data-process="'+namePre+'rule"]');var ruleSign=$(this).attr('data-rule-sign');if(ruleSign=='sign_wildcard'){ruleInsertSign.wildcard(obj)}else if(ruleSign=='sign_match'){ruleInsertSign.match(obj)}else if(ruleSign=='sign_group'){ruleInsertSign.match(obj,{group:1})}else if(ruleSign=='sign_match_n'){var ruleMerge=prt.find('[data-process="'+namePre+'rule_merge"]');ruleInsertSign.matchN(obj,ruleMerge,{def:1})}})}else{$(boxId+' [name="'+name+'['+namePre+'rule_multi]"]').bind('change',function(){if($(this).is(':checked')){$(boxId+' #c_p_'+name+'_'+namePre+'rule_multi_str').show()}else{$(boxId+' #c_p_'+name+'_'+namePre+'rule_multi_str').hide()}});inputSelectCustom(boxId+' select[name="'+name+'['+namePre+'xpath_attr]"]',name+'['+namePre+'xpath_attr_custom]');$(boxId+' [name="'+name+'['+namePre+'xpath_multi]"]').bind('change',function(){if($(this).is(':checked')){$(boxId+' #c_p_'+name+'_'+namePre+'xpath_multi_str').show()}else{$(boxId+' #c_p_'+name+'_'+namePre+'xpath_multi_str').hide()}});$(boxId+' select[name="'+name+'['+namePre+'json_arr]"]').bind('change',function(){if($(this).val()=='implode'){$(boxId+' #c_p_'+name+'_'+namePre+'json_arr_implode').show()}else{$(boxId+' #c_p_'+name+'_'+namePre+'json_arr_implode').hide()}})}}

14
public/static/js/admin/cpattern_test.js

@ -9,22 +9,24 @@
*/
'use strict';function CpTestSourceUrls(collId,maxNum,sourceIsUrl,hasLevels){this.coll_id=collId;this.max_num=maxNum;this.source_is_url=sourceIsUrl;this.has_levels=hasLevels;this.box_id='#win_test_source_urls';this.url_ajax_requests=new Array()}
CpTestSourceUrls.prototype={constructor:CpTestSourceUrls,init:function(){var $_o=this;$('#myModal').on('hide.bs.modal',function(e){if($_o&&$_o.url_ajax_requests){for(var i in $_o.url_ajax_requests){$_o.url_ajax_requests[i].abort()}}});$($_o.box_id).on('click','.set-test-num .set-num-btn',function(){var testNum=$($_o.box_id+' .set-test-num').find('.set-num').val();ajaxOpen({type:'get',dataType:'json',url:ulink('cpattern_test/level_num'),data:{num:testNum},async:!0,success:function(data){toastr.success(data.msg)}})});$($_o.box_id).on('click','.cont_ceshi',function(){var curUrl=$(this).attr('data-url');var test_url=ulink('cpattern_test/test_url?coll_id=_collid_&test_url=_url_',{'_collid_':$_o.coll_id,'_url_':curUrl});var urls={};$(this).parents('.source_url').each(function(){var surl=$(this).attr('data-url');if(surl){if($(this).attr('data-level')){urls['level_'+$(this).attr('data-level')]=surl}else{urls.source_url=surl}}});if(urls){for(var i in urls){test_url+='&'+i+'='+encodeURIComponent(urls[i])}}
window.open(test_url,'_blank')});$($_o.box_id).on('click','.cont_element',function(){var urls={};$(this).parents('.source_url').each(function(){var surl=$(this).attr('data-url');if(surl){if($(this).attr('data-level')){urls['level_'+$(this).attr('data-level')]=surl}else{urls.source_url=surl}}});if((/\beasymode\s*\=/i).test(window.self.location.href)&&window.top){cpEasyBrowser($(this).attr('data-url'),'url',urls)}else{var testUrl=$(this).attr('data-url');var browserUrl=cpBrowserUrl($_o.coll_id,'url',testUrl,urls);window.open(browserUrl,'_blank')}});$($_o.box_id).on('click','.cont_urls_num a',function(){var status=$(this).attr('status');if(status==1){$(this).html('[展开]');$(this).attr('status',0);$(this).parents('.cont_urls_num').eq(0).siblings('.cont_urls_list').hide()}else{$(this).html('[收起]');$(this).attr('status',1);$(this).parents('.cont_urls_num').eq(0).siblings('.cont_urls_list').show()}});$($_o.box_id+' .source_url').each(function(index){if(!$_o.source_is_url){var source_url=$(this).attr('data-url');if($_o.has_levels){$($_o.box_id+' .set-test-num').show().find('.set-num').val($_o.max_num);if(index<$_o.max_num){$_o.get_cont_urls(source_url,$(this),1)}}else{$_o.get_cont_urls(source_url,$(this),0)}}})},get_cont_urls:function(source_url,curObj,level,parentUrl,parentLevel){parentUrl=parentUrl?parentUrl:'';parentLevel=parentLevel?parentLevel:'';var $_o=this;if(source_url){curObj.children('.cont_urls_list').html('<div class="loading-sm"></div>').show();var url=ulink('cpattern_test/cont_urls?coll_id=_collid_',{'_collid_':$_o.coll_id});var url_ajax_request=ajaxOpen({type:'post',url:url,data:{source_url:source_url,level:level,parent_url:parentUrl,parent_level:parentLevel,},dataType:'json',async:!0,success:function(data){if(data.code==1){data=data.data?data.data:{};var urls=data.urls;var list='<ul style="list-style-type:'+(level>0?'decimal':'square')+';padding-left:15px;white-space:normal;overflow-x:scroll;">';if(level>0){for(var i in urls){urls[i]=htmlspecialchars(urls[i]);if(i<$_o.max_num){list+='<li class="source_url" data-url="'+urls[i]+'" data-level="'+level+'"><p><b>抓取第'+level+'级页面 “'+data.levelName+'”:</b>'+data.levelOpened+urls[i]+'</p><p class="cont_urls_num"></p><div class="cont_urls_list"></div></li>'}}
list+='</ul>';curObj.children('.cont_urls_list').html(list).show();curObj.children('.cont_urls_num').html('获取到'+urls.length+'条网址'+(urls.length>$_o.max_num?'(只测试前'+$_o.max_num+'条)':'')+' <a href="javascript:;" status="1">[收起]</a>');curObj.children('.cont_urls_list').find('.source_url').each(function(){var obj=$(this);$_o.get_cont_urls(obj.attr('data-url'),obj,data.nextLevel,data.sourceUrl,data.level)})}else{for(var i in urls){urls[i]=htmlspecialchars(urls[i]);list+='<li>[<a href="javascript:;" class="cont_ceshi" data-url="'+urls[i]+'">测试</a>] '+'[<a href="javascript:;" class="cont_element" data-url="'+urls[i]+'">分析</a>] '+data.urlOpened+urls[i]+'</li>'}
window.open(test_url,'_blank')});$($_o.box_id).on('click','.cont_element',function(){var urls={};$(this).parents('.source_url').each(function(){var surl=$(this).attr('data-url');if(surl){if($(this).attr('data-level')){urls['level_'+$(this).attr('data-level')]=surl}else{urls.source_url=surl}}});if((/\beasymode\s*\=/i).test(window.self.location.href)&&window.top){cpEasyBrowser($(this).attr('data-url'),'url',urls)}else{var testUrl=$(this).attr('data-url');var browserUrl=cpBrowserUrl($_o.coll_id,'url',testUrl,urls);window.open(browserUrl,'_blank')}});$($_o.box_id).on('click','.cont_urls_num a',function(){var status=$(this).attr('status');if(status==1){$(this).html('[展开]');$(this).attr('status',0);$(this).parents('.cont_urls_num').eq(0).siblings('.cont_urls_list').hide()}else{$(this).html('[收起]');$(this).attr('status',1);$(this).parents('.cont_urls_num').eq(0).siblings('.cont_urls_list').show()}});$($_o.box_id+' .source_url').each(function(index){if(!$_o.source_is_url){var source_url=$(this).attr('data-url');if($_o.has_levels){$($_o.box_id+' .set-test-num').show().find('.set-num').val($_o.max_num);if(index<$_o.max_num){$_o.get_cont_urls(source_url,$(this),1)}}else{$_o.get_cont_urls(source_url,$(this),0)}}})},get_cont_urls:function(source_url,curObj,level,parentUrl,parentLevel){parentUrl=parentUrl?parentUrl:'';parentLevel=parentLevel?parentLevel:'';var $_o=this;if(source_url){curObj.children('.cont_urls_list').html('<div class="loading-sm"></div>').show();var url=ulink('cpattern_test/cont_urls?coll_id=_collid_',{'_collid_':$_o.coll_id});var url_ajax_request=ajaxOpen({type:'post',url:url,data:{source_url:source_url,level:level,parent_url:parentUrl,parent_level:parentLevel,},dataType:'json',async:!0,success:function(data){if(data.code==1){data=data.data?data.data:{};var urls=data.urls;var urlMsgLinks=data.urlMsgLinks;if(!isObject(urlMsgLinks)){urlMsgLinks={}}
var list='<ul style="list-style-type:'+(level>0?'decimal':'square')+';padding-left:15px;white-space:normal;overflow-x:scroll;">';if(level>0){for(var i in urls){var urlMsgLink=urlMsgLinks[urls[i]];urlMsgLink=urlMsgLink?urlMsgLink:'';urls[i]=htmlspecialchars(urls[i]);if(i<$_o.max_num){list+='<li class="source_url" data-url="'+urls[i]+'" data-level="'+level+'"><p><b>抓取第'+level+'级页面 “'+data.levelName+'”:</b>'+data.levelOpened+urls[i]+urlMsgLink+'</p><p class="cont_urls_num"></p><div class="cont_urls_list"></div></li>'}}
list+='</ul>';curObj.children('.cont_urls_list').html(list).show();curObj.children('.cont_urls_num').html('获取到'+urls.length+'条网址'+(urls.length>$_o.max_num?'(只测试前'+$_o.max_num+'条)':'')+' <a href="javascript:;" status="1">[收起]</a>');curObj.children('.cont_urls_list').find('.source_url').each(function(){var obj=$(this);$_o.get_cont_urls(obj.attr('data-url'),obj,data.nextLevel,data.sourceUrl,data.level)})}else{for(var i in urls){var urlMsgLink=urlMsgLinks[urls[i]];urlMsgLink=urlMsgLink?urlMsgLink:'';urls[i]=htmlspecialchars(urls[i]);list+='<li>[<a href="javascript:;" class="cont_ceshi" data-url="'+urls[i]+'">测试</a>] '+'[<a href="javascript:;" class="cont_element" data-url="'+urls[i]+'">分析</a>] '+data.urlOpened+urls[i]+urlMsgLink+'</li>'}
list+='</ul>';curObj.children('.cont_urls_list').html(list).hide();curObj.children('.cont_urls_num').html('获取到'+urls.length+'条网址 <a href="javascript:;" status="0">[展开]</a>')}}else{curObj.children('.cont_urls_list').html('<span style="color:red">'+data.msg+'</span>').show()}}});$_o.url_ajax_requests.push(url_ajax_request)}}}
function CpTestUrl(collId,testType,pageSource){this.coll_id=collId;this.test=testType?testType:'get_fields';this.test_async=!0;this.page_source=pageSource?pageSource:'';this.box_id='#win_test_url';this.test_ajax_requests=new Array()}
CpTestUrl.prototype={constructor:CpTestUrl,ajax:function(params){var ajax_request=ajaxOpen(params);this.test_ajax_requests.push(ajax_request)},abort_test:function(){if(this.test_ajax_requests&&this.test_ajax_requests.length>0){for(var i in this.test_ajax_requests){this.test_ajax_requests[i].abort()}
this.test_ajax_requests=new Array()}},load_input_url:function(func){var $_o=this;var urlParams=$($_o.box_id+' [name="url_params"]').val();var inputedUrls={};$('#win_input_urls').find('[name]').each(function(){inputedUrls[$(this).attr('name')]=$(this).val()});var pageSource=$($_o.box_id+' [name="page_source"]').val();var url=ulink('cpattern_test/input_url?test=_test_&coll_id=_collid_&page_source=_source_',{'_test_':$_o.test,'_collid_':$_o.coll_id,'_source_':pageSource});if($($_o.box_id+' button.dropdown-toggle').attr('data-test')=='get_signs'){if($('#win_test_signs').find('[name="signs_cur_all"]').is(':checked')){url+='&signs_cur_all=1'}}
$_o.ajax({type:'post',url:url,dataType:'html',async:$_o.test_async,data:{url_params:urlParams,inputed_urls:inputedUrls},success:function(html){if(html){$('#win_input_urls').html(html).show()}else{$('#win_input_urls').html('').hide()}
var pageOpendObj=$('#win_input_urls').find('#input_url_page_opened');if(pageOpendObj.length>0){$($_o.box_id+' .test-page-opened').html(pageOpendObj.html()).show()}else{$($_o.box_id+' .test-page-opened').hide()}
var pageOpenedObj=$('#win_input_urls').find('#input_url_page_opened');if(pageOpenedObj.length>0){$($_o.box_id+' .test-page-opened').html(pageOpenedObj.html()).show()}else{$($_o.box_id+' .test-page-opened').hide()}
execVarFuncs(func)}})},init:function(){var $_o=this;$($_o.box_id+' .dropdown-menu a[data-test]').bind('click',function(){$_o.abort_test();var btnObj=$(this).parents('.dropdown-menu').eq(0).siblings('button.dropdown-toggle').eq(0);var testName=$(this).attr('data-test');btnObj.attr('data-test',testName);btnObj.find('.test-tips').text($(this).attr('data-title'));if(testName=='get_html'||testName=='get_browser'||testName=='get_signs'||testName=='get_pagination'){$($_o.box_id+' [name="test_url"]').attr('placeholder','输入网址');$($_o.box_id+' .test-page-sources').show()}else{$($_o.box_id+' [name="test_url"]').attr('placeholder','输入内容页网址');$($_o.box_id+' .test-page-sources').hide()}
$($_o.box_id+' .field-vals').html('');$_o.test=testName;if(testName=='get_signs'){$('#win_test_signs').show()}else{$('#win_test_signs').hide()}
if(testName=='get_pagination'){$('#win_test_pagination').show()}else{$('#win_test_pagination').hide()}
$_o.load_input_url()});$($_o.box_id+' [name="page_source"]').bind('change',function(){$_o.abort_test();$_o.load_input_url()});$($_o.box_id).off('click','[data-test-code]').on('click','[data-test-code]',function(){var objId='#'+$(this).attr('data-test-code');visualizeData('<pre>'+htmlspecialchars($(objId).val())+'</pre>')});$($_o.box_id).off('click','[data-test-visualize]').on('click','[data-test-visualize]',function(){var objId='#'+$(this).attr('data-test-visualize');visualizeData($(objId).val())});$($_o.box_id+' button.test-sub').bind('click',function(){$_o.abort_test();var testOp=$($_o.box_id+' button.dropdown-toggle').attr('data-test');testOp=testOp?testOp:'get_fields';$_o.test_async=testOp=='get_browser'?false:!0;$_o.load_input_url(function(){var test_url=$($_o.box_id+' input[name="test_url"]').val();var page_source=$($_o.box_id+' [name="page_source"]').val();if(!test_url){toastr.error('请输入网址')}else{$($_o.box_id+' .field-vals').html('<div class="loading"></div>');var url=ulink('cpattern_test/_op_?coll_id=_collid_&page_source=_source_&test_url=_url_',{'_op_':testOp,'_source_':page_source,'_collid_':$_o.coll_id,'_url_':test_url});$('#win_input_urls').find('[name]').each(function(){url+='&'+$(this).attr('name')+'='+encodeURIComponent($(this).val())});if(testOp=='get_html'){$_o.ajax({type:'get',url:url,dataType:'html',success:function(data){if(dataIsJson(data)){var json=eval('('+data+')');if(json.msg){$($_o.box_id+' .field-vals').html(json.msg)}else{var html='<label>源码:</label><textarea class="form-control" rows="5">'+data+'</textarea><label style="margin-top:15px;">JSON解析:</label><div id="win_json_tree"></div>';$($_o.box_id+' .field-vals').html(html);var jsonTreeFunc=function(){window.tool_json_tree.treeId='#win_json_tree';window.tool_json_tree.load(data)};if(window.tool_json_tree){jsonTreeFunc()}else{$.getScript(window.site_config.pub+'/static/js/admin/tool_json_tree.js',jsonTreeFunc)}}}else{var eleId=generateUUID();data=data.replace(/\</g,'&lt;').replace(/\>/g,'&gt;');var html='<label>源码:</label> <a href="javascript:;" data-test-visualize="'+eleId+'">预览</a><span style="margin-left:5px;margin-right:5px;">/</span><a href="javascript:;" data-test-browser="1">分析网页</a><textarea id="'+eleId+'" class="form-control" rows="20">'+data+'</textarea>';$($_o.box_id+' .field-vals').html(html);$($_o.box_id).find('[data-test-browser]').bind('click',function(){var pageSource=$($_o.box_id+' [name="page_source"]').val();var testUrl=$($_o.box_id+' input[name="test_url"]').val();var inputedUrls={};$('#win_input_urls').find('[name]').each(function(){inputedUrls[$(this).attr('name')]=$(this).val()});var browserUrl=cpBrowserUrl($_o.coll_id,pageSource,testUrl,inputedUrls);window.open(browserUrl,'_blank')})}}})}else{if(testOp=='get_signs'){if($('#win_test_signs').find('[name="signs_cur_all"]').is(':checked')){url+='&signs_cur_all=1'}}else if(testOp=='get_pagination'){url+='&pagination_type='+$('#win_test_pagination').find('[name="pagination_type"]:checked').val()}
$_o.ajax({type:'get',url:url,dataType:'json',async:$_o.test_async,success:function(data){if(data.code==1){var html='';if(testOp=='get_pagination'){var pnType=data.data.pagination_type;var pnUrls=data.data.urls;if(!pnType){html='<div class="page-header"><b>成功抓取到分页链接</b></div><ul>';for(var i in pnUrls){html+='<li>'+pnUrls[i]+'</li>'}
$_o.ajax({type:'get',url:url,dataType:'json',async:$_o.test_async,success:function(data){if(data.code==1){var html='';if(testOp=='get_pagination'){var pnType=data.data.pagination_type;var pnUrls=data.data.urls;var pnUrlMsgLinks=data.data.pn_links;if(!isObject(pnUrlMsgLinks)){pnUrlMsgLinks={}}
if(!pnType){html='<div class="page-header"><b>成功抓取到分页链接</b></div><ul>';for(var i in pnUrls){html+='<li>'+pnUrls[i]+(pnUrlMsgLinks[pnUrls[i]]?pnUrlMsgLinks[pnUrls[i]]:'')+'</li>'}
html+='</ul>'}else if(pnType=='next'){html='<div class="page-header"><b>成功抓取到分页链接</b>';if(pnUrls.length>=10){html+='(测试时最多抓取到第10个分页)'}
html+='</div><ul>';for(var i in pnUrls){var pnUrl=pnUrls[i];html+='<li>当前页:'+pnUrl.cur+'<br>抓取到的分页:'+pnUrl.next+'</li>'}
html+='</ul><div class="page-header"><b>循环抓取到的分页链接</b></div><ul>';for(var i in pnUrls){var pnUrl=pnUrls[i];html+='<li>'+pnUrl.next+'</li>'}
html+='</div><ul>';for(var i in pnUrls){var pnUrl=pnUrls[i];html+='<li>当前页:'+pnUrl.cur+(pnUrlMsgLinks[pnUrl.cur]?pnUrlMsgLinks[pnUrl.cur]:'')+'<br>抓取到的分页:'+pnUrl.next+(pnUrlMsgLinks[pnUrl.next]?pnUrlMsgLinks[pnUrl.next]:'')+'</li>'}
html+='</ul><div class="page-header"><b>循环抓取到的分页链接</b></div><ul>';for(var i in pnUrls){var pnUrl=pnUrls[i];html+='<li>'+pnUrl.next+(pnUrlMsgLinks[pnUrl.next]?pnUrlMsgLinks[pnUrl.next]:'')+'</li>'}
html+='</ul>'}}else if(testOp=='get_fields'){if(data.msg){toastr.success(data.msg)}
var valList=data.data.val_list;valList=valList?valList:[];if(valList.length>1){var loopTable=data.data.loop_table;loopTable=isNull(loopTable)?{}:loopTable;html+='<div class="table-responsive"><table class="table table-bordered table-hover table-test-loop"><thead><tr><td></td>';var fields=valList[0];for(var f in fields){var loopTableTh=isNull(loopTable[f])?{}:loopTable[f];var divStyle=isNull(loopTableTh.width)?'':(' style="width:'+parseInt(loopTableTh.width)+'px;"');html+='<th data-val="'+f+'"><div'+divStyle+'>'+f+'</div></th>'}
html+='</tr></thead><tbody>';var curNum=0;for(var i in valList){curNum++;var vals=valList[i];html+='<tr><td>'+curNum+'</td>';for(var f in vals){var val=vals[f]?vals[f]:'';if(val){if(dataIsJson(val)||dataIsHtml(val)){var eleId=generateUUID();html+='<td class="view-box"><input type="text" value="'+(val.replace(/"/g,'&quot;'))+'" id="'+eleId+'" class="view-ipt" /> <a class="glyphicon glyphicon-eye-open view-btn" href="javascript:;" data-test-visualize="'+eleId+'"></a></td>'}else{html+='<td><input type="text" value="'+(val.replace(/"/g,'&quot;'))+'" /></td>'}}else{html+='<td></td>'}}

7
public/static/js/admin/index.js

@ -12,8 +12,11 @@ $('#upgrade_error').html('').hide();var versionFile=obj.attr('data-version-file'
ajaxOpen({type:'get',dataType:'json',url:ulink('upgrade/download?version_file=_vfile_',{'_vfile_':versionFile}),success:function(data){obj.attr('upgrading',1);if(versionFile=='zip'){if(data.code==1){data=data.data?data.data:{};var size=toInt(data.size);size=size/(1024*1024);size=Math.floor(size*100)/100;obj.html('正在下载... &nbsp;<span class="size">0MB</span> / '+size+'MB');var upgradeZipClass=new UpgradeZipClass(data.size,data.blocks);upgradeZipClass.down_zip(1)}else{obj.html(data.msg?data.msg:'压缩包下载失败')}}else{if(data.code==1){var fileList=new Array();if(data.data.files){for(var i in data.data.files){fileList.push(data.data.files[i])}}
if(fileList.length>0){obj.html('正在更新...');var upgradeClass=new UpgradeClass(fileList);upgradeClass.down_file(0)}else{obj.html('没有需要更新的文件')}}else{var upgradeClass=new UpgradeClass(null);upgradeClass.down_complete()}}}});return!1});$('#refresh_admin_index').bind('click',function(){$('#skycaiji_admin_index').parents('.box').eq(0).find('.overlay').show();ajaxOpen({type:'get',dataType:'json',async:!0,timeout:10000,url:ulink('backstage/adminIndex?refresh=1'),success:function(data){var html=data.html?data.html:'';$('#skycaiji_admin_index').html(html);$('#skycaiji_admin_index').parents('.box').eq(0).find('.overlay').hide()},error:function(){var times=$('#refresh_admin_index').attr('data-times');times=toInt(times);if(times<3){$('#refresh_admin_index').attr('data-times',times+1).trigger('click')}}})});$('#box_open_basedir .close').bind('click',function(){confirmRight('忽略该问题?',function(){ajaxOpen({type:'get',dataType:'json',url:ulink('backstage/ignoreOpenBasedir'),success:function(data){$('#box_open_basedir').remove()}})})});$('#upgrade_check').html('正在检测更新...');ajaxOpen({type:'get',dataType:'json',async:!0,timeout:10000,url:ulink('backstage/newVersion'),success:function(data){data=data.data;if(data){if(data.is_new_version){var html='<a href="javascript:;" id="op_upgrade" data-version-file="'+(data.version_file?data.version_file:'')+'">检测到新版本V'+data.new_version+'点击升级</a>';if(data.version_link){html+=' &nbsp;<a href="'+data.version_link[1]+'" target="_blank" style="color:red;">'+data.version_link[0]+'</a>'}
$('#upgrade_check').html(html)}else{$('#upgrade_check').html('暂无更新')}
if(data.is_new_admin_index){$('#refresh_admin_index').trigger('click')}}else{$('#upgrade_check').html('')}},error:function(){$('#upgrade_check').html('<a href="javascript:;" onclick="window.location.reload();">检测失败</a>')}});ajaxOpen({type:'get',dataType:'json',async:!0,timeout:60000,url:ulink('backstage/checkUp'),success:function(data){data=data.data;if(data){var list=[];if(data.phpInvalid){list.push('<a href="'+ulink('setting/caiji')+'" target="_blank">cli命令行</a>')}
if(data.phpCliVersion){$('#php_cli_version').show().find('span').html(data.phpCliVersion)}
if(data.is_new_admin_index){$('#refresh_admin_index').trigger('click')}}else{$('#upgrade_check').html('')}},error:function(){$('#upgrade_check').html('<a href="javascript:;" onclick="window.location.reload();">检测失败</a>')}});ajaxOpen({type:'get',dataType:'json',async:!0,timeout:60000,url:ulink('backstage/checkUp'),success:function(data){data=data.data;if(data){var list=[];if(data.cliPhpVersion){$('#cli_php_version').show().find('span').html(data.cliPhpVersion)}
if(data.swoolePhpVersion){$('#swoole_php_version').show().find('span').html(data.swoolePhpVersion)}
if(data.phpInvalid){list.push('<a href="'+ulink('setting/caiji')+'" target="_blank">cli命令行</a>')}
if(data.swooleInvalid){list.push('<a href="'+ulink('setting/caiji')+'" target="_blank">swoole服务</a>')}
if(data.swoolePhpInvalid){list.push('<a href="'+ulink('setting/caiji')+'" target="_blank">swoole快捷启动</a>')}
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}}})})}

2
public/static/js/admin/release.js

@ -9,7 +9,7 @@
*/
'use strict';function ReleaseClass(formid,releid){this.formid='#'+formid;this.releid=releid;this.curFocusResIpt=''}
ReleaseClass.prototype={constructor:ReleaseClass,init:function(){var $_o=this;$($_o.formid).bind('submit',function(){var module=$($_o.formid+' select[name="module"]').val();if(module=='diy'&&$_o.has_diy_editor()){var diyCode=editorCodeIfr('#diy_editor_ifr',{'get_value':1});if(diyCode){$($_o.formid+' [name="diy[code]"]').val(diyCode)}}
var settings=getFormAjaxSettings($(this));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)});$($_o.formid).find('[name="toapi[response][module]"]').bind('change',function(){var module=$(this).val();var resNames=['id','target','desc','error'];for(var i in resNames){var obj=$($_o.formid).find('[name="toapi[response]['+resNames[i]+']"]');var objPh=obj.attr('data-placeholder');if(!module){objPh+=',默认:'+resNames[i]}
var settings=getFormAjaxSettings($(this));settings.data={'_post_data_':settings.data};ajaxOpen(settings);return!1});$($_o.formid+' select[name="module"]').bind('change',function(){var module=$(this).val();$($_o.formid+' .rele-module').hide();$($_o.formid+' .rele-module[module="'+module+'"]').show()});$('#btn_import_release').bind('click',function(){windowModal('导入配置会覆盖当前任务的发布设置,且不可恢复',ulink('release/import'))});$('#rele_module_cms .btn-cms-detect').bind('click',function(){$_o.cms_detect()});$('#rele_module_cms .btn-cms-bind').bind('click',function(){$_o.cms_bind()});$('#rele_module_cms').on('change','select[name="cms[app]"]',function(){var cmsApp=$(this).val();$_o.cms_bind({cms:{app:cmsApp}})});$('#cms_list').on('click','li a',function(){var path=$(this).attr('path');if(path){$($_o.formid+' [name="cms[path]"]').val(path);$('#cms_tab a[href="#cms_tab_bind"]').tab('show');$_o.cms_bind()}});$('#rele_module_cms').on('change','select[name^="cms_app[param]"]',function(){var cusName=$(this).attr('name').replace('cms_app[param]','cms_app[custom]');if($(this).val()=='custom:'){$('input[name="'+cusName+'"]').show()}else{$('input[name="'+cusName+'"]').hide()}});$('#db_tab_config .dm-db-charset li span').bind('click',function(){var charset=$(this).attr('data-val');charset=charset?charset:'';$('#db_tab_config [name="db[charset]"]').val(charset)});$('#db_tab_config .btn-db-names').bind('click',function(){$_o.db_connect('db_names')});$('#db_tab_config .btn-db-connect').bind('click',function(){$_o.db_connect()});$('#rele_module_file').on('click','.btn-file-rand-path',function(){var randStr=$_o.rand_str(10);$($_o.formid+' [name="file[path]"]').val(randStr)});$('#rele_module_api').on('click','.btn-api-rand-url',function(){var randStr=$_o.rand_str(10);$($_o.formid+' [name="api[url]"]').val(randStr)});$('#diy_tab').on('click','[data-type]',function(){var type=$(this).attr('data-type');$($_o.formid+' [name="diy[type]"]').val(type);if(type=='code'&&$_o.has_diy_editor()){var diyCode=$($_o.formid+' [name="diy[code]"]').val();diyCode=diyCode?diyCode:'';editorCodeIfr('#diy_editor_ifr',{'set_value':diyCode})}});$('#toapi_tab').on('click','[data-module]',function(){var module=$(this).attr('data-module');$($_o.formid+' [name="toapi[module]"]').val(module)});$('#rele_module_toapi').on('change','[name="toapi[type]"]',function(){if($(this).val()=='post'){$('#rele_module_toapi .toapi-content-type').show()}else{$('#rele_module_toapi .toapi-content-type').hide()}});$('#rele_module_toapi').on('click','.toapi-add-param',function(){$_o.toapi_add_param(null,null)});$('#rele_module_toapi').on('click','.toapi-del-param',function(){$(this).parents('tr').eq(0).remove()});$('#rele_module_toapi').on('click','.toapi-txt-field a[data-val]',function(){insertAtCaret($(this).parents('.toapi-txt-field').eq(0).find('input:text').eq(0),$(this).attr('data-val'))});inputSelectCustom('#rele_module_toapi [name="toapi[charset]"]','toapi[charset_custom]');inputSelectCustom('#rele_module_toapi [name="toapi[encode]"]','toapi[encode_custom]');$('#rele_module_toapi').on('click','.toapi-add-header',function(){$_o.toapi_add_header(null,null)});$('#rele_module_toapi').on('click','.toapi-del-header',function(){$(this).parents('tr').eq(0).remove()});$('#toapi_url_field').bind('change',function(){var val=$(this).val();$(this).val('');insertAtCaret($('#rele_module_toapi [name="toapi[url]"]'),val)});$('#toapi_app_url_field').bind('change',function(){var val=$(this).val();$(this).val('');insertAtCaret($('#rele_module_toapi [name="toapi[app_url]"]'),val)});$($_o.formid).find('[name="toapi[response][module]"]').bind('change',function(){var module=$(this).val();var resNames=['id','target','desc','error'];for(var i in resNames){var obj=$($_o.formid).find('[name="toapi[response]['+resNames[i]+']"]');var objPh=obj.attr('data-placeholder');if(!module){objPh+=',默认:'+resNames[i]}
obj.attr('placeholder',objPh);$('#toapi_resp_module_help').find('[data-module]').hide();$('#toapi_resp_module_help').find('[data-module="'+module+'"]').show()}});$($_o.formid).find('input[name^="toapi[response]"]').bind('focus',function(){$_o.curFocusResIpt=$(this).attr('name')});$('#toapi_resp_module_help').find('[data-rule-sign]').bind('click',function(){var curName=$_o.curFocusResIpt?$_o.curFocusResIpt:'toapi[response][id]';var ruleSign=$(this).attr('data-rule-sign');if(ruleSign=='sign_wildcard'){ruleInsertSign.wildcard('[name="'+curName+'"]')}else if(ruleSign=='sign_match'){ruleInsertSign.match('[name="'+curName+'"]')}else if(ruleSign=='sign_group'){ruleInsertSign.match('[name="'+curName+'"]',{group:1})}});$('#btn_toapi_app').bind('click',function(){$('#toapi_app_params').html('<div class="loading" style="margin-bottom:20px;"></div>');ajaxOpen({type:'post',url:ulink("release/toapiApp"),data:{'task_id':$($_o.formid+' [name="task_id"]').val(),'app_url':$('#rele_module_toapi [name="toapi[app_url]"]').val()},success:function(data){$('#toapi_app_params').html('');if(dataIsJson(data)){ajaxDataMsg(data)}else{$('#toapi_app_params').html(data)}},error:function(){$('#toapi_app_params').html('')}})});$('#toapi_tab a[href="#toapi_tab_app"]').bind('click',function(){ajaxOpen({type:'get',url:ulink("release/toapiApp?task_id=_id_",{'_id_':$($_o.formid+' [name="task_id"]').val()}),success:function(data){if(dataIsJson(data)){ajaxDataMsg(data)}else{$('#toapi_app_params').html(data)}}})});$('#btn_rele_test').bind('click',function(){collectorWindow('测试','admin/release/test?id='+$_o.releid,null,{lg:1})})},load:function(data){var $_o=this;if(data.module){$($_o.formid+' select[name="module"]').val(data.module).trigger('change')}
if(data.config){if('cms'==data.module){$_o.cms_bind(data.config);$(document).ready(function(){$('#cms_tab a[href="#cms_tab_bind"]').tab('show')})}else if('db'==data.module){$_o.db_bind(data.config)}else if('file'==data.module){if(data.config.file){$($_o.formid+' [name="file[path]"]').val(data.config.file.path);$($_o.formid+' [name="file[type]"]').each(function(){if($(this).val()==data.config.file.type){$(this).prop('checked',!0)}});$($_o.formid+' [name="file[txt_implode]"]').val(data.config.file.txt_implode);if(data.config.file.hide_fields){for(var fi in data.config.file.hide_fields){$($_o.formid+' [name="file[hide_fields][]"][value="'+data.config.file.hide_fields[fi]+'"]').prop('checked',!0)}}}}else if('api'==data.module){if(data.config.api){$($_o.formid+' [name="api[url]"]').val(data.config.api.url);$($_o.formid+' [name="api[cache_time]"]').val(data.config.api.cache_time);if(data.config.api.hide_fields){for(var fi in data.config.api.hide_fields){$($_o.formid+' [name="api[hide_fields][]"][value="'+data.config.api.hide_fields[fi]+'"]').prop('checked',!0)}}}}else if('diy'==data.module){if(data.config.diy){$(document).ready(function(){$('#diy_tab a[href="#diy_tab_'+data.config.diy.type+'"]').tab('show').trigger('click');for(var i in data.config.diy){$($_o.formid+' [name="diy['+i+']"]').val(data.config.diy[i])}
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()}

14
public/static/js/admin/setting.js

@ -8,12 +8,14 @@
|--------------------------------------------------------------------------
*/
'use strict';function SettingClass(){this.caijiForm='#form_set';this.downImgForm='#form_set';this.downFileForm='#form_set';this.pageRenderForm='#form_set';this.transForm='#form_set';this.siteForm='#form_set';this.emailForm='#form_set';this.storeForm='#form_set'}
SettingClass.prototype={constructor:SettingClass,caiji_init:function(caijiConfig){var $_o=this;caijiConfig=caijiConfig?caijiConfig:{};$($_o.caijiForm+' [name="auto"]').bind('click',function(){if($(this).val()>0){$('#set_caiji_run').show()}else{$('#set_caiji_run').hide()}});$($_o.caijiForm+' [name="run"]').bind('change',function(){$('#set_caiji_run .help-block').hide();$('#set_caiji_run .run-'+$(this).val()).show()});$($_o.caijiForm+' [name="server"]').bind('change',function(){$('#set_caiji_server .server-').hide();$('#set_caiji_server .server-cli').hide();$('#set_caiji_server .server-'+$(this).val()).show()});$('#btn_test_php').bind('click',function(){ajax_check_userpwd({type:'POST',dataType:'json',url:ulink('setting/test_php'),data:{php:$($_o.caijiForm+' [name="server_php"]').val()},beforeSend:function(){$('#btn_test_php').text('测试中...').attr('disabled',!0)},success:function(data){if(data.code==1){toastr.success(data.msg)}else{toastr.error(data.msg)}},complete:function(){$('#btn_test_php').text('测试').removeAttr('disabled')}})});$($_o.caijiForm).bind('submit',function(){var formObj=$(this);var settings=getFormAjaxSettings(formObj);settings.complete=function(){formObj.find('button[type="submit"]').removeAttr('disabled')};ajax_check_userpwd(settings);return!1});$($_o.caijiForm+' [name="robots"][value="'+toInt(caijiConfig.robots)+'"]').prop('checked',!0);$($_o.caijiForm+' [name="auto"][value="'+toInt(caijiConfig.auto)+'"]').trigger("click");$($_o.caijiForm+' [name="run"]').val(caijiConfig.run?caijiConfig.run:'backstage').trigger("change");$($_o.caijiForm+' [name="server"]').val(caijiConfig.server).trigger("change");$($_o.caijiForm+' [name="ip_resolve"]').val(caijiConfig.ip_resolve);$($_o.caijiForm+' [name="same_url"][value="'+toInt(caijiConfig.same_url)+'"]').prop('checked',!0);$($_o.caijiForm+' [name="same_title"][value="'+toInt(caijiConfig.same_title)+'"]').prop('checked',!0);$($_o.caijiForm+' [name="real_time"][value="'+toInt(caijiConfig.real_time)+'"]').prop('checked',!0);if(caijiConfig.ip_resolve||toInt(caijiConfig.max_redirs)>0){showPanelCollapse('#panel_others')}},down_img_init:function(imgConfig){var $_o=this;imgConfig=imgConfig?imgConfig:{};$($_o.downImgForm+' [name="download_img"]').bind('click',function(){if($(this).val()==1){$('.content-wrapper').removeClass('wrapper-not-enable')}else{$('.content-wrapper').addClass('wrapper-not-enable')}});$($_o.downImgForm+' [name="img_name"]').bind('change',function(){if($(this).val()=='custom'){$('#img_name_custom').show()}else{$('#img_name_custom').hide()}});inputSelectCustom($_o.downImgForm+' [name="charset"]','charset_custom');$($_o.downImgForm+' .dropup-img-params .dropdown-menu a').bind('click',function(){var val=$(this).attr('data-val');if(val){var obj=$($_o.downImgForm).find('[name="img_func_param"]');var objVal=obj.val();objVal=objVal?(objVal+"\r\n"):'';obj.val(objVal+val)}});$($_o.downImgForm).on('click','.name-custom-path a[data-val]',function(){insertAtCaret($('[name="name_custom_path"]'),$(this).attr('data-val'))});for(var i in imgConfig){var ele=$($_o.downImgForm).find('[name="'+i+'"]').eq(0);if(!ele.is('input:radio')){ele.val(imgConfig[i])}}
if(imgConfig.img_func){showPanelCollapse('#panel_img_func')}
$($_o.downImgForm+' [name="download_img"][value="'+toInt(imgConfig.download_img)+'"]').trigger("click");$($_o.downImgForm+' [name="data_image"][value="'+toInt(imgConfig.data_image)+'"]').trigger("click");$($_o.downImgForm+' [name="img_name"]').trigger("change");$($_o.downImgForm+' [name="charset"]').trigger("change");$($_o.downImgForm+' [name="img_watermark"][value="'+toInt(imgConfig.img_watermark)+'"]').trigger("click");if(imgConfig.img_wm_logo){$('#img_wm_logo_show').attr('src',window.site_config.root+imgConfig.img_wm_logo+'?'+(new Date().getTime())).show()}
loadPluginFunc({module:'downloadImg',boxObj:$_o.downImgForm,funcObj:'[name="img_func"]',paramObj:'[name="img_func_param"]',funcVal:imgConfig.img_func})},down_file_init:function(fileConfig){var $_o=this;fileConfig=fileConfig?fileConfig:{};$($_o.downFileForm+' [name="download_file"]').bind('click',function(){if($(this).val()==1){$('.content-wrapper').removeClass('wrapper-not-enable')}else{$('.content-wrapper').addClass('wrapper-not-enable')}});$($_o.downFileForm+' [name="file_name"]').bind('change',function(){if($(this).val()=='custom'){$('#file_name_custom').show()}else{$('#file_name_custom').hide()}});inputSelectCustom($_o.downFileForm+' [name="charset"]','charset_custom');$($_o.downFileForm+' .dropup-file-params .dropdown-menu a').bind('click',function(){var val=$(this).attr('data-val');if(val){var obj=$($_o.downFileForm).find('[name="file_func_param"]');var objVal=obj.val();objVal=objVal?(objVal+"\r\n"):'';obj.val(objVal+val)}});$($_o.downFileForm).on('click','.name-custom-path a[data-val]',function(){insertAtCaret($('[name="name_custom_path"]'),$(this).attr('data-val'))});for(var i in fileConfig){var ele=$($_o.downFileForm).find('[name="'+i+'"]').eq(0);if(!ele.is('input:radio')){ele.val(fileConfig[i])}}
if(fileConfig.file_func){showPanelCollapse('#panel_file_func')}
$($_o.downFileForm+' [name="download_file"][value="'+toInt(fileConfig.download_file)+'"]').trigger("click");$($_o.downFileForm+' [name="file_name"]').trigger("change");$($_o.downFileForm+' [name="charset"]').trigger("change");loadPluginFunc({module:'downloadFile',boxObj:$_o.downFileForm,funcObj:'[name="file_func"]',paramObj:'[name="file_func_param"]',funcVal:fileConfig.file_func})},page_render_init:function(renderConfig){var $_o=this;renderConfig=renderConfig?renderConfig:{};$($_o.pageRenderForm+' [name="tool"]').bind('change',function(){var tool=$(this).val();$('[id^="render_tool_"]').hide();if(tool){$('#render_tool_'+tool).show()}});$('#btn_chrome_test').bind('click',function(){ajax_check_userpwd({type:'POST',dataType:'json',url:ulink('setting/chrome_test'),data:$($_o.pageRenderForm).serialize(),beforeSend:function(){$('#btn_chrome_test').text('测试中...').attr('disabled',!0)},success:function(data){if(data.code==1){toastr.success(data.msg)}else{var warning=!1;if(data.msg.indexOf(':WARNING')>-1){warning=!0;if(data.msg.indexOf(':ERROR')>-1){warning=!1}}
SettingClass.prototype={constructor:SettingClass,caiji_init:function(caijiConfig){var $_o=this;caijiConfig=caijiConfig?caijiConfig:{};$($_o.caijiForm+' [name="auto"]').bind('click',function(){if($(this).val()>0){$('#set_caiji_run').show()}else{$('#set_caiji_run').hide()}});$($_o.caijiForm+' [name="run"]').bind('change',function(){$('#set_caiji_run .help-block').hide();$('#set_caiji_run .run-'+$(this).val()).show()});$($_o.caijiForm+' [name="server"]').bind('change',function(){var srvVal=$(this).val();srvVal=srvVal?srvVal:'';$('#set_caiji_server [data-server]').hide();$('#set_caiji_server [data-server="'+srvVal+'"]').show()});$('#btn_test_php').bind('click',function(){ajax_check_userpwd({type:'POST',dataType:'json',url:ulink('setting/test_php'),data:{php:$($_o.caijiForm+' [name="server_php"]').val()},beforeSend:function(){$('#btn_test_php').text('测试中...').attr('disabled',!0)},success:function(data){if(data.code==1){toastr.success(data.msg)}else{toastr.error(data.msg)}},complete:function(){$('#btn_test_php').text('测试').removeAttr('disabled')}})});$('#btn_test_swoole_php').bind('click',function(){ajax_check_userpwd({type:'POST',dataType:'json',url:ulink('setting/test_swoole_php'),data:{php:$($_o.caijiForm+' [name="swoole_php"]').val()},beforeSend:function(){$('#btn_test_swoole_php').text('测试中...').attr('disabled',!0)},success:function(data){if(data.code==1){toastr.success(data.msg)}else{toastr.error(data.msg)}},complete:function(){$('#btn_test_swoole_php').text('测试').removeAttr('disabled')}})});$('#test_swoole_restart button').bind('click',function(){ajax_check_userpwd({type:'POST',dataType:'json',url:ulink('setting/restart_swoole'),beforeSend:function(){$('#test_swoole_restart button').text('重启中...').attr('disabled',!0)},success:function(data){ajaxDataMsg(data)},complete:function(){$('#test_swoole_restart button').text('重启').removeAttr('disabled')}})});$($_o.caijiForm).bind('submit',function(){var formObj=$(this);var settings=getFormAjaxSettings(formObj);settings.complete=function(){formObj.find('button[type="submit"]').removeAttr('disabled')};ajax_check_userpwd(settings);return!1});for(var i in caijiConfig){var obj=$($_o.caijiForm+' [name="'+i+'"]');if(!obj.is('input:radio')){obj.val(caijiConfig[i])}}
$($_o.caijiForm+' [name="robots"][value="'+toInt(caijiConfig.robots)+'"]').prop('checked',!0);$($_o.caijiForm+' [name="auto"][value="'+toInt(caijiConfig.auto)+'"]').trigger("click");$($_o.caijiForm+' [name="run"]').val(caijiConfig.run?caijiConfig.run:'backstage').trigger("change");$($_o.caijiForm+' [name="server"]').trigger("change");$($_o.caijiForm+' [name="same_url"][value="'+toInt(caijiConfig.same_url)+'"]').prop('checked',!0);$($_o.caijiForm+' [name="same_title"][value="'+toInt(caijiConfig.same_title)+'"]').prop('checked',!0);$($_o.caijiForm+' [name="real_time"][value="'+toInt(caijiConfig.real_time)+'"]').prop('checked',!0);if(caijiConfig.server=='swoole'){$('#test_swoole_restart').show()}
if(caijiConfig.ip_resolve||toInt(caijiConfig.max_redirs)>0){showPanelCollapse('#panel_others')}
ajaxOpen({dataType:'json',url:ulink('setting/caiji_check'),async:!0,success:function(data){data=data.data?data.data:{};if(data.error){if(data.server=='cli'){$('#error_server_php').html(data.error).show()}else if(data.server=='swoole'){$('#error_server_swoole').html(data.error).show()}}}})},down_img_init:function(imgConfig){var $_o=this;imgConfig=imgConfig?imgConfig:{};$($_o.downImgForm+' [name="download_img"]').bind('click',function(){if($(this).val()==1){$('.content-wrapper').removeClass('wrapper-not-enable')}else{$('.content-wrapper').addClass('wrapper-not-enable')}});$($_o.downImgForm+' [name="img_name"]').bind('change',function(){if($(this).val()=='custom'){$('#img_name_custom').show()}else{$('#img_name_custom').hide()}});inputSelectCustom($_o.downImgForm+' [name="charset"]','charset_custom');$($_o.downImgForm).on('click','.name-custom-path a[data-val]',function(){insertAtCaret($('[name="name_custom_path"]'),$(this).attr('data-val'))});$($_o.downImgForm+' #add_img_func').bind('click',function(){$_o.add_img_func(null)});pluginFuncOp.initHtml($_o.downImgForm+' #img_funcs');for(var i in imgConfig){var ele=$($_o.downImgForm).find('[name="'+i+'"]').eq(0);if(ele.length>0&&!ele.is('input:radio')){ele.val(imgConfig[i])}}
if(imgConfig.img_funcs){for(var i in imgConfig.img_funcs){$_o.add_img_func(imgConfig.img_funcs[i])}}
$($_o.downImgForm+' [name="download_img"][value="'+toInt(imgConfig.download_img)+'"]').trigger("click");$($_o.downImgForm+' [name="data_image"][value="'+toInt(imgConfig.data_image)+'"]').trigger("click");$($_o.downImgForm+' [name="img_name"]').trigger("change");$($_o.downImgForm+' [name="charset"]').trigger("change");$($_o.downImgForm+' [name="img_watermark"][value="'+toInt(imgConfig.img_watermark)+'"]').trigger("click");if(imgConfig.img_wm_logo){$('#img_wm_logo_show').attr('src',window.site_config.root+imgConfig.img_wm_logo+'?'+(new Date().getTime())).show()}},add_img_func:function(funcData){var $_o=this;pluginFuncOp.addHtml({funcData:funcData,funcName:'img_funcs[{id}][func]',funcParamName:'img_funcs[{id}][func_param]',tplId:'img_tpl_func',listId:'img_funcs',funcId:'img_func_{id}'},{module:'downloadImg',boxObj:$_o.downImgForm})},down_file_init:function(fileConfig){var $_o=this;fileConfig=fileConfig?fileConfig:{};$($_o.downFileForm+' [name="download_file"]').bind('click',function(){if($(this).val()==1){$('.content-wrapper').removeClass('wrapper-not-enable')}else{$('.content-wrapper').addClass('wrapper-not-enable')}});$($_o.downFileForm+' [name="file_name"]').bind('change',function(){if($(this).val()=='custom'){$('#file_name_custom').show()}else{$('#file_name_custom').hide()}});inputSelectCustom($_o.downFileForm+' [name="charset"]','charset_custom');$($_o.downFileForm).on('click','.name-custom-path a[data-val]',function(){insertAtCaret($('[name="name_custom_path"]'),$(this).attr('data-val'))});$($_o.downFileForm+' #add_file_func').bind('click',function(){$_o.add_file_func(null)});pluginFuncOp.initHtml($_o.downFileForm+' #file_funcs');for(var i in fileConfig){var ele=$($_o.downFileForm).find('[name="'+i+'"]').eq(0);if(ele.length>0&&!ele.is('input:radio')){ele.val(fileConfig[i])}}
if(fileConfig.file_funcs){for(var i in fileConfig.file_funcs){$_o.add_file_func(fileConfig.file_funcs[i])}}
$($_o.downFileForm+' [name="download_file"][value="'+toInt(fileConfig.download_file)+'"]').trigger("click");$($_o.downFileForm+' [name="file_name"]').trigger("change");$($_o.downFileForm+' [name="charset"]').trigger("change")},add_file_func:function(funcData){var $_o=this;pluginFuncOp.addHtml({funcData:funcData,funcName:'file_funcs[{id}][func]',funcParamName:'file_funcs[{id}][func_param]',tplId:'file_tpl_func',listId:'file_funcs',funcId:'file_func_{id}'},{module:'downloadFile',boxObj:$_o.downFileForm})},page_render_init:function(renderConfig){var $_o=this;renderConfig=renderConfig?renderConfig:{};$($_o.pageRenderForm+' [name="tool"]').bind('change',function(){var tool=$(this).val();$('[id^="render_tool_"]').hide();if(tool){$('#render_tool_'+tool).show()}});$('#btn_chrome_test').bind('click',function(){ajax_check_userpwd({type:'POST',dataType:'json',url:ulink('setting/chrome_test'),data:$($_o.pageRenderForm).serialize(),beforeSend:function(){$('#btn_chrome_test').text('测试中...').attr('disabled',!0)},success:function(data){if(data.code==1){toastr.success(data.msg)}else{var warning=!1;if(data.msg.indexOf(':WARNING')>-1){warning=!0;if(data.msg.indexOf(':ERROR')>-1){warning=!1}}
if(warning){toastr.warning(data.msg)}else{toastr.error(data.msg)}}},complete:function(){$('#btn_chrome_test').text('测试').removeAttr('disabled')}})});$($_o.pageRenderForm).bind('submit',function(){var formObj=$(this);var settings=getFormAjaxSettings(formObj);settings.complete=function(){formObj.find('button[type="submit"]').removeAttr('disabled')};ajax_check_userpwd(settings);return!1});$('#btn_chrome_clean').bind('click',function(){confirmRight('确定清理?',function(){windowModal('正在清理...',ulink('setting/chrome_clean'))})});$('#btn_chrome_restart').bind('click',function(){confirmRight('确定重启?',function(){windowModal('正在重启...',ulink('setting/chrome_restart'))})});$($_o.pageRenderForm+' [name="tool"]').val(renderConfig.tool).trigger('change')},translate_init:function(transConfig){var $_o=this;transConfig=transConfig?transConfig:{};$($_o.transForm+' [name="open"]').bind('click',function(){if($(this).val()==1){$('.content-wrapper').removeClass('wrapper-not-enable')}else{$('.content-wrapper').addClass('wrapper-not-enable')}});$($_o.transForm+' [name="api"]').bind('change',function(){$('[id^="api_"]').hide();$('#api_'+$(this).val()).show()});$($_o.transForm+' [name="open"][value="'+toInt(transConfig.open)+'"]').trigger('click');$($_o.transForm+' [name="api"]').val(transConfig.api).trigger("change");$($_o.transForm+' [name="pass_html"][value="'+toInt(transConfig.pass_html)+'"]').trigger('click')},site_init:function(siteConfig){var $_o=this;siteConfig=siteConfig?siteConfig:{};siteConfig.login=siteConfig.login?siteConfig.login:{};$($_o.siteForm+' [name="verifycode"]').bind('click',function(){if($(this).val()==1){$('#verifycode_len').show()}else{$('#verifycode_len').hide()}});$($_o.siteForm+' [name="login[limit]"]').bind('click',function(){if($(this).val()==1){$('#login_limit').show()}else{$('#login_limit').hide()}});$($_o.siteForm+' #btn_timezone').bind('click',function(){var nowTime=new Date();var offset=nowTime.getTimezoneOffset()/60;ajaxOpen({type:'post',url:ulink("setting/site_timezone"),data:{time:nowTime.getTime(),offset:offset},dataType:'json',success:function(data){if(data.code==1){if(data.data&&data.data.timezone){if($($_o.siteForm+' [name="timezone"]').find('option[value="'+data.data.timezone+'"]').length>0){$($_o.siteForm+' [name="timezone"]').val(data.data.timezone)}else{toastr.error('自动调整失败,请手动选择!')}}}else{if(data.msg){toastr.error(data.msg)}}}})});$($_o.siteForm+' [name="verifycode"][value="'+toInt(siteConfig.verifycode)+'"]').prop('checked','checked').trigger('click');$($_o.siteForm+' [name="hidehome"][value="'+toInt(siteConfig.hidehome)+'"]').prop('checked','checked');$($_o.siteForm+' [name="closelog"][value="'+toInt(siteConfig.closelog)+'"]').prop('checked','checked');$($_o.siteForm+' [name="dblong"][value="'+toInt(siteConfig.dblong)+'"]').prop('checked','checked');$($_o.siteForm+' [name="login[limit]"][value="'+toInt(siteConfig.login.limit)+'"]').prop('checked','checked').trigger('click');$($_o.siteForm+' [name="closetrans"][value="'+toInt(siteConfig.closetrans)+'"]').prop('checked','checked');$($_o.siteForm+' [name="timezone"]').val(siteConfig.timezone)},email_init:function(emailConfig){var $_o=this;emailConfig=emailConfig?emailConfig:{};$('#btn_test').bind('click',function(){$($_o.emailForm+' [name="is_test"]').val(1);$($_o.emailForm).submit()});$($_o.emailForm+' button[type="submit"]').bind('click',function(){$($_o.emailForm+' [name="is_test"]').val(0)});$($_o.emailForm+' [name="type"][value="'+emailConfig.type+'"]').prop('checked','checked')},store_init:function(storeConfig){var $_o=this;storeConfig=storeConfig?storeConfig:{};$($_o.storeForm).bind('submit',function(){var obj=$(this);ajaxOpen({type:'post',url:obj.attr('action'),dataType:'json',data:obj.serialize(),success:function(data){if(data.code==1){ajaxDataMsg(data)}else{if(data.msg){toastr.error(data.msg)}
var data=data.data;if(data&&data.same_as_pwd){confirmRight(data.same_as_pwd,function(){obj.find('[name="same_as_pwd"]').val(1);obj.trigger('submit')})}}}});return!1});$('#provider_authkeys_iframe').bind('load',function(){var mainheight=$(this).contents().find('body').height()+1;$(this).height(mainheight)})}}
var settingClass=new SettingClass()

19
public/static/js/admin/task.js

@ -10,17 +10,18 @@
'use strict';var taskOpClass={import_rule:function(ruleId,ruleName){$('#form_item input[name="rule_id"]').val(ruleId);$('#btn_import_rule').text('导入规则:'+ruleName);if(ruleId=='file'){var settings=getFormAjaxSettings($('#form_item'));settings.url=ulink('task/import_rule_file');settings.beforeSend=null;settings.error=null;settings.success=function(data){data.url='';if(data.msg){ajaxDataMsg(data)}
$('#import_rule_file_plugins').hide().find('.plugins-info').html('');var dataData=data.data;if(isObject(dataData)){if(isObject(dataData.show_plugins)){var html='<input type="hidden" name="upload_addon[ignore_plugin]" value="1" />';for(var app in dataData.show_plugins){html+='<div class="checkbox"><label><input type="checkbox" name="upload_addon[plugins][]" value="'+app+'">'+dataData.show_plugins[app]+'</label></div>'}
$('#import_rule_file_plugins').show().find('.plugins-info').html(html)}}};ajaxOpen(settings)}else{$('#form_item [name="rule_file"]').val('')}
$('#myModal').modal('hide')},import_task:function(id,name){$('#form_item input[name="task_id"]').val(id);$('#btn_import_task').text('导入任务:'+name);$('#myModal').modal('hide')},task_init:function(){$('#form_item select[name="module"]').bind('change',function(){if($(this).val()!='pattern'){$('#btn_import_rule').parents('.input-group-btn').hide()}else{$('#btn_import_rule').parents('.input-group-btn').show()}});$('#form_item select[name="auto"]').bind('change',function(){var val=$(this).val();val=toInt(val);if(val==2){$('#config_task_timer').show()}else{$('#config_task_timer').hide()}});$('select[id^="task_timer_"]').bind('change',function(){var name=$(this).attr('data-name');if(name){var val=$(this).val();val=val?val.join(','):'';$('#form_item [name="'+name+'"]').val(val)}});$('#form_item [name="rule_file"]').bind('change',function(){taskOpClass.import_rule('file',$(this).val());$(this).parents('.dropdown').removeClass('open')});$('#form_item [name="config[proxy]"]').bind('click',function(){var open=!1;var val=$(this).val();if(val=='y'){open=!0}else if($(this).attr('data-global')){open=!0}
$('#myModal').modal('hide')},import_task:function(id,name){$('#form_item input[name="task_id"]').val(id);$('#btn_import_task').text('导入任务:'+name);$('#myModal').modal('hide')},task_init:function(){$('#form_item select[name="module"]').bind('change',function(){if($(this).val()!='pattern'){$('#btn_import_rule').parents('.input-group-btn').hide()}else{$('#btn_import_rule').parents('.input-group-btn').show()}});$('#form_item select[name="auto"]').bind('change',function(){var val=$(this).val();val=toInt(val);if(val==2){$('#config_task_timer').show()}else{$('#config_task_timer').hide()}
if(val>0){$('#config_task_auto_tips').show()}else{$('#config_task_auto_tips').hide()}});$('select[id^="task_timer_"]').bind('change',function(){var name=$(this).attr('data-name');if(name){var val=$(this).val();val=val?val.join(','):'';$('#form_item [name="'+name+'"]').val(val)}});$('#form_item [name="rule_file"]').bind('change',function(){taskOpClass.import_rule('file',$(this).val());$(this).parents('.dropdown').removeClass('open')});$('#form_item [name="config[proxy]"]').bind('click',function(){var open=!1;var val=$(this).val();if(val=='y'){open=!0}else if($(this).attr('data-global')){open=!0}
if(open){$('#config_proxy').removeClass('box-not-enable')}else{$('#config_proxy').addClass('box-not-enable')}});var downFunc=function(isImg){var type=isImg?'img':'file';$('#form_item [name="config[download_'+type+']"]').bind('click',function(){var open=!1;var val=$(this).val();if(val=='y'){open=!0}else if($(this).attr('data-global')){open=!0}
if(open){$('#config_download_'+type).removeClass('box-not-enable')}else{$('#config_download_'+type).addClass('box-not-enable')}});$('#form_item [name="config['+type+'_name]"]').bind('change',function(){var val=$(this).val();if(val=='custom'){$('#config_'+type+'_name_custom').show()}else{$('#config_'+type+'_name_custom').hide()}});var nameType=isImg?'name':'file';$('#config_'+type+'_name_custom').on('click','.'+nameType+'-custom-path a[data-val]',function(){insertAtCaret($('[name="config['+nameType+'_custom_path]"]'),$(this).attr('data-val'))});$('#config_'+type+'_name_custom').on('click','.'+nameType+'-custom-name a[data-val]',function(){insertAtCaret($('[name="config['+nameType+'_custom_name]"]'),$(this).attr('data-val'))});$('#form_item [name="config['+type+'_func]"]').bind('change',function(){var open=!1;var val=$(this).val();if(val){if(val!='n'){open=!0}}else{if($(this).attr('data-global')){open=!0}}
if(open){$('#config_'+type+'_func').show()}else{$('#config_'+type+'_func').hide()}});$('#form_item .dropup-'+type+'-params .dropdown-menu a').bind('click',function(){var val=$(this).attr('data-val');if(val){var obj=$('#form_item [name="config['+type+'_func_param]"]');var objVal=obj.val();objVal=objVal?(objVal+"\r\n"):'';obj.val(objVal+val)}})};downFunc(!0);downFunc(!1);$('#form_item [name="config[img_watermark]"]').bind('click',function(){var open=!1;var val=$(this).val();if(val=='y'){open=!0}else if($(this).attr('data-global')){open=!0}
if(open){$('#config_img_watermark').show()}else{$('#config_img_watermark').hide()}});$('#img_wm_logo_show a').bind('click',function(){var obj=$(this);confirmRight('删除后恢复使用全局设置logo,是否继续?',function(){$('#form_item [name="config[img_wm_logo]"]').val('');taskOpClass.show_img_wm_logo()})})},task_load:function(taskData,fieldList){taskOpClass.task_init();var imgFunc='';var fileFunc='';if(taskData){$('#form_item select[name="tg_id"]').val(toInt(taskData.tg_id));$('#form_item select[name="module"]').val(taskData.module);$('#form_item select[name="auto"]').val(toInt(taskData.auto)).trigger('change');var task_timer=taskData._task_timer;if(task_timer){var timerNames=['month','day','hour','minute'];for(var i in timerNames){var timerName=timerNames[i];var timerData=task_timer[timerName];if(!timerData||typeof(timerData)!='object'){timerData=[]}
if(open){$('#config_download_'+type).removeClass('box-not-enable')}else{$('#config_download_'+type).addClass('box-not-enable')}});$('#form_item [name="config['+type+'_name]"]').bind('change',function(){var val=$(this).val();if(val=='custom'){$('#config_'+type+'_name_custom').show()}else{$('#config_'+type+'_name_custom').hide()}});var nameType=isImg?'name':'file';$('#config_'+type+'_name_custom').on('click','.'+nameType+'-custom-path a[data-val]',function(){insertAtCaret($('[name="config['+nameType+'_custom_path]"]'),$(this).attr('data-val'))});$('#config_'+type+'_name_custom').on('click','.'+nameType+'-custom-name a[data-val]',function(){insertAtCaret($('[name="config['+nameType+'_custom_name]"]'),$(this).attr('data-val'))});$('#form_item [name="config['+type+'_funcs_open]"]').bind('click',function(){if($(this).val()=='n'){$('#config_'+type+'_funcs_open').hide()}else{$('#config_'+type+'_funcs_open').show()}});$('#form_item #add_config_'+type+'_func').bind('click',function(){if(isImg){taskOpClass.add_config_img_func(null)}else{taskOpClass.add_config_file_func(null)}});pluginFuncOp.initHtml('#config_'+type+'_funcs')};downFunc(!0);downFunc(!1);$('#form_item [name="config[img_watermark]"]').bind('click',function(){var open=!1;var val=$(this).val();if(val=='y'){open=!0}else if($(this).attr('data-global')){open=!0}
if(open){$('#config_img_watermark').show()}else{$('#config_img_watermark').hide()}});$('#img_wm_logo_show a').bind('click',function(){var obj=$(this);confirmRight('删除后恢复使用全局设置logo,是否继续?',function(){$('#form_item [name="config[img_wm_logo]"]').val('');taskOpClass.show_img_wm_logo()})})},task_load:function(taskData,fieldList){taskOpClass.task_init();$('#form_item').find('[name^="config"]').each(function(){if($(this).is('input:radio')){if(!$(this).val()){$(this).prop('checked','checked').trigger('click')}}else if($(this).is('select')){$(this).val('').trigger('change')}});if(taskData){$('#form_item select[name="tg_id"]').val(toInt(taskData.tg_id));$('#form_item select[name="module"]').val(taskData.module);$('#form_item select[name="auto"]').val(toInt(taskData.auto)).trigger('change');var task_timer=taskData._task_timer;if(task_timer){var timerNames=['month','day','hour','minute'];for(var i in timerNames){var timerName=timerNames[i];var timerData=task_timer[timerName];if(!timerData||typeof(timerData)!='object'){timerData=[]}
if(timerData.length>0){$('#form_item [name="task_timer['+timerName+']"]').val(timerData.join(','));for(var ii in timerData){$('#task_timer_'+timerName).find('option[value="'+timerData[ii]+'"]').prop('selected','selected')}}else{$('#task_timer_'+timerName).find('option[value=""]').prop('selected','selected')}}}
var task_config=taskData.config;var showConfig=!1;if(task_config){imgFunc=task_config.img_func;fileFunc=task_config.file_func;for(var i in task_config){if(task_config[i]){showConfig=!0;break}}
for(var i in task_config){var ele=$('#form_item').find('[name="config['+i+']"]').eq(0);var eleType=ele.attr('type');if(ele.is('input')&&eleType=='radio'){$('#form_item').find('[name="config['+i+']"][value="'+task_config[i]+'"]').prop('checked','checked')}else{ele.val(task_config[i])}}
$('#form_item [name="config[proxy]"][value="'+task_config.proxy+'"]').trigger('click');$('#form_item [name="config[download_img]"][value="'+task_config.download_img+'"]').trigger('click');$('#form_item [name="config[img_watermark]"][value="'+task_config.img_watermark+'"]').trigger('click');$('#form_item [name="config[img_name]"]').trigger('change');$('#form_item [name="config[img_func]"]').trigger('change');$('#form_item [name="config[download_file]"][value="'+task_config.download_file+'"]').trigger('click');$('#form_item [name="config[file_name]"]').trigger('change');$('#form_item [name="config[file_func]"]').trigger('change')}
var task_config=taskData.config;var showConfig=!1;if(task_config){for(var i in task_config){if((isObject(task_config[i])&&task_config[i].length>0)||(!isObject(task_config[i])&&task_config[i])){showConfig=!0;break}}
var imgFuncs=isObject(task_config.img_funcs)?task_config.img_funcs:[];var fileFuncs=isObject(task_config.file_funcs)?task_config.file_funcs:[];for(var i in task_config){var ele=$('#form_item').find('[name="config['+i+']"]').eq(0);if(ele.length>0){if(ele.is('input:radio')){$('#form_item').find('[name="config['+i+']"][value="'+task_config[i]+'"]').prop('checked','checked').trigger('click')}else{ele.val(task_config[i]);if(ele.is('select')){ele.trigger('change')}}}}
for(var i in imgFuncs){taskOpClass.add_config_img_func(imgFuncs[i])}
for(var i in fileFuncs){taskOpClass.add_config_file_func(fileFuncs[i])}}
if(taskData._show_config||showConfig){showPanelCollapse('#task_config')}
if(fieldList&&fieldList.length>0){$('#config_img_name_custom .name-custom-path-fields').html('');$('#config_img_name_custom .name-custom-name-fields').html('');$('#config_file_name_custom .file-custom-path-fields').html('');$('#config_file_name_custom .file-custom-name-fields').html('');for(var i in fieldList){var fieldHtml='[字段:'+fieldList[i]+']';fieldHtml='<li><a href="javascript:;" data-val="'+fieldHtml+'">'+fieldHtml+'</a></li>';$('#config_img_name_custom .name-custom-path-fields').append(fieldHtml);$('#config_img_name_custom .name-custom-name-fields').append(fieldHtml);$('#config_file_name_custom .file-custom-path-fields').append(fieldHtml);$('#config_file_name_custom .file-custom-name-fields').append(fieldHtml)}}}
taskOpClass.show_img_wm_logo();loadPluginFunc({module:'downloadImg',boxObj:'#form_item',funcObj:'[name="config[img_func]"]',funcVal:imgFunc,paramObj:'[name="config[img_func_param]"]'});loadPluginFunc({module:'downloadFile',boxObj:'#form_item',funcObj:'[name="config[file_func]"]',funcVal:fileFunc,paramObj:'[name="config[file_func_param]"]'})},show_img_wm_logo:function(){var isGlobal=!1;var imgWmLogo=$('#form_item [name="config[img_wm_logo]"]').val();if(!imgWmLogo){isGlobal=!0;imgWmLogo=$('#img_wm_logo_show').attr('data-global')}
taskOpClass.show_img_wm_logo()},show_img_wm_logo:function(){var isGlobal=!1;var imgWmLogo=$('#form_item [name="config[img_wm_logo]"]').val();if(!imgWmLogo){isGlobal=!0;imgWmLogo=$('#img_wm_logo_show').attr('data-global')}
$('#img_wm_logo_show').hide();var imgObj=$('#img_wm_logo_show img');imgObj.attr('src','');if(imgWmLogo){imgWmLogo=window.site_config.root+imgWmLogo;imgObj.attr('src',imgWmLogo+'?'+(new Date().getTime()));if(isGlobal){$('#img_wm_logo_show p.help-block').show();$('#img_wm_logo_show a.glyphicon-remove').hide()}else{$('#img_wm_logo_show p.help-block').hide();$('#img_wm_logo_show a.glyphicon-remove').show()}
$('#img_wm_logo_show').show()}}}
$('#img_wm_logo_show').show()}},add_config_img_func:function(funcData){pluginFuncOp.addHtml({funcData:funcData,funcName:'config[img_funcs][{id}][func]',funcParamName:'config[img_funcs][{id}][func_param]',tplId:'config_img_tpl_func',listId:'config_img_funcs',funcId:'config_img_func_{id}'},{module:'downloadImg',boxObj:'#form_item'})},add_config_file_func:function(funcData){pluginFuncOp.addHtml({funcData:funcData,funcName:'config[file_funcs][{id}][func]',funcParamName:'config[file_funcs][{id}][func_param]',tplId:'config_file_tpl_func',listId:'config_file_funcs',funcId:'config_file_func_{id}'},{module:'downloadFile',boxObj:'#form_item'})}}

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

File diff suppressed because one or more lines are too long

11
skycaiji

@ -1,11 +1,6 @@
#!/usr/bin/env php
<?php
// [ 应用入口文件 ]
define('SKYCAIJI_PATH', __DIR__.DIRECTORY_SEPARATOR);
// 定义应用目录
define('VENDOR_PATH', SKYCAIJI_PATH.'vendor'.DIRECTORY_SEPARATOR);
define('APP_PATH', VENDOR_PATH.'skycaiji'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR);
define('RUNTIME_PATH', SKYCAIJI_PATH.'runtime'.DIRECTORY_SEPARATOR);
define('APP_NAMESPACE', 'skycaiji');
// 加载框架引导文件
require VENDOR_PATH.'skycaiji'.DIRECTORY_SEPARATOR.'tp'.DIRECTORY_SEPARATOR.'console.php';
require __DIR__.DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'skycaiji'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'common'.DIRECTORY_SEPARATOR.'command'.DIRECTORY_SEPARATOR.'SkycaijiCli.php';
$_skycaijiCli=new \skycaiji\common\command\SkycaijiCli(__DIR__);
$_skycaijiCli->start();

4
vendor/skycaiji/app/admin/behavior/Init.php vendored

@ -37,6 +37,8 @@ class Init{
$s_userlogin=session('user_login');
}
$s_userlogin=is_array($s_userlogin)?$s_userlogin:array();
set_g_sc('user_login', $s_userlogin);
$s_userid=intval($s_userlogin['uid']);
$isAdmin=null;
@ -148,6 +150,8 @@ class Init{
session('usertoken',$usertoken);
}
set_g_sc('usertoken',$usertoken);
\util\Tools::close_session();
}
}

34
vendor/skycaiji/app/admin/command/Collect.php vendored

@ -29,44 +29,16 @@ class Collect extends Command{
protected function execute(Input $input, Output $output){
$cacheConfig=CacheModel::getInstance()->getCache('cli_cache_config','data');
if(is_array($cacheConfig)){
\think\Config::set($cacheConfig);
}
\util\Tools::cli_cache_config();
\util\Tools::set_url_compatible();
$op=$input->getArgument('op');
static $loginOps=array();
if(in_array($op, $loginOps)){
if ($input->hasOption('cli_user')){
$cliUser=$input->getOption('cli_user');
$cliUser=base64_decode($cliUser);
$cliUser=explode('_', $cliUser);
if(!empty($cliUser[0])){
$muser=new \skycaiji\admin\model\User();
$user=$muser->getByUid($cliUser[0]);
if(!empty($user)){
if($cliUser[1]==$muser->generate_key($user)){
$muser->setLoginSession($user);
}
}
}
}
$sUserlogin=session('user_login');
if(empty($sUserlogin)){
$this->error_msg('抱歉,必须传入账号信息!');
}
}
$rootUrl=\think\Config::get('root_website').'/index.php?s=';
\util\Tools::close_session();
if('auto_backstage'==$op){

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

@ -30,7 +30,7 @@ class Backstage extends BaseController{
$dbVersion=db()->query('SELECT VERSION() as v;');
$serverData['db'].=' '.($dbVersion[0]?$dbVersion[0]['v']:'');
}
$mconfig=model('Config');
$runInfo['auto_status']='良好';
/*设置采集状态*/
if(g_sc_c('caiji','auto')){
@ -56,7 +56,15 @@ class Backstage extends BaseController{
$runInfo['auto_status']='停止运行';
$serverData['caiji'].='<p class="help-block">自动采集已停止 <a href="javascript:;" id="a_run_auto_backstage">点击激活</a></p>';
}else{
$runInfo['auto_status']='<span style="font-size:16px;">'.(model('Config')->server_is_cli()?'cli':'web').'后台运行</span>';
$runInfo['auto_status']='<span style="font-size:16px;">';
if($mconfig->server_is_cli()){
$runInfo['auto_status'].='cli';
}elseif($mconfig->server_is_swoole()){
$runInfo['auto_status'].='swoole';
}else{
$runInfo['auto_status'].='web';
}
$runInfo['auto_status'].='后台运行</span>';
$runInfo['auto_status1']='<small>'.date('m-d H:i:s',$collectBackstageTime).'</small>';
}
}elseif(g_sc_c('caiji','run')=='visit'){
@ -75,7 +83,7 @@ class Backstage extends BaseController{
}
$upgradeDb=false;
if(version_compare(model('Config')->getVersion(),SKYCAIJI_VERSION,'<')){
if(version_compare($mconfig->getVersion(),SKYCAIJI_VERSION,'<')){
$upgradeDb=true;
}
@ -97,7 +105,7 @@ class Backstage extends BaseController{
}
}
if(model('Config')->server_is_cli()||g_sc_c('page_render','tool')){
if($mconfig->server_is_cli()){
$procFuncs=array('proc_open','proc_get_status','proc_terminate','proc_close');
foreach ($procFuncs as $procFunc){
@ -166,11 +174,12 @@ class Backstage extends BaseController{
public function checkUpAction(){
\util\Funcs::close_session();
$info=array(
'pageRenderInvalid'=>false,
'phpInvalid'=>false,
'swooleInvalid'=>false,
'swoolePhpInvalid'=>false,
'repairTables'=>'',
);
@ -188,16 +197,36 @@ class Backstage extends BaseController{
if($mconfig->server_is_cli()){
$phpvInfo=$mconfig->exec_php_version(g_sc_c('caiji','server_php'));
if(empty($phpvInfo)||(!$phpvInfo['success']&&$phpvInfo['msg'])){
$phpResult=$mconfig->php_is_valid(g_sc_c('caiji','server_php'));
if(empty($phpResult['success'])){
$info['phpInvalid']=true;
}
if($phpvInfo['msg']){
if($phpResult['ver']){
$info['cliPhpVersion']=$phpResult['ver'];
}
}elseif($mconfig->server_is_swoole()){
$ss=new \util\SwooleSocket(g_sc_c('caiji','swoole_host'),g_sc_c('caiji','swoole_port'));
if($ss->websocketError()){
$info['swooleInvalid']=true;
}else{
if(preg_match('/\bPHP\s+(?P<ver>\d+(\.\d+){1,})/i', $phpvInfo['msg'],$mphpv)){
$mphpv=$mphpv['ver'];
$info['phpCliVersion']=$mphpv;
$ssData=$ss->sendReceive('php_ver');
if($ssData['php_ver']){
$info['swoolePhpVersion']=$ssData['php_ver'];
}
}
if(empty($info['swoolePhpVersion'])&&$mconfig->server_is_swoole_php()){
$phpResult=$mconfig->php_is_valid(g_sc_c('caiji','swoole_php'));
if(empty($phpResult['success'])){
$info['swoolePhpInvalid']=true;
}
if($phpResult['ver']){
$info['swoolePhpVersion']=$phpResult['ver'];
}
}
}
@ -206,6 +235,7 @@ class Backstage extends BaseController{
if($mconfig->page_render_is_chrome()){
$pageRender=g_sc_c('page_render');
init_array($pageRender['chrome']);
$chromeSoket=new \util\ChromeSocket($pageRender['chrome']['host'],$pageRender['chrome']['port'],$pageRender['timeout'],$pageRender['chrome']['filename'],$pageRender['chrome']);
$info['pageRenderInvalid']=$chromeSoket->hostIsOpen()?false:true;
@ -282,7 +312,6 @@ class Backstage extends BaseController{
/*检测更新*/
public function newVersionAction(){
\util\Funcs::close_session();
$version=\util\Tools::curl_skycaiji('/client/info/version?v='.SKYCAIJI_VERSION);
$version=json_decode($version,true);
$version=is_array($version)?$version:array();
@ -313,7 +342,6 @@ class Backstage extends BaseController{
/*获取推送消息*/
public function adminIndexAction(){
\util\Funcs::close_session();
$refresh=input('refresh');
$data=cache('backstage_admin_index');
$data=is_array($data)?$data:array();
@ -541,4 +569,30 @@ class Backstage extends BaseController{
}
print_r ( $repeatList );
}
public function admincpAction(){
if($this->request->isPost()){
$op=input('op');
$val=input('val');
$mconfig=model('Config');
$config=$mconfig->getConfig('admincp','data');
init_array($config);
if($op=='mini'||$op=='narrow'){
$config[$op]=intval($val);
}elseif($op=='skin'){
if(preg_match('/^[\w\-\_]+$/', $val)){
$config[$op]=$val;
}
}
$allowConfig=array('skin'=>'','mini'=>'','narrow'=>'');
foreach ($allowConfig as $k=>$v){
$allowConfig[$k]=isset($config[$k])?$config[$k]:'';
}
$mconfig->setConfig('admincp',$allowConfig);
$this->success();
}else{
$this->error();
}
}
}

1
vendor/skycaiji/app/admin/controller/CollectController.php vendored

@ -169,7 +169,6 @@ class CollectController extends \skycaiji\admin\controller\BaseController{
set_time_limit(0);
}
}
\util\Funcs::close_session();
if(empty($nowTime)){
$nowTime=time();
}

56
vendor/skycaiji/app/admin/controller/Collector.php vendored

@ -17,9 +17,13 @@ class Collector extends BaseController {
public function indexAction(){
return $this->fetch();
}
public function setAction(){
$taskId=input('task_id/d',0);
$taskId=input('task_id/d',0);
if(request()->isPost()){
\util\UnmaxPost::init_post_data('_post_data_');
$taskId=\util\UnmaxPost::val('task_id/d',0);
}
$mtask=model('Task');
$mcoll=model('Collector');
$taskData=$mtask->getById($taskId);
@ -35,19 +39,19 @@ class Collector extends BaseController {
}
$collData=$mcoll->where(array('task_id'=>$taskData['id'],'module'=>$taskData['module']))->find();
if(request()->isPost()){
$effective=input('effective');
$effectiveEdit=input('effective_edit');
$effective=\util\UnmaxPost::val('effective');
$effectiveEdit=\util\UnmaxPost::val('effective_edit');
if(empty($effective)){
$this->error(lang('coll_error_empty_effective'));
}
$name=trim(input('name'));
$module=trim(input('module'));
$name=trim(\util\UnmaxPost::val('name'));
$module=trim(\util\UnmaxPost::val('module'));
$module=strtolower($module);
if(!in_array($module,config('allow_coll_modules'))){
$this->error(lang('coll_error_invalid_module'));
}
$config=input('post.config/a',array(),'trim');
$config=\util\UnmaxPost::val('config/a',array(),'trim');
$config=\util\Funcs::array_array_map('trim',$config);
$acoll=controller('admin/C'.$module,'event');
@ -68,8 +72,11 @@ class Collector extends BaseController {
$mcoll->edit_by_id($collId,$newColl);
}
if($collId>0){
$tab_link=trim(input('tab_link'),'#');
$this->success(lang('op_success'),'collector/set?task_id='.$taskId.($tab_link?'&tab_link='.$tab_link:'').(input('?easymode')?'&easymode=1':''));
$tabLink=trim(\util\UnmaxPost::val('tab_link'),'#');
$tabLink=$tabLink?('&tab_link='.$tabLink):'';
$isEasymode=\util\UnmaxPost::val('easymode');
$isEasymode=$isEasymode?'&easymode=1':'';
$this->success(lang('op_success'),'collector/set?task_id='.$taskId.$tabLink.$isEasymode);
}else{
$this->error(lang('op_failed'));
}
@ -85,7 +92,7 @@ class Collector extends BaseController {
}
$htmlTagName=lang('coll_set').lang('separator').lang('task_module_'.$taskData['module']);
if(input('?easymode')){
if(input('easymode')){
$htmlTagName.=' <small><a href="'.url('collector/set?task_id='.$taskId).'" onclick="if(window.top){window.top.location.href=$(this).attr(\'href\');return false;}" title="切换普通模式">普通模式</a></small>';
}else{
$htmlTagName.=' <small><a href="'.url('cpattern/easymode?task_id='.$taskId).'" title="切换简单模式">简单模式</a></small>';
@ -477,6 +484,35 @@ class Collector extends BaseController {
}
}
public function echo_url_msgAction(){
$data=input('data','','trim');
$data=json_decode($data,true);
init_array($data['post']);
init_array($data['renderer']);
$urlWeb=array();
if(!empty($data['post'])){
$urlWeb['open']=1;
$urlWeb['form_names']=array_keys($data['post']);
$urlWeb['form_vals']=array_values($data['post']);
}
$renderer=$data['renderer'];
if(!empty($renderer)){
$renderer['open']='y';
}
$data=array(
'url_web'=>$urlWeb,
'renderer'=>$renderer
);
$this->set_html_tags('查看网址信息','查看网址信息');
$this->assign('data',$data);
return $this->fetch();
}
public function plugin_funcAction(){
$module=input('module');
if(empty($module)){

40
vendor/skycaiji/app/admin/controller/Cpattern.php vendored

@ -218,6 +218,8 @@ class Cpattern extends BaseController {
$field=array();
}
$field['time_format']=$field['time_format']?$field['time_format']:'[年]/[月]/[日] [时]:[分]';
$field['num_start']=isset($field['num_start'])?intval($field['num_start']):1;
$field['num_end']=isset($field['num_end'])?intval($field['num_end']):100;
$sortField=array();
@ -546,6 +548,9 @@ class Cpattern extends BaseController {
case 'xpath':if(empty($contentSign['xpath']))$this->error('xpath规则不能为空!');break;
case 'json':if(empty($contentSign['json']))$this->error('json提取规则不能为空!');break;
}
if(is_array($contentSign['funcs'])){
$contentSign['funcs']=array_values($contentSign['funcs']);
}
$this->success('',null,array('content_sign'=>$contentSign,'objid'=>$objid));
}else{
$objid=input('objid');
@ -643,14 +648,7 @@ class Cpattern extends BaseController {
$pageConfig=input('page_config/a',array(),'trim');
$mergeType=input('merge_type','');
$sourceIsUrl=input('source_is_url/d',0);
$mergeCsIdentity='';
if(strpos($mergeType,'content_sign:')===0){
$mergeCsIdentity=str_replace('content_sign:', '', $mergeType);
$mergeCsIdentity=cp_sign('match',$mergeCsIdentity);
}
$isPagination=input('is_pagination/d',0);
$pageType=input('page_type','','trim');
if($sourceIsUrl){
@ -664,6 +662,26 @@ class Cpattern extends BaseController {
}
}
$pnSigns=null;
if($isPagination){
if($pageType=='source_url'){
$pnSigns=array('name'=>'当前起始页 - 分页','signs'=>array('area'=>$this->_get_rule_signs($sourceConfig['pagination']['area']),'url'=>$mergeType=='area'?'':$this->_get_rule_signs($sourceConfig['pagination']['url_rule'])),'cur'=>true);
}elseif($pageType=='level_url'){
$pnSigns=array('name'=>'当前多级页 - 分页','signs'=>array('area'=>$this->_get_rule_signs($pageConfig['pagination']['area']),'url'=>$mergeType=='area'?'':$this->_get_rule_signs($pageConfig['pagination']['url_rule'])),'cur'=>true);
}elseif($pageType=='url'){
$pnSigns=array('name'=>'当前内容页 - 分页','signs'=>array('area'=>$this->_get_rule_signs($urlConfig['pagination']['area']),'url'=>$mergeType=='area'?'':$this->_get_rule_signs($urlConfig['pagination']['url_rule'])),'cur'=>true);
}
$mergeType='content_sign';
}
$mergeCsIdentity='';
if(strpos($mergeType,'content_sign:')===0){
$mergeCsIdentity=str_replace('content_sign:', '', $mergeType);
$mergeCsIdentity=cp_sign('match',$mergeCsIdentity);
}
$eCpattern=controller('admin/Cpattern','event');
$frontSigns=array();
@ -798,6 +816,12 @@ class Cpattern extends BaseController {
$allSigns=array();
if($isPagination&&$pnSigns){
$allSigns[]=$pnSigns;
}
foreach ($relationSigns as $k=>$v){
if($k=='_cur_'){
$allSigns[]=array('name'=>'当前关联页','signs'=>$v,'cur'=>true);

59
vendor/skycaiji/app/admin/controller/CpatternTest.php vendored

@ -35,7 +35,6 @@ class CpatternTest extends BaseController {
/*测试*/
private function _test_init($clearCache=true,$skipCollect=false){
set_time_limit(600);
\util\Funcs::close_session();
$coll_id=input('coll_id/d',0);
$collData=model('Collector')->where(array('id'=>$coll_id))->find();
if(empty($collData)){
@ -87,6 +86,8 @@ class CpatternTest extends BaseController {
'page_area_matches'=>$this->eCpattern->page_area_matches,
'page_url_matches'=>$this->eCpattern->page_url_matches,
'page_content_matches'=>$this->eCpattern->page_content_matches,
'pn_area_matches'=>$this->eCpattern->pn_area_matches,
'pn_url_matches'=>$this->eCpattern->pn_url_matches,
'cur_front_urls'=>$this->eCpattern->cur_front_urls,
$keyUseCookie=>\util\Param::get_gsc_use_cookie(),
$keyUseCookieImg=>\util\Param::get_gsc_use_cookie('img'),
@ -107,6 +108,13 @@ class CpatternTest extends BaseController {
$this->eCpattern->page_content_matches=$cacheFrontData['page_content_matches'];
}
if(is_array($cacheFrontData['pn_area_matches'])){
$this->eCpattern->pn_area_matches=$cacheFrontData['pn_area_matches'];
}
if(is_array($cacheFrontData['pn_url_matches'])){
$this->eCpattern->pn_url_matches=$cacheFrontData['pn_url_matches'];
}
if(is_array($cacheFrontData['cur_front_urls'])){
$this->eCpattern->cur_front_urls=$cacheFrontData['cur_front_urls'];
}
@ -264,6 +272,12 @@ class CpatternTest extends BaseController {
if(is_array($cacheParentData['page_content_matches'])){
$this->eCpattern->page_content_matches=$cacheParentData['page_content_matches'];
}
if(is_array($cacheParentData['pn_area_matches'])){
$this->eCpattern->pn_area_matches=$cacheParentData['pn_area_matches'];
}
if(is_array($cacheParentData['pn_url_matches'])){
$this->eCpattern->pn_url_matches=$cacheParentData['pn_url_matches'];
}
if(is_array($cacheParentData['cur_level_urls'])){
$curLevelUrls=$cacheParentData['cur_level_urls'];
@ -295,13 +309,28 @@ class CpatternTest extends BaseController {
'page_area_matches'=>$this->eCpattern->page_area_matches,
'page_url_matches'=>$this->eCpattern->page_url_matches,
'page_content_matches'=>$this->eCpattern->page_content_matches,
'cur_level_urls'=>$this->eCpattern->cur_level_urls,
'pn_area_matches'=>$this->eCpattern->pn_area_matches,
'pn_url_matches'=>$this->eCpattern->pn_url_matches,
'cur_level_urls'=>$this->eCpattern->cur_level_urls
);
cache($cacheKeyPre.$curLevel,$cachePageData,1200);
$urls=$levelData['urls'];
init_array($urls);
$urlMsgLinks=array();
foreach ($urls as $k=>$v){
$k=\util\Tools::echo_url_msg_link($v);
if($k){
$urlMsgLinks[$v]=$k;
}
}
$this->success('', null, array(
'sourceUrl'=>$source_url,
'urls' => $levelData['urls'],
'urlMsgLinks' => $urlMsgLinks,
'urlOpened'=>$this->_page_opened_tips('url'),
'levelName' => $levelData['levelName'],
'level' => $curLevel,
@ -1035,6 +1064,10 @@ class CpatternTest extends BaseController {
$this->success('以下是所有页面的内容标签',null,$data);
}else{
if(input('?signs_cur_all')&&$pageType=='url'){
$this->eCpattern->get_page_html($test_url, $pageType, $pageName);
}
$data=array();
$signs=$this->eCpattern->parent_page_signs($pageType,$pageName);
@ -1082,14 +1115,21 @@ class CpatternTest extends BaseController {
if(empty($pageType)){
$this->error('请选择页面类型');
}elseif(!in_array($pageType,array('source_url','level_url','url'))){
}elseif(!$this->eCpattern->page_has_pagination($pageType)){
$this->error('该页面类型不支持分页');
}
$pnType=input('pagination_type');
$pnUrls=null;
$pnUrlMsgLinks=array();
if(empty($pnType)){
$pnUrls=$this->eCpattern->getPaginationUrls($pageType,$pageName,false,$test_url,'',true);
foreach ($pnUrls as $k=>$v){
$k=\util\Tools::echo_url_msg_link($v);
if($k){
$pnUrlMsgLinks[$v]=$k;
}
}
}elseif($pnType=='next'){
$pnUrls=$this->eCpattern->getPaginationUrls($pageType,$pageName,false,$test_url,'',true);
@ -1117,6 +1157,17 @@ class CpatternTest extends BaseController {
$doWhile=false;
}
}while($doWhile);
foreach ($pnUrls as $k=>$v){
$msgLinkCur=\util\Tools::echo_url_msg_link($v['cur']);
if($msgLinkCur){
$pnUrlMsgLinks[$v['cur']]=$msgLinkCur;
}
$msgLinkNext=\util\Tools::echo_url_msg_link($v['next']);
if($msgLinkNext){
$pnUrlMsgLinks[$v['next']]=$msgLinkNext;
}
}
}
}
@ -1124,7 +1175,7 @@ class CpatternTest extends BaseController {
$this->error('没有抓取到分页链接');
}else{
$pnUrls=is_array($pnUrls)?$pnUrls:array();
$this->success('',null,array('pagination_type'=>$pnType,'urls'=>$pnUrls));
$this->success('',null,array('pagination_type'=>$pnType,'urls'=>$pnUrls,'pn_links'=>$pnUrlMsgLinks));
}
}elseif('get_relation_urls'==$testName){

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

@ -342,6 +342,15 @@ class Index extends CollectController{
if($mconfig->server_is_cli(true,$caijiConfig['server'])){
\util\Tools::cli_command_exec('collect auto_backstage');
}elseif($mconfig->server_is_swoole(true,$caijiConfig['server'])){
$ss=new \util\SwooleSocket($caijiConfig['swoole_host'],$caijiConfig['swoole_port']);
$ssError=$ss->websocketError();
if($ssError){
$this->error($ssError);
}else{
$ss->send('auto_backstage');
}
}else{
$curlCname='caiji_auto_curltime_'.$key;
@ -519,6 +528,17 @@ class Index extends CollectController{
}
\util\Tools::cli_command_exec('collect collect_process'.$urlParams);
exit();
}elseif(model('admin/Config')->server_is_swoole()){
$ss=new \util\SwooleSocket(g_sc_c('caiji','swoole_host'),g_sc_c('caiji','swoole_port'));
$ssError=$ss->websocketError();
if($ssError){
$this->echo_msg_exit($ssError);
}else{
$urlParams=input('param.','','trim');
$ss->send('collect_process',array('url_params'=>$urlParams));
}
exit();
}
}
@ -596,7 +616,7 @@ class Index extends CollectController{
}
private function _collect_check_key(){
if(is_empty(session('user_login'))){
if(is_empty(g_sc('user_login'))){
if(!\util\Param::exist_cache_key(input('key'))){
@ -622,9 +642,23 @@ class Index extends CollectController{
$timeout=intval($params[2]);
$timeout=max($timeout,15);
set_time_limit($timeout);
\util\Funcs::close_session();
$info=\util\Tools::proc_open_exec($params[0],$params[1],$params[2],$params[3],$params[4]);
}
return json($info);
}
public function swoole_serverAction(){
$key=input('key');
$ssKey=\util\Param::get_swoole_server_key();
if(empty($key)||$key!=$ssKey){
$this->error('密钥错误');
}
if(model('Config')->server_is_swoole_php()){
$ss=new \util\SwooleSocket(g_sc_c('caiji','swoole_host'),g_sc_c('caiji','swoole_port'));
\util\Tools::cli_command_exec($ss->cmdStr());
}else{
$this->error('未开启swoole快捷启动');
}
}
}

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

@ -18,6 +18,14 @@ class Release extends CollectController{
public function setAction(){
$taskId=input('task_id/d',0);
$releaseId=input('release_id/d',0);
if(request()->isPost()){
\util\UnmaxPost::init_post_data('_post_data_');
$taskId=\util\UnmaxPost::val('task_id/d',0);
$releaseId=\util\UnmaxPost::val('release_id/d',0);
}
$mtask=model('Task');
$mrele=model('Release');
$taskData=$mtask->getById($taskId);
@ -34,7 +42,7 @@ class Release extends CollectController{
$newData['config']=$importRele['config'];
}else{
$newData['module']=input('module','','strtolower');
$newData['module']=\util\UnmaxPost::val('module','','strtolower');
if(empty($newData['module'])){
$this->error(lang('rele_error_null_module'));
}

140
vendor/skycaiji/app/admin/controller/Setting.php vendored

@ -12,6 +12,7 @@
namespace skycaiji\admin\controller;
use skycaiji\admin\model\CacheModel;
use util\Funcs;
class Setting extends BaseController {
/*站点设置*/
@ -101,6 +102,9 @@ class Setting extends BaseController {
$config['run']=input('run');
$config['server']=input('server');
$config['server_php']=input('server_php');
$config['swoole_host']=input('swoole_host');
$config['swoole_port']=input('swoole_port');
$config['swoole_php']=input('swoole_php');
$config['process_num']=input('process_num/d',0);
$config['num']=input('num/d',0);
$config['interval']=input('interval/d',0);
@ -116,17 +120,30 @@ class Setting extends BaseController {
unset($config['download_img']);
if($mconfig->server_is_cli(true,$config['server'])){
if($mconfig->server_is_cli(true,$config['server'])||$mconfig->server_is_swoole(true,$config['server'])){
$this->ajax_check_userpwd();
if(!function_exists('proc_open')){
$this->error('抱歉cli命令行模式需开启proc_open函数');
if($mconfig->server_is_cli(true,$config['server'])){
$this->error('cli命令行模式需开启proc_open函数');
}elseif($mconfig->server_is_swoole_php(true,$config['server'],$config['swoole_php'])){
$this->error('swoole快捷启动需开启proc_open函数');
}
}
}
if(in_array($config['swoole_port'], array(80,8080,443))){
if($mconfig->server_is_swoole(true,$config['server'])){
$this->error('swoole端口号不能设置为'.$config['swoole_port']);
}else{
$config['swoole_port']='';
}
}
$mconfig->setConfig('caiji',$config);
$this->_run_auto_backstage();
$this->success(lang('op_success'),'setting/caiji');
@ -151,21 +168,56 @@ class Setting extends BaseController {
return $this->fetch();
}
public function caiji_checkAction(){
$data=array('server'=>g_sc_c('caiji','server'),'error'=>'');
$mconfig=model('Config');
if($mconfig->server_is_cli()){
$phpResult=$mconfig->php_is_valid(g_sc_c('caiji','server_php'));
if(empty($phpResult['success'])){
$data['error']='PHP可执行文件错误'.($phpResult['msg']?(':'.$phpResult['msg']):'');
}
}elseif($mconfig->server_is_swoole()){
$ss=new \util\SwooleSocket(g_sc_c('caiji','swoole_host'),g_sc_c('caiji','swoole_port'));
$error=$ss->websocketError();
if($error){
$data['error']=$error;
}
$phpResult=$ss->checkPhp(g_sc_c('caiji','server'),g_sc_c('caiji','swoole_php'),true,true);
if(!$phpResult['success']){
if($data['error']){
$data['error'].='<br>';
}
$data['error'].=$phpResult['msg'];
}
}
$this->success('','',$data);
}
public function _run_auto_backstage(){
$mconfig=model('Config');
$config=$mconfig->getConfig('page_render','data');
$this->_chrome_start($config,false,true);
$config=$mconfig->getConfig('caiji','data');
init_array($config);
if($config['auto']){
if($mconfig->server_is_swoole(true,$config['server'])){
$ss=new \util\SwooleSocket($config['swoole_host'],$config['swoole_port']);
$ss->startWs($config['server'], $config['swoole_php'],true);
if($ss->websocketError()){
$ss->startWs($config['server'], $config['swoole_php'],true);
}
}
if($config['auto']){
if($config['run']=='backstage'){
$bskey=\util\Param::set_auto_backstage_key();
@get_html(url('admin/index/auto_backstage?key='.$bskey,null,false,true),null,array('timeout'=>3));
@get_html(url('admin/index/auto_backstage?key='.$bskey,null,false,true),null,array('timeout'=>2));
}
}
$config=$mconfig->getConfig('page_render','data');
$this->_chrome_start($config);
}
/*图片本地化设置*/
public function download_imgAction(){
@ -190,8 +242,7 @@ class Setting extends BaseController {
$config['charset_custom']=input('charset_custom','');
$config['img_max']=input('img_max/d',0);
$config['img_func']=input('img_func','');
$config['img_func_param']=input('img_func_param','');
$config['img_funcs']=input('img_funcs/a',array());
$config['img_watermark']=input('img_watermark/d',0);
$config['img_wm_logo']=input('img_wm_logo','');
@ -262,6 +313,10 @@ class Setting extends BaseController {
$config['img_wm_logo']=$upResult['file_name'];
}
if(is_array($config['img_funcs'])){
$config['img_funcs']=array_values($config['img_funcs']);
}
$mconfig->setConfig('download_img',$config);
$this->success(lang('op_success'),'setting/download_img');
@ -300,6 +355,9 @@ class Setting extends BaseController {
}
}
$imgConfig=$mconfig->compatible_func_config($imgConfig,false);
$imgWmError='';
$LocSystem=new \skycaiji\install\event\LocSystem();
$LocSystem=$LocSystem->environmentPhp();
@ -333,9 +391,7 @@ class Setting extends BaseController {
$config['charset']=input('charset','');
$config['charset_custom']=input('charset_custom','');
$config['file_max']=input('file_max/d',0);
$config['file_func']=input('file_func','');
$config['file_func_param']=input('file_func_param','');
$config['file_funcs']=input('file_funcs/a',array());
@ -388,6 +444,9 @@ class Setting extends BaseController {
if($config['charset']=='custom'&&empty($config['charset_custom'])){
$this->error('请输入系统编码自定义内容');
}
if(is_array($config['file_funcs'])){
$config['file_funcs']=array_values($config['file_funcs']);
}
$mconfig->setConfig('download_file',$config);
@ -410,6 +469,8 @@ class Setting extends BaseController {
$fileConfig['retry']=0;
}
$fileConfig=$mconfig->compatible_func_config($fileConfig,true);
$this->assign('fileConfig',$fileConfig);
return $this->fetch('download_file');
}
@ -695,31 +756,48 @@ class Setting extends BaseController {
return $this->fetch();
}
}
/*测试php*/
public function test_phpAction(){
if(request()->isPost()){
$this->ajax_check_userpwd();
$phpFile=input('php','','trim');
$phpResult=model('Config')->php_is_valid($phpFile);
if($phpResult['success']){
$this->success($phpResult['msg']?$phpResult['msg']:'测试成功');
}else{
$this->error($phpResult['msg']?$phpResult['msg']:'测试失败');
}
}
$this->error('测试失败');
}
public function test_swoole_phpAction(){
if(request()->isPost()){
$this->ajax_check_userpwd();
$mconfig=model('Config');
$phpFile=input('php','','trim');
if(!function_exists('proc_open')){
$this->error('需开启proc_open函数');
$ss=new \util\SwooleSocket(g_sc_c('caiji','swoole_host'),g_sc_c('caiji','swoole_port'));
$phpResult=$ss->checkPhp('swoole',$phpFile,false,true);
if(!$phpResult['success']){
$this->error($phpResult['msg']?:'测试失败');
}else{
$phpFile=input('php','','trim');
$phpvInfo=model('Config')->exec_php_version($phpFile);
if($phpvInfo===false){
$this->error('未检测到PHP可执行文件,请手动输入');
}else{
if($phpvInfo['success']){
$this->success($phpvInfo['msg']?$phpvInfo['msg']:'测试成功');
}else{
$this->error($phpvInfo['msg']?$phpvInfo['msg']:'测试失败');
}
}
$this->success($phpResult['v']?:'测试成功');
}
}
$this->error('测试失败');
}
public function restart_swooleAction(){
if(request()->isPost()){
$this->ajax_check_userpwd();
$this->_run_auto_backstage();
$this->success('操作完成','setting/caiji');
}
$this->error('重启失败');
}
public function chrome_testAction(){
if(request()->isPost()){
$this->ajax_check_userpwd();
@ -765,9 +843,10 @@ class Setting extends BaseController {
$this->success('重启完成','setting/page_render');
}
private function _chrome_start($config,$restart=false){
private function _chrome_start($config,$restart=false,$noError=false){
init_array($config);
$chromeSocket=$this->_chrome_socket($config);
$error='';
if($chromeSocket){
try {
if($restart){
@ -781,9 +860,12 @@ class Setting extends BaseController {
}
}
}catch (\Exception $ex){
$this->error($ex->getMessage());
$error=$ex->getMessage();
}
}
if($error&&!$noError){
$this->error($error);
}
}
private function _chrome_socket($config){

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

@ -407,24 +407,6 @@ class Task extends CollectController {
$proxyGroupId=g_sc_c('proxy','group_id');
$proxyGroupId=intval($proxyGroupId);
$imgFuncParam=g_sc_c('download_img','img_func_param');
if($imgFuncParam){
$imgFuncParam=str_replace("\r", '\r', $imgFuncParam);
$imgFuncParam=str_replace("\n", '\n', $imgFuncParam);
$imgFuncParam=htmlspecialchars($imgFuncParam,ENT_QUOTES);
}else{
$imgFuncParam='';
}
$fileFuncParam=g_sc_c('download_file','file_func_param');
if($fileFuncParam){
$fileFuncParam=str_replace("\r", '\r', $fileFuncParam);
$fileFuncParam=str_replace("\n", '\n', $fileFuncParam);
$fileFuncParam=htmlspecialchars($fileFuncParam,ENT_QUOTES);
}else{
$fileFuncParam='';
}
$gConfig=array(
'num'=>intval(g_sc_c('caiji','num')),
'num_interval'=>intval(g_sc_c('caiji','interval')),
@ -449,9 +431,7 @@ class Task extends CollectController {
'img_wm_right'=>g_sc_c('download_img','img_wm_right')?g_sc_c('download_img','img_wm_right'):'0',
'img_wm_bottom'=>g_sc_c('download_img','img_wm_bottom')?g_sc_c('download_img','img_wm_bottom'):'0',
'img_wm_opacity'=>g_sc_c('download_img','img_wm_opacity')?g_sc_c('download_img','img_wm_opacity'):'不透明',
'img_func'=>g_sc_c('download_img','img_func'),
'img_func_param'=>$imgFuncParam,
'img_funcs'=>g_sc_c('download_img','img_funcs'),
'download_file'=>g_sc_c('download_file','download_file')>0?'1':'',
'file_path'=>g_sc_c('download_file','file_path')?g_sc_c('download_file','file_path'):(config('root_path').DS.'data'.DS.'files'),
@ -460,9 +440,12 @@ class Task extends CollectController {
'file_custom_path'=>g_sc_c('download_file','file_custom_path')?g_sc_c('download_file','file_custom_path'):'无',
'file_custom_name'=>lang('down_file_name_custom_name_'.g_sc_c('download_file','file_custom_name')),
'file_interval'=>intval(g_sc_c('download_file','file_interval')),
'file_func'=>g_sc_c('download_file','file_func'),
'file_func_param'=>$fileFuncParam,
'file_funcs'=>g_sc_c('download_file','file_funcs'),
);
init_array($gConfig['img_funcs']);
init_array($gConfig['file_funcs']);
$this->assign('gConfig',$gConfig);
$this->assign('tgSelect',$tgSelect);
$this->assign('proxyGroups',model('ProxyGroup')->getAll());
@ -623,6 +606,11 @@ class Task extends CollectController {
}
}
init_array($config['img_funcs']);
$config['img_funcs']=array_values($config['img_funcs']);
init_array($config['file_funcs']);
$config['file_funcs']=array_values($config['file_funcs']);
return $config;
}

25
vendor/skycaiji/app/admin/event/CollectBase.php vendored

@ -40,6 +40,31 @@ class CollectBase extends \skycaiji\admin\controller\CollectController {
}
}
public function echo_url_msg($strArgs,$url,$opened='',$color='black'){
init_array($strArgs);
if($opened){
$strArgs[0].=':%s';
$strArgs[]=$opened.$url;
}else{
$strArgs[0].=':<a href="%s" target="_blank">%s</a>';
$strArgs[]=$url;
$strArgs[]=$url;
}
if(!\util\Param::is_task_close_echo()){
$urlMsgLink=\util\Tools::echo_url_msg_link($url,true);
if($urlMsgLink&&is_array($urlMsgLink)){
$strArgs[0].=$urlMsgLink[0];
$strArgs[]=$urlMsgLink[1];
}
}
$this->echo_msg($strArgs,$color);
}
/*判断采集器正在执行中*/
public function is_collecting(){
return \util\Param::is_collector_collecting();

91
vendor/skycaiji/app/admin/event/Cpattern.php vendored

@ -93,10 +93,9 @@ class Cpattern extends CpatternEvent{
$config['field_process'][$k]=$this->set_process($config['field_process'][$k]);
}
}
$config['common_process']=trim_input_process('process/a');
$config['common_process']=\util\UnmaxPost::val('process/a',array(),null);
$config['common_process']=$this->set_process($config['common_process']);
if(is_array($config['level_urls'])){
foreach ($config['level_urls'] as $k=>$v){
@ -496,21 +495,36 @@ class Cpattern extends CpatternEvent{
if(!empty($config['new_front_urls'])){
foreach ($config['new_front_urls'] as $k=>$v){
$signs[$this->page_source_merge('front_url',$k)]=array(''=>$this->parent_page_signs('front_url', $k, ''));
$signs[$this->page_source_merge('front_url',$k)]=array(
''=>$this->parent_page_signs('front_url', $k, ''),
'pn:'=>$this->parent_page_signs('front_url', $k, 'pn:')
);
}
}
$signs['source_url']=array(''=>$this->parent_page_signs('source_url', '', ''));
$signs['source_url']=array(
''=>$this->parent_page_signs('source_url', '', ''),
'pn:'=>$this->parent_page_signs('source_url', '', 'pn:')
);
if(!empty($config['new_level_urls'])){
foreach ($config['new_level_urls'] as $k=>$v){
$signs[$this->page_source_merge('level_url',$k)]=array(''=>$this->parent_page_signs('level_url', $k, ''));
$signs[$this->page_source_merge('level_url',$k)]=array(
''=>$this->parent_page_signs('level_url', $k, ''),
'pn:'=>$this->parent_page_signs('level_url', $k, 'pn:')
);
}
}
$signs['url']=array(''=>$this->parent_page_signs('url', '', ''));
$signs['url']=array(
''=>$this->parent_page_signs('url', '', ''),
'pn:'=>$this->parent_page_signs('url', '', 'pn:')
);
if(!empty($config['new_relation_urls'])){
foreach ($config['new_relation_urls'] as $k=>$v){
$signs[$this->page_source_merge('relation_url',$k)]=array(''=>$this->parent_page_signs('relation_url', $k, ''));
$signs[$this->page_source_merge('relation_url',$k)]=array(
''=>$this->parent_page_signs('relation_url', $k, ''),
'pn:'=>$this->parent_page_signs('relation_url', $k, 'pn:')
);
}
}
$this->config_params['signs']=$signs;
@ -649,6 +663,7 @@ class Cpattern extends CpatternEvent{
$source_urls=$this->page_convert_url_signs('source_url', '', false, $source_urls, array(), false);
}
$pageOpened=$this->page_opened_tips('source_url');
$pnOpened=$this->page_opened_tips('source_url','',true);
foreach ($source_urls as $key_source_url=>$source_url){
$this->cur_source_url=$source_url;
if(array_key_exists($source_url,$this->used_source_urls)){
@ -682,7 +697,8 @@ class Cpattern extends CpatternEvent{
}
}
$this->used_pagination_urls['source_url'][$pageCurMd5]=1;
$this->echo_msg($pageOpened?array('采集起始页%s:%s',$pagePnStr,$pageOpened.$pageCurUrl):array('采集起始页%s:<a href="%s" target="_blank">%s</a>',$pagePnStr,$pageCurUrl,$pageCurUrl),$pageIsPn?'black':'green');
$this->echo_url_msg(array('采集起始页%s',$pagePnStr),$pageCurUrl,$pageIsPn?$pnOpened:$pageOpened,$pageIsPn?'black':'green');
if(!empty($this->config['level_urls'])){
@ -753,7 +769,7 @@ class Cpattern extends CpatternEvent{
}
if($frontUrl){
$pageOpened=$this->page_opened_tips('front_url',$fuv['name']);
$this->echo_msg($pageOpened?array('采集前置页“%s”:%s',$fuv['name'],$pageOpened.$frontUrl):array('采集前置页“%s”:<a href="%s" target="_blank">%s</a>',$fuv['name'],$frontUrl,$frontUrl),'black');
$this->echo_url_msg(array('采集前置页“%s”',$fuv['name']),$frontUrl,$pageOpened);
$htmlInfo=$this->get_page_html($frontUrl,'front_url',$fuv['name'],false,true);
if($fuv['use_cookie']||$fuv['use_cookie_img']||$fuv['use_cookie_file']){
@ -905,9 +921,21 @@ class Cpattern extends CpatternEvent{
/*获取分页链接*/
public function getPaginationUrls($pageType,$pageName,$isPagination,$fromUrl,$html,$isTest=false){
if(!isset($this->pn_area_matches[$pageType])){
$this->pn_area_matches[$pageType]=array();
}
if(!isset($this->pn_area_matches[$pageType][$pageName])){
$this->pn_area_matches[$pageType][$pageName]=array();
}
if(!isset($this->pn_url_matches[$pageType])){
$this->pn_url_matches[$pageType]=array();
}
if(!isset($this->pn_url_matches[$pageType][$pageName])){
$this->pn_url_matches[$pageType][$pageName]=array();
}
$pn_urls=array();
$pnConfig=$this->get_page_config($pageType,$pageName,'pagination');
if($pnConfig&&is_array($pnConfig)&&$pnConfig['open']){
if($this->pagination_is_open(null,null,$pnConfig)){
if(empty($html)){
$html=$this->get_page_html($fromUrl, $pageType, $pageName, $isPagination);
@ -921,24 +949,9 @@ class Cpattern extends CpatternEvent{
}
if($allowColl){
$url_info=$this->match_url_info($fromUrl,$html);
$pn_area='';
if(!empty($pnConfig['reg_area'])){
if(empty($pnConfig['reg_area_module'])){
$pn_area=$this->get_rule_module_rule_data(array('rule'=>$pnConfig['reg_area'],'rule_merge'=>$pnConfig['reg_area_merge']), $html,null,true);
}elseif('json'==$pnConfig['reg_area_module']){
$pn_area=$this->rule_module_json_data(array('json'=>$pnConfig['reg_area'],'json_arr'=>'jsonencode'),$html);
}elseif('xpath'==$pnConfig['reg_area_module']){
$pn_area=$this->rule_module_xpath_data(array('xpath'=>$pnConfig['reg_area'],'xpath_attr'=>'outerHtml'),$html);
}
}else{
$pn_area=$html;
}
$areaMatch=$this->rule_match_area($pageType, $pageName, true, $html, true);
$pn_area=$areaMatch['area'];
$this->pn_area_matches[$pageType][$pageName]=$areaMatch['matches'];
if(!empty($pn_area)){
@ -951,7 +964,9 @@ class Cpattern extends CpatternEvent{
},$pn_area);
}
$m_pn_urls=$this->rule_match_urls($pageType,$pageName,true,$pn_area);
$urlsMatches=$this->rule_match_urls($pageType,$pageName,true,$pn_area,false,true);
$m_pn_urls=$urlsMatches['urls'];
foreach ($m_pn_urls as $purl){
@ -967,6 +982,8 @@ class Cpattern extends CpatternEvent{
$pn_urls=array_unique($pn_urls);
$pn_urls=array_values($pn_urls);
$this->pn_url_matches[$pageType][$pageName]=$urlsMatches['matches'];
}else{
if($isTest){
return $this->echo_error('未获取到分页链接,请检查分页链接规则');
@ -1018,7 +1035,12 @@ class Cpattern extends CpatternEvent{
}
}
}
if(!empty($nextPnUrl)){
$this->cur_pagination_urls[$pageSource]=$nextPnUrl;
}
}
return $nextPnUrl;
}
@ -1083,7 +1105,8 @@ class Cpattern extends CpatternEvent{
$pageOpened=$this->page_opened_tips($pageType,$pageName);
$cur_url=$field_source_url;
$this->echo_msg($pageOpened?array('%s:%s',$source_echo_msg,$pageOpened.$field_source_url):array('%s:<a href="%s" target="_blank">%s</a>',$source_echo_msg,$field_source_url,$field_source_url),'black');
$this->echo_url_msg(array('%s',$source_echo_msg),$field_source_url,$pageOpened);
$htmlInfo=$this->get_page_html($field_source_url, $pageType, $pageName,false,true);
$html=$htmlInfo['html'];
}
@ -1335,7 +1358,7 @@ class Cpattern extends CpatternEvent{
$this->collect_sleep(g_sc_c('caiji','interval_html'),true,true);
$pageOpened=$this->page_opened_tips('url','',true);
$this->echo_msg($pageOpened?array('——采集分页:%s',$pageOpened.$page_url):array('——采集分页:<a href="%s" target="_blank">%s</a>',$page_url,$page_url),'black');
$this->echo_url_msg(array('——采集分页'),$page_url,$pageOpened);
$htmlInfo=$this->get_page_html($page_url,'url','',true,true);
if(empty($htmlInfo['html'])){
return $this->echo_error('未获取到分页源代码');
@ -1881,8 +1904,8 @@ class Cpattern extends CpatternEvent{
}
}
$this->used_pagination_urls[$levelSource][$pageCurMd5]=1;
$pageOpened=$this->page_opened_tips('level_url',$levelConfig['name']);
$this->echo_msg($pageOpened?array('%s分析第%s级%s:%s',$next_level_str,$level,$pagePnStr,$pageOpened.$pageCurUrl):array('%s分析第%s级%s:<a href="%s" target="_blank">%s</a>',$next_level_str,$level,$pagePnStr,$pageCurUrl,$pageCurUrl),'black');
$pageOpened=$this->page_opened_tips('level_url',$levelConfig['name'],$pageIsPn);
$this->echo_url_msg(array('%s分析第%s级%s',$next_level_str,$level,$pagePnStr),$pageCurUrl,$pageOpened);
if($level_data['nextLevel']>0){
$return_msg=$this->_collect_level($pageCurUrl,$level_data['nextLevel']);
@ -2003,7 +2026,7 @@ class Cpattern extends CpatternEvent{
continue;
}
$mcacheCont->setCache($md5_cont_url, 1);
$this->echo_msg($pageOpened?array('%s采集内容页:%s',$echo_str,$pageOpened.$cont_url):array('%s采集内容页:<a href="%s" target="_blank">%s</a>',$echo_str,$cont_url,$cont_url),'black');
$this->echo_url_msg(array('%s采集内容页',$echo_str),$cont_url,$pageOpened);
$field_vals_list=$this->getFields($cont_url);
$is_loop=empty($this->first_loop_field)?false:true;

68
vendor/skycaiji/app/admin/event/CpatternBase.php vendored

@ -605,28 +605,13 @@ class CpatternBase extends CollectBase{
init_array($processList);
return $processList;
}
/*保存页面配置时处理数据*/
public function page_set_config($pageType,$pageConfig){
if(!is_array($pageConfig)){
$pageConfig=array();
}
$urlWebConfig=$pageConfig['url_web'];
if(!is_array($urlWebConfig)){
$urlWebConfig=array();
}
$urlWebConfig['open']=intval($urlWebConfig['open']);
$urlWebConfig['form_method']=empty($urlWebConfig['form_method'])?'':strtolower($urlWebConfig['form_method']);
$urlWebConfig['content_type']=empty($urlWebConfig['content_type'])?'':strtolower($urlWebConfig['content_type']);
$urlWebConfig['header_global']=empty($urlWebConfig['header_global'])?'':strtolower($urlWebConfig['header_global']);
\util\Funcs::filter_key_val_list($urlWebConfig['form_names'], $urlWebConfig['form_vals']);
\util\Funcs::filter_key_val_list($urlWebConfig['header_names'], $urlWebConfig['header_vals']);
$pageConfig['url_web']=$urlWebConfig;
$pageConfig['url_web']=$this->_page_set_config_url_web($pageConfig['url_web']);
if(!is_array($pageConfig['content_signs'])){
$pageConfig['content_signs']=array();
@ -644,7 +629,7 @@ class CpatternBase extends CollectBase{
$pageConfig['content_signs']=array_values($contentSigns);
if($pageType=='source_url'||$pageType=='level_url'||$pageType=='url'){
if($this->page_has_pagination($pageType)){
$pnConfig=is_array($pageConfig['pagination'])?$pageConfig['pagination']:array();
if($pageType=='url'){
@ -659,11 +644,27 @@ class CpatternBase extends CollectBase{
}
$pnConfig['open']=intval($pnConfig['open']);
$pnConfig['max']=intval($pnConfig['max']);
$pnConfig['url_web']=$this->_page_set_config_url_web($pnConfig['url_web']);
$pnConfig['renderer']=$this->_page_set_config_renderer($pnConfig['renderer']);
$pageConfig['pagination']=$pnConfig;
}
$pageConfig['renderer']=$this->_page_set_config_renderer($pageConfig['renderer']);
return $pageConfig;
}
private function _page_set_config_url_web($urlWebConfig){
init_array($urlWebConfig);
$urlWebConfig['open']=intval($urlWebConfig['open']);
$urlWebConfig['form_method']=empty($urlWebConfig['form_method'])?'':strtolower($urlWebConfig['form_method']);
$urlWebConfig['content_type']=empty($urlWebConfig['content_type'])?'':strtolower($urlWebConfig['content_type']);
$urlWebConfig['header_global']=empty($urlWebConfig['header_global'])?'':strtolower($urlWebConfig['header_global']);
$renderer=$pageConfig['renderer'];
\util\Funcs::filter_key_val_list($urlWebConfig['form_names'], $urlWebConfig['form_vals']);
\util\Funcs::filter_key_val_list($urlWebConfig['header_names'], $urlWebConfig['header_vals']);
return $urlWebConfig;
}
private function _page_set_config_renderer($renderer){
init_array($renderer);
\util\Funcs::filter_key_val_list3($renderer['types'], $renderer['elements'], $renderer['contents']);
foreach ($renderer['types'] as $k=>$v){
@ -676,9 +677,7 @@ class CpatternBase extends CollectBase{
$renderer['contents'][$k]='';
}
}
$pageConfig['renderer']=$renderer;
return $pageConfig;
return $renderer;
}
@ -880,6 +879,15 @@ class CpatternBase extends CollectBase{
return false;
}
}
public function page_has_pagination($pageType){
static $types=array('source_url','level_url','url');
if(in_array($pageType,$types)){
return true;
}else{
return false;
}
}
/*转换成数据源*/
public function page_source_merge($pageType,$pageName){
$pageSource=$pageType;
@ -1024,19 +1032,5 @@ class CpatternBase extends CollectBase{
}
return $return['data'];
}
public function page_url_web_opened($urlWebConfig,$paginationConfig=null){
$opened=false;
if($paginationConfig&&is_array($paginationConfig)&&$paginationConfig['use_url_web']){
$opened=$paginationConfig['use_url_web']=='y'?true:false;
}else{
if($urlWebConfig&&is_array($urlWebConfig)&&!empty($urlWebConfig['open'])){
$opened=true;
}
}
return $opened;
}
}
?>

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

File diff suppressed because it is too large Load Diff

23
vendor/skycaiji/app/admin/event/CpatternEvent.php vendored

@ -571,9 +571,21 @@ class CpatternEvent extends CpatternColl{
$listMd5=md5($params['batch_list']);
if(!isset($batch_list[$listMd5])){
if(preg_match_all('/([^\r\n]+?)\=([^\r\n]+)/', $params['batch_list'],$mlist)){
$batch_re=$mlist[1];
$batch_to=$mlist[2];
if(preg_match_all('/[^\r\n]+/', $params['batch_list'],$mlist)){
unset($params['batch_list']);
$mlist=$mlist[0];
$sign=empty($params['batch_sign'])?'=':$params['batch_sign'];
$batch_re=array();
$batch_to=array();
foreach ($mlist as $k=>$v){
$v=explode($sign,$v,2);
if(is_array($v)&&count($v)==2&&!empty($v[0])&&!empty($v[1])){
$batch_re[]=$v[0];
$batch_to[]=$v[1];
}
unset($mlist[$k]);
}
$batch_list[$listMd5]=array($batch_re,$batch_to);
}
}else{
@ -856,7 +868,6 @@ class CpatternEvent extends CpatternColl{
if(preg_match('/^\w+\:\/\//', $url)){
$charset=$params['api_charset'];
if($charset=='custom'){
$charset=$params['api_charset_custom'];
@ -875,6 +886,10 @@ class CpatternEvent extends CpatternColl{
}
$url=$this->_replace_insert_fields($url, $curUrlMd5, $loopIndex);
$url=\util\Funcs::url_auto_encode($url, $charset);
$postData=array();
if(is_array($params['api_params'])){
init_array($params['api_params']['name']);

2
vendor/skycaiji/app/admin/event/Rapi.php vendored

@ -17,7 +17,7 @@ class Rapi extends Release{
* @param unknown $config
*/
public function setConfig($config){
$api=input('api/a',array());
$api=\util\UnmaxPost::val('api/a',array());
$api['url']=trim($api['url'],'\/\\');
$api['cache_time']=intval($api['cache_time']);
$api['hide_fields']=is_array($api['hide_fields'])?$api['hide_fields']:array();

4
vendor/skycaiji/app/admin/event/Rcms.php vendored

@ -19,8 +19,8 @@ class Rcms extends Release{
* @param unknown $config
*/
public function setConfig($config){
$config['cms']=input('cms/a',array());
$config['cms_app']=input('cms_app/a',array());
$config['cms']=\util\UnmaxPost::val('cms/a',array());
$config['cms_app']=\util\UnmaxPost::val('cms_app/a',array());
if(empty($config['cms']['path'])){
$this->error('cms路径不能为空');
}

5
vendor/skycaiji/app/admin/event/Rdb.php vendored

@ -18,7 +18,7 @@ class Rdb extends Release{
* @param unknown $config
*/
public function setConfig($config){
$db=input('db/a',array(),'trim');
$db=\util\UnmaxPost::val('db/a',array(),'trim');
foreach ($db as $k=>$v){
if(empty($v)&&'pwd'!=$k){
@ -26,7 +26,8 @@ class Rdb extends Release{
}
}
$config['db']=$db;
$dbTables=trim_input_array('db_tables');
$dbTables=\util\UnmaxPost::val('db_tables/a',array(),'trim');
$dbTables=\util\Funcs::array_array_map('trim', $dbTables);
$dbTables=model('Release')->config_db_tables($dbTables);
$config['db_tables']=$dbTables;
return $config;

2
vendor/skycaiji/app/admin/event/Rdiy.php vendored

@ -18,7 +18,7 @@ class Rdiy extends Release{
* @param unknown $config
*/
public function setConfig($config){
$diy=input('diy/a',array(),'trim');
$diy=\util\UnmaxPost::val('diy/a',array(),'trim');
if(!in_array($diy['type'],array('app','code'))){
$this->error('类型错误');
}

58
vendor/skycaiji/app/admin/event/ReleaseBase.php vendored

@ -424,26 +424,31 @@ class ReleaseBase extends CollectBase{
}
$funcName=g_sc_c('download_img','img_func');
if(!empty($funcName)){
$imgFuncs=g_sc_c('download_img','img_funcs');
if(!empty($imgFuncs)&&is_array($imgFuncs)){
$paramVals=array(
'[图片:文件名]'=>$filename,
'[图片:路径]'=>$img_path,
'[图片:名称]'=>$imgname,
'[图片:链接]'=>$imgurl,
'[图片:网址]'=>$url
);
$return=model('FuncApp')->execute_func('downloadImg',$funcName,$filename,g_sc_c('download_img','img_func_param'),$paramVals);
if($return['success']){
if($return['data']&&preg_match('/^\w+\:\/\//',$return['data'])){
$mfuncApp=model('FuncApp');
foreach ($imgFuncs as $imgFunc){
$paramVals['[图片:链接]']=$this->cache_img_list[$key];
if($imgFunc&&is_array($imgFunc)&&$imgFunc['func']){
$this->cache_img_list[$key]=$return['data'];
$return=$mfuncApp->execute_func('downloadImg',$imgFunc['func'],$filename,$imgFunc['func_param'],$paramVals);
if($return['success']){
if($return['data']&&preg_match('/^\w+\:\/\//',$return['data'])){
$this->cache_img_list[$key]=$return['data'];
}
}elseif($return['msg']){
$this->echo_msg(array('%s',$return['msg']));
}
}
}elseif($return['msg']){
$this->echo_msg(array('%s',$return['msg']));
}
}
}
@ -653,26 +658,31 @@ class ReleaseBase extends CollectBase{
if(write_dir_file($filefull,$fileCodeInfo['html'])){
$this->cache_file_list[$key]=$fileurl;
$funcName=g_sc_c('download_file','file_func');
if(!empty($funcName)){
$fileFuncs=g_sc_c('download_file','file_funcs');
if(!empty($fileFuncs)&&is_array($fileFuncs)){
$paramVals=array(
'[文件:文件名]'=>$filefull,
'[文件:路径]'=>$file_path,
'[文件:名称]'=>$filename,
'[文件:链接]'=>$fileurl,
'[文件:网址]'=>$url
);
$return=model('FuncApp')->execute_func('downloadFile',$funcName,$filefull,g_sc_c('download_file','file_func_param'),$paramVals);
if($return['success']){
if($return['data']&&preg_match('/^\w+\:\/\//',$return['data'])){
$mfuncApp=model('FuncApp');
foreach ($fileFuncs as $fileFunc){
$paramVals['[文件:链接]']=$this->cache_file_list[$key];
if($fileFunc&&is_array($fileFunc)&&$fileFunc['func']){
$this->cache_file_list[$key]=$return['data'];
$return=$mfuncApp->execute_func('downloadFile',$fileFunc['func'],$filefull,$fileFunc['func_param'],$paramVals);
if($return['success']){
if($return['data']&&preg_match('/^\w+\:\/\//',$return['data'])){
$this->cache_file_list[$key]=$return['data'];
}
}elseif($return['msg']){
$this->echo_msg(array('%s',$return['msg']));
}
}
}elseif($return['msg']){
$this->echo_msg(array('%s',$return['msg']));
}
}
}

2
vendor/skycaiji/app/admin/event/Rfile.php vendored

@ -17,7 +17,7 @@ class Rfile extends Release {
* @param unknown $config
*/
public function setConfig($config){
$file=input('file/a',array());
$file=\util\UnmaxPost::val('file/a',array());
$file['path']=trim($file['path'],'\/\\');
$file['hide_fields']=is_array($file['hide_fields'])?$file['hide_fields']:array();
if(empty($file['path'])){

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

@ -18,7 +18,7 @@ class Rtoapi extends Release{
* @param unknown $config
*/
public function setConfig($config){
$toapi=input('toapi/a',array(),'trim');
$toapi=\util\UnmaxPost::val('toapi/a',array(),'trim');
if($toapi['module']=='app'){
if(empty($toapi['app_url'])){
$this->error('请输入接口地址');
@ -193,6 +193,7 @@ class Rtoapi extends Release{
$postData=$this->_replace_fields($paramVals,$collFields);
$url=$this->_replace_fields($apiUrl,$collFields);
$url=\util\Funcs::url_auto_encode($url, $apiCharset);
if($apiConfig['type']=='post'){

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

@ -213,7 +213,13 @@ return array(
'page_url'=>'内容页',
'page_relation_url'=>'关联页',
'render_wait_end'=>'等待页面完全渲染',
'render_wait_time'=>'等待时间(秒)',
'render_scroll_half'=>'滚动到中间',
'render_scroll_end'=>'滚动到底部',
'render_scroll_top'=>'滚动到指定位置',
'render_val'=>'赋值',
'render_click'=>'点击',
'rele_set'=>'发布设置',
'rele_error_detect_null'=>'没有检测到本地CMS程序,您可以手动绑定数据',
@ -345,7 +351,7 @@ return array(
'tips_matchn_area'=>'示例:[内容123] [内容abc]',
'tips_match_url'=>'示例:&lt;a href=&quot;http://demo.com/[内容123]/[内容abc]&quot;&gt;(*)&lt;/a&gt;',
'tips_matchn_url'=>'示例:http://www.demo.com/[内容123]-[内容abc].html',
'release_upgrade'=>'插件版本过低,请升级插件 <a href="https://www.skycaiji.com/manual/doc/release_upgrade" target="_blank">升级教程</a>',
);
?>

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

@ -79,9 +79,49 @@ class Collector extends \skycaiji\common\model\BaseModel{
if(is_array($config['common_process'])){
$config['common_process']=$this->_compatible_processes($config['common_process']);
}
foreach (array('front_urls','level_urls','relation_urls') as $pagesKey){
if(is_array($config[$pagesKey])){
foreach ($config[$pagesKey] as $k=>$v){
if(is_array($v)&&is_array($v['content_signs'])){
$v['content_signs']=$this->_compatible_content_signs($v['content_signs']);
$config[$pagesKey][$k]=$v;
}
}
}
}
if(is_array($config['source_config'])&&is_array($config['source_config']['content_signs'])){
$config['source_config']['content_signs']=$this->_compatible_content_signs($config['source_config']['content_signs']);
}
if(is_array($config['content_signs'])){
$config['content_signs']=$this->_compatible_content_signs($config['content_signs']);
}
return $config;
}
private function _compatible_content_signs($contentSigns){
if(is_array($contentSigns)){
foreach ($contentSigns as $k=>$v){
if(isset($v['func'])){
if($v['func']){
$v['funcs']=array();
$v['funcs'][]=array(
'func'=>$v['func'],
'func_param'=>$v['func_param']
);
}
unset($v['func']);
unset($v['func_param']);
$contentSigns[$k]=$v;
}
}
}
return $contentSigns;
}
private function _compatible_processes($processes){
if(is_array($processes)){
$processes=array_values($processes);
@ -367,7 +407,6 @@ class Collector extends \skycaiji\common\model\BaseModel{
/*采集运行进程*/
public static function collect_run_processes($collectorKey,$collectNum=null,$collectAuto=null,$backstageRun=false,$urlParams=null){
ignore_user_abort(true);
\util\Funcs::close_session();
if(empty($collectorKey)){
return;
}

185
vendor/skycaiji/app/admin/model/Config.php vendored

@ -20,10 +20,75 @@ class Config extends \skycaiji\common\model\Config {
$cacheConfig=array();
}
$configList=$cacheConfig['list'];
return is_array($configList)?$configList:array();
if(!empty($configList)){
init_array($configList);
$configList['download_img']=$this->compatible_func_config($configList['download_img'], false);
$configList['download_file']=$this->compatible_func_config($configList['download_file'], true);
}
return $configList;
}
public function compatible_func_config($config,$isFileConfig,$isTaskConfig=false){
if($config&&is_array($config)){
$funcName=$isFileConfig?'file_func':'img_func';
if(isset($config[$funcName])){
$funcsName=$isFileConfig?'file_funcs':'img_funcs';
if(!$isTaskConfig){
if($config[$funcName]){
$config[$funcsName]=array(
array(
'func'=>$config[$funcName],
'func_param'=>$config[$funcName.'_param']
)
);
}
}else{
$taskFunc='';
$taskFuncParam=$config[$funcName.'_param'];
if(empty($config[$funcName])){
$funcs=g_sc_c($isFileConfig?'download_file':'download_img',$funcsName);
if($funcs&&is_array($funcs)){
$funcs=array_values($funcs);
if($funcs[0]&&is_array($funcs[0])){
$taskFunc=$funcs[0]['func'];
$taskFuncParam=empty($taskFuncParam)?$funcs[0]['func_param']:$taskFuncParam;
}
}
}else if($config[$funcName]=='n'){
$config[$funcsName.'_open']='n';
}else{
$taskFunc=$config[$funcName];
}
if($taskFunc){
$config[$funcsName.'_open']='y';
$config[$funcsName]=array(
array(
'func'=>$taskFunc,
'func_param'=>$taskFuncParam
)
);
}
}
unset($config[$funcName]);
unset($config[$funcName.'_param']);
}
}
return $config;
}
public function server_is_cli($isInput=false,$val=null){
$value='';
if(empty($isInput)){
@ -38,6 +103,34 @@ class Config extends \skycaiji\common\model\Config {
}
public function server_is_swoole($isInput=false,$val=null){
$value='';
if(empty($isInput)){
$value=g_sc_c('caiji','server');
}else{
$value=$val;
}
$value=$value=='swoole'?true:false;
return $value;
}
public function server_is_swoole_php($isInput=false,$server=null,$swoolePhp=null){
if(empty($isInput)){
$server=g_sc_c('caiji','server');
$swoolePhp=g_sc_c('caiji','swoole_php');
}
if($server=='swoole'&&!empty($swoolePhp)){
return true;
}else{
return false;
}
}
public function page_render_is_chrome($isInput=false,$val=null){
$value='';
if(empty($isInput)){
@ -197,6 +290,60 @@ class Config extends \skycaiji\common\model\Config {
return $php_filename;
}
public function php_is_valid($phpFile,$getModules=false){
$result=return_result('',false,array('v'=>'','ver'=>'','m'=>'','swoole'=>''));
if(!function_exists('proc_open')){
$result['msg']='需开启proc_open函数';
}else{
$phpResult=$this->exec_php_version($phpFile);
if($phpResult===false){
$result['msg']='未检测到PHP可执行文件,请手动输入';
}elseif(is_array($phpResult)){
$result=array_merge($result,$phpResult);
}
if(empty($phpResult)||(!$phpResult['success']&&$phpResult['msg'])){
$result['success']=false;
$result['msg']=$phpResult['msg']?:'php无效';
}
if($result['success']){
$result['v']=$result['msg'];
if($result['v']){
if(preg_match('/\bPHP\s+(?P<ver>\d+(\.\d+){1,})/i',$result['v'],$mphpv)){
$result['ver']=$mphpv['ver'];
}
}
}
if($getModules){
if($result['success']){
$phpResult=$this->exec_php_m($phpFile);
if($phpResult===false){
$result['msg']='未检测到PHP可执行文件,请手动输入';
}elseif(is_array($phpResult)){
$result=array_merge($result,$phpResult);
}
if(empty($phpResult)||(!$phpResult['success']&&$phpResult['msg'])){
$result['success']=false;
$result['msg']=$phpResult['msg']?:'php无效';
}
if($result['success']){
$result['m']=$result['msg'];
if($result['m']){
if(preg_match('/\bswoole\b/i', $result['m'])){
$result['swoole']=true;
}
}
}
}
}
}
return $result;
}
public function exec_php_version($phpFile){
$result=false;
if(empty($phpFile)){
@ -218,7 +365,7 @@ class Config extends \skycaiji\common\model\Config {
$result['msg']=$info['error'];
}elseif($info['output']){
$result['success']=true;
$result['msg']=('测试成功,PHP信息:'.$info['output']);
$result['msg']=$info['output'];
}else{
$result['success']=true;
}
@ -228,6 +375,40 @@ class Config extends \skycaiji\common\model\Config {
}
return $result;
}
public function exec_php_m($phpFile){
$result=false;
if(empty($phpFile)){
$phpFile=self::detect_php_exe();
}
if(!empty($phpFile)){
$result=return_result('',false);
$phpFile=self::cli_safe_filename($phpFile);
$phpFile.=' -m';
$info=\util\Tools::proc_open_exec_curl($phpFile,'all',10,true);
$info=is_array($info)?$info:array();
$info['output']=trim($info['output']);
$info['error']=trim($info['error']);
if(is_array($info['status'])&&$info['status']['running']){
if($info['error']){
$result['msg']=$info['error'];
}elseif($info['output']){
$result['success']=true;
$result['msg']=$info['output'];
}else{
$result['success']=true;
}
}elseif($info['error']){
$result['msg']=$info['error'];
}
}
return $result;
}
public static function cli_safe_filename($filename){
if(!empty($filename)){

2
vendor/skycaiji/app/admin/model/ReleaseApp.php vendored

@ -111,7 +111,7 @@ class ReleaseApp extends \skycaiji\common\model\BaseModel{
$fileName=$this->oldFileName($appName,$model);
$appName=$appName.$model;
if(file_exists($fileName)){
Loader::addNamespace('Release',realpath(APP_PATH.'Release'));
Loader::addNamespace('Release',realpath(config('app_path').'/Release'));
Loader::import($appName,config('app_path').'/Release/'.$model.'/','.class.php');
$oldClass='\\Release\\'.$model.'\\'.$appName;
$oldClass=new $oldClass();

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

@ -77,13 +77,21 @@ class Task extends \skycaiji\common\model\BaseModel{
}
if(empty($config['img_func'])){
init_array($config['img_funcs']);
$imgFuncs=array();
if(empty($config['img_funcs_open'])){
set_g_sc(['c','download_img','img_func'],$original_config['download_img']['img_func']);
$imgFuncs=$original_config['download_img']['img_funcs'];
init_array($imgFuncs);
if(!empty($config['img_funcs'])){
$imgFuncs=array_merge($imgFuncs,$config['img_funcs']);
}
}else{
set_g_sc(['c','download_img','img_func'],$config['img_func']=='n'?'':$config['img_func']);
$imgFuncs=$config['img_funcs_open']=='n'?array():$config['img_funcs'];
}
set_g_sc(['c','download_img','img_funcs'],$imgFuncs);
if(empty($config['download_file'])){
@ -92,14 +100,23 @@ class Task extends \skycaiji\common\model\BaseModel{
}else{
set_g_sc(['c','download_file','download_file'],$config['download_file']=='n'?0:1);
}
if(empty($config['file_func'])){
init_array($config['file_funcs']);
$fileFuncs=array();
if(empty($config['file_funcs_open'])){
set_g_sc(['c','download_file','file_func'],$original_config['download_file']['file_func']);
$fileFuncs=$original_config['download_file']['file_funcs'];
init_array($fileFuncs);
if(!empty($config['file_funcs'])){
$fileFuncs=array_merge($fileFuncs,$config['file_funcs']);
}
}else{
set_g_sc(['c','download_file','file_func'],$config['file_func']=='n'?'':$config['file_func']);
$fileFuncs=$config['file_funcs_open']=='n'?array():$config['file_funcs'];
}
set_g_sc(['c','download_file','file_funcs'],$fileFuncs);
if(empty($config['translate'])){
@ -183,6 +200,8 @@ class Task extends \skycaiji\common\model\BaseModel{
}
}
}
$config=model('Config')->compatible_func_config($config,false,true);
$config=model('Config')->compatible_func_config($config,true,true);
}
return $config;
}

7
vendor/skycaiji/app/admin/model/User.php vendored

@ -136,12 +136,15 @@ class User extends \skycaiji\common\model\User{
session('user_login',null);
session('is_admin',null);
set_g_sc('user_login',null);
}else{
session('user_login',array(
$userLogin=array(
'uid'=>$userData['uid'],
'key'=>$this->generate_key($userData)
));
);
session('user_login',$userLogin);
set_g_sc('user_login',$userLogin);
$mUg=model('admin/Usergroup');
$isAdmin=null;

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

@ -110,7 +110,10 @@
</tr>
<tr>
<th>PHP版本</th>
<td>{$serverData['php']} <a href="{:url('setting/caiji')}" id="php_cli_version" style="display:none;margin-left:10px;">CLI命令行版本:<span></span></a></td>
<td>{$serverData['php']}
<a href="{:url('setting/caiji')}" id="cli_php_version" style="display:none;margin-left:10px;">CLI命令行版本:<span></span></a>
<a href="{:url('setting/caiji')}" id="swoole_php_version" style="display:none;margin-left:10px;">swoole php版本:<span></span></a>
</td>
</tr>
<tr>
<th>上传限制</th>
@ -125,7 +128,7 @@
{if !empty($openBasedir)}
<div class="alert alert-warning alert-dismissible" id="box_open_basedir">
<button type="button" class="close">×</button>
您的网站开启了目录访问限制(open_basedir),受保护的站点目录:{$openBasedir},这会影响到站点目录外的文件读写和CMS程序的访问。如果您未更改图片保存目录(站点目录外)并且cms程序都在站点目录内则可忽略该问题!
您的网站开启了目录访问限制(open_basedir)导致 {$openBasedir} 目录外的文件无法读写。如果图片保存目录、文件保存目录、cms程序(发布)都在目录内则可忽略该问题!
</div>
{/if}
{if !empty($systemWarning)}

28
vendor/skycaiji/app/admin/view/collector/echo_url_msg.html vendored

@ -0,0 +1,28 @@
{extend name="common:main" /}
{block name="cssjs"}
<script type="text/javascript" src="__PUBLIC__/static/js/admin/collector.js?{$Think.config.html_v}"></script>
{/block}
{block name="content"}
<style type="text/css">
.add-url-web-form,.add-url-web-header,.add-url-renderer,.help-block{display:none;}
.c-p-url-web-form tr td:last-child,.c-p-url-web-header tr td:last-child{display:none;}
.td-renderer-op{display:none;}
.c-p-url-page-signs{display:block;}
.c-p-url-page-signs>.input-group-addon{display:none;}
</style>
<div id="win_test_match">
<form id="win_form_cache" style="display:none;">
</form>
<form id="win_form_test" method="post">
{include file="cpattern:set_page_url" _page_type="test" _is_pagination="" /}
{include file="cpattern:set_tpl" /}
</form>
</div>
<script type="text/javascript">
'use strict';//严格模式
(function(){
var testCp=new CollectorPattern();
testCp.init_echo_url_msg({$data['url_web']|json_encode},{$data['renderer']|json_encode});
})();
</script>
{/block}

2
vendor/skycaiji/app/admin/view/collector/set.html vendored

@ -10,7 +10,7 @@
<input type="hidden" name="tab_link" value="{:input('tab_link')}" />
<input type="hidden" name="effective" value="" />
<input type="hidden" name="effective_edit" value="" />
{if input('?easymode')}
{if input('easymode')}
<input type="hidden" name="easymode" value="1" />
{/if}

2
vendor/skycaiji/app/admin/view/common/header_public.html vendored

@ -47,4 +47,4 @@
<script src="__PUBLIC__/static/js/admin.js?{$Think.config.html_v}"></script>
<link href="__PUBLIC__/static/css/admin.css?{$Think.config.html_v}" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__PUBLIC__/static/js/langs/{$Think.config.DEFAULT_LANG}.js?{$Think.config.html_v}"></script>
<script type="text/javascript">var site_config={root:"__ROOT__",pub:"__PUBLIC__",usertoken:"{:g_sc('usertoken')}",clientinfo:"{:g_sc('clientinfo')}"};</script>
<script type="text/javascript">var site_config={root:"__ROOT__",pub:"__PUBLIC__",usertoken:"{:g_sc('usertoken')}",clientinfo:"{:g_sc('clientinfo')}",admincp:{:json_encode(g_sc_c('admincp'))}};</script>

5
vendor/skycaiji/app/admin/view/common/main.html vendored

@ -2,7 +2,6 @@
{block name="cssjs"}{/block}
</head>
<body class="skin-blue" data-spy="scroll" data-target="#scrollspy">
<script type="text/javascript">admincpInit();</script>
<div class="wrapper">
<header class="main-header">
<a href="{:url('admin/backstage/index')}" class="logo">
@ -41,7 +40,7 @@
{php}$curSubm=array(strtolower(request()->action())=>' menu-open cur-menu');{/php}
<aside class="main-sidebar">
<section class="sidebar">
<ul class="sidebar-menu" data-widget="tree">
<ul class="sidebar-menu">
<li class="treeview{$curMenu['setting']}">
<a href="#">
<i class="fa fa-cog"></i> <span>{$Think.lang.setting}</span>
@ -172,6 +171,7 @@
<ul class="treeview-menu treeview-skins" style="display:none;">
<li>
<div class="checkbox"><label><input id="chk_sidebar_mini" type="checkbox"> {$Think.lang.admincp_sidebar_mini}</label></div>
<div class="checkbox"><label><input id="chk_sidebar_narrow" type="checkbox"> 窄屏显示</label></div>
</li>
<li>
<div id="sidebar_skins"></div>
@ -183,6 +183,7 @@
</ul>
</section>
</aside>
<script type="text/javascript">admincpOp.init();</script>
<div class="content-wrapper">
<section class="content-header">
<h1>{:g_sc('html_tag_name')}</h1>

44
vendor/skycaiji/app/admin/view/cpattern/content_sign.html vendored

@ -27,40 +27,46 @@
</div>
</div>
<div class="panel panel-default">
<div class="form-group">
<label>使用函数</label>
<a href="javascript:;" class="glyphicon glyphicon-plus" id="c_p_content_sign_add_func" title="添加"></a>
<div class="panel-group ui-sortable" id="c_p_content_sign_funcs" style="margin-bottom:0;">
</div>
</div>
<div class="form-group form-group-sm">
<button type="submit" class="btn btn-primary btn-block">确定</button>
</div>
</form>
<div id="c_p_content_sign_tpl_func" style="display:none;">
<div class="panel panel-default" data-func-box="1">
<div class="panel-heading">
<h4 class="panel-title"><a data-toggle="collapse" href="#panel_content_sign_func" aria-expanded="false" class="collapsed">使用函数</a></h4>
<div class="panel-title" style="font-size:14px;overflow:hidden;line-height:20px;">
<a data-toggle="collapse" data-func-a="1" href="#" data-parent="#c_p_content_sign_funcs" aria-expanded="false" class="collapsed">使用函数</a>
<div style="float:right;font-size:12px;">
<a href="javascript:;" data-func-move="1" class="glyphicon icon-drag-move" title="移动"></a>
<a href="javascript:;" data-func-remove="1" class="glyphicon glyphicon-remove" title="删除"></a>
</div>
</div>
</div>
<div class="panel-collapse collapse" id="panel_content_sign_func">
<div class="panel-collapse collapse" data-func-panel="1">
<div class="panel-body">
<div class="form-group">
<label>函数名</label>
<select name="content_sign[func]" class="form-control">
<select class="form-control" data-func-func="1">
<option value="">不使用</option>
</select>
</div>
<div class="form-group c-p-url-page-signs" data-page-type="{$page_type}" data-input-name="content_sign[func_param]">
<div class="form-group">
<label>传入参数</label>
<textarea name="content_sign[func_param]" rows="2" class="form-control" data-placeholder="默认传入当前内容标签的值" placeholder="默认传入当前内容标签的值"></textarea>
<textarea rows="3" data-func-func-param="1" class="form-control" data-placeholder="默认传入当前内容标签的值" placeholder="默认传入当前内容标签的值"></textarea>
<div class="help-block">
<div class="dropdown">
一行一个值,可输入任何内容,用 <a href="javascript:;" class="c-p-content-sign-add-cur" onclick="">###</a>
<div style="display:inline;">
表示当前内容标签的值
<div class="dropdown-menu dropdown-menu-right"></div>
</div>
,请按函数传参,否则运行出错!<a href="javascript:;" onclick="tipsPluginFunc('contentSign')">扩展函数</a>
</div>
一行一个值,可输入任何内容,用 <a href="javascript:;" data-func-insert="###">###</a> 表示当前内容标签的值,请按函数传参,否则运行出错!<a href="javascript:;" onclick="pluginFuncOp.tips('contentSign')">扩展函数</a>
</div>
</div>
</div>
</div>
</div>
<div class="form-group form-group-sm">
<button type="submit" class="btn btn-primary btn-block">确定</button>
</div>
</form>
</div>
<script type="text/javascript">
c_pattern.cpContentSign.init({:empty($content_sign)?'null':json_encode($content_sign)},'{$page_type}',{$page_config|json_encode});
</script>

14
vendor/skycaiji/app/admin/view/cpattern/field.html vendored

@ -72,14 +72,14 @@
{include file="cpattern:rule_module" _type="xpath" _name="field" _name_pre="" _allow_loop="1" /}
</div>
<div class="c-p-field-module" module="words" style="display:none;">
<textarea name="field[words]" class="form-control" rows="3">{$field['words']}</textarea>
<textarea name="field[words]" class="form-control" rows="10"></textarea>
</div>
<div class="c-p-field-module" module="num" style="display:none;">
<div class="input-group">
<div class="input-group-addon">范围</div>
<input type="number" name="field[num_start]" class="form-control" value="{:isset($field['num_start'])?intval($field['num_start']):1}" />
<input type="number" name="field[num_start]" class="form-control" />
<div class="input-group-addon" style="border-left:0;border-right:0;"></div>
<input type="number" name="field[num_end]" class="form-control" value="{:isset($field['num_end'])?intval($field['num_end']):100}" />
<input type="number" name="field[num_end]" class="form-control" />
</div>
</div>
<div class="c-p-field-module" module="time" style="display:none;">
@ -105,12 +105,12 @@
<input type="text" name="field[time_end]" class="form-control" placeholder="默认当前时间" autocomplete="off" />
<div class="input-group-btn"><button type="button" class="btn btn-default" onclick="$(this).parent().siblings('input:text').val('');">清空</button></div>
</div>
<div class="checkbox"><label><input type="checkbox" name="field[time_stamp]" value="1" {$field['time_stamp']?'checked="checked"':''}> 转换成时间戳</label></div>
<div class="checkbox"><label><input type="checkbox" name="field[time_stamp]" value="1" /> 转换成时间戳</label></div>
</div>
<div class="c-p-field-module" module="list" style="display:none;">
<div class="form-group">
<label>列表数据</label>
<textarea name="field[list]" class="form-control" rows="3">{$field['list']}</textarea>
<textarea name="field[list]" class="form-control" rows="3"></textarea>
<p class="help-block">一行一条数据,从列表中抽取数据</p>
</div>
<div class="form-group">
@ -123,7 +123,7 @@
</div>
</div>
<div class="c-p-field-module" module="merge" style="display:none;">
<textarea name="field[merge]" class="form-control" rows="3">{$field['merge']}</textarea>
<textarea name="field[merge]" class="form-control" rows="3"></textarea>
<div id="c_p_field_merge_list" style="margin-top:5px;"></div>
</div>
<div class="c-p-field-module" module="json" style="display:none;">
@ -162,7 +162,7 @@
</div>
<div class="c-p-field-module" module="sign" style="display:none;">
<div class="form-group">
<textarea name="field[sign]" class="form-control" rows="3" placeholder="填入数据来源页面中区域规则或网址规则里的{:cp_sign('match')}标签">{$field['sign']}</textarea>
<textarea name="field[sign]" class="form-control" rows="3" placeholder="填入数据来源页面中区域规则或网址规则里的{:cp_sign('match')}标签"></textarea>
<div id="c_p_field_sign_list" style="margin-top:10px;"></div>
<p class="help-block">如果存在同名标签,实际获取后面的标签</p>
</div>

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

@ -338,9 +338,13 @@
<div class="c-p-process-module" module="batch">
<div class="form-group">
<label>批量替换</label>
<textarea data-process="batch:batch_list" rows="3" class="form-control"></textarea>
<textarea data-process="batch:batch_list" rows="5" class="form-control"></textarea>
<p class="help-block">一行一对替换词,用“=”分隔,例如:aa=bb,即将“aa”替换成“bb”</p>
</div>
<div class="form-group">
<label>替换词分隔符</label>
<input type="text" data-process="batch:batch_sign" class="form-control" placeholder="默认=" />
</div>
</div>
<div class="c-p-process-module" module="substr">
<div class="form-group">
@ -375,7 +379,7 @@
<textarea data-process="func:func_param" rows="2" class="form-control" data-placeholder="默认传入当前字段"></textarea>
<div class="help-block">
一行一个值, 可输入任何内容或<select class="p-m-func-field"><option value="">插入字段</option></select>
请按函数传参, 否则运行出错!<a href="javascript:;" onclick="tipsPluginFunc('process')">扩展函数</a>
请按函数传参, 否则运行出错!<a href="javascript:;" onclick="pluginFuncOp.tips('process')">扩展函数</a>
</div>
</div>
</section>
@ -384,7 +388,15 @@
<section>
<div class="form-group">
<label>接口地址</label>
<input type="text" data-process="api:api_url" class="form-control" />
<div class="input-group">
<input type="text" data-process="api:api_url" class="form-control" />
<div class="input-group-addon" style="padding:0;">
<div class="form-control-slt p-m-api-url-field">
<select class="form-control">
</select>
</div>
</div>
</div>
<p class="help-block">/开头自动补全为{:config('root_website')}/</p>
</div>
<div class="form-group">

4
vendor/skycaiji/app/admin/view/cpattern/set.html vendored

@ -233,7 +233,7 @@
</div>
</div>
<div class="panel panel-default" style="margin-bottom:0;">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#c_p_request_headers_file" aria-expanded="false">下载文件</a>
@ -316,7 +316,7 @@
<div class="panel-heading">
<h4 class="panel-title">起始页列表</h4>
</div>
<div class="panel-body" style="padding-bottom:0;">
<div class="panel-body">
<div class="form-group" id="coll_pattern_source_url">
<div>
<label class="control-label" style="margin-bottom:0;">起始网址</label>

160
vendor/skycaiji/app/admin/view/cpattern/set_page.html vendored

@ -1,163 +1,25 @@
{assign name="_tpl_page_type" value="[_page_type]" /}
{php}$_tpl_vars=\util\Tools::cp_page_tpl_vars($_tpl_page_type);{/php}
{if $_tpl_page_type=='level_url'}
{if $_tpl_page_type=='front_url'}
{include file="cpattern:set_page_url" _page_type="front_url" _is_pagination="" /}
{elseif $_tpl_page_type=='source_url'}
{include file="cpattern:set_page_url" _page_type="source_url" _is_pagination="" /}
{elseif $_tpl_page_type=='level_url'}
{include file="cpattern:set_page_rule" _page_type="level_url" _is_pagination="" /}
{include file="cpattern:set_page_url" _page_type="level_url" _is_pagination="" /}
{elseif $_tpl_page_type=='url' /}
{include file="cpattern:set_page_rule" _page_type="url" _is_pagination="" /}
{include file="cpattern:set_page_url" _page_type="url" _is_pagination="" /}
{elseif $_tpl_page_type=='relation_url' /}
{include file="cpattern:set_page_rule" _page_type="relation_url" _is_pagination="" /}
{include file="cpattern:set_page_url" _page_type="relation_url" _is_pagination="" /}
{elseif $_tpl_page_type=='test' /}
{include file="cpattern:set_page_url" _page_type="test" _is_pagination="" /}
{/if}
<div class="panel panel-default" id="panel_{$_tpl_vars['id']}_web">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#{$_tpl_vars['id']}_web" aria-expanded="false" class="collapsed">请求{$_tpl_vars['title']}网址</a>
</h4>
</div>
<div id="{$_tpl_vars['id']}_web" class="panel-collapse collapse" aria-expanded="false">
<div class="panel-body">
<div class="form-group" style="margin-bottom:0;">
<label class="control-label">开启自定义请求</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="{$_tpl_vars['name']}[url_web][open]" value="1"></label>
<label class="radio-inline"><input type="radio" name="{$_tpl_vars['name']}[url_web][open]" value="0" checked="checked"></label>
</div>
<p class="help-block">抓取网址时使用自定义设置</p>
</div>
<div id="{$_tpl_vars['id']}_web_open" style="display:none;margin-top:15px;">
<div class="form-group">
<label class="control-label">网页编码</label>
<div class="input-group input-select-custom">
<div class="input-group-btn">
<select name="{$_tpl_vars['name']}[url_web][charset]" class="form-control">
<option value="" class="def-config-charset"></option>
<option value="auto">自动检测</option>
<option value="utf-8">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="{$_tpl_vars['name']}[url_web][charset_custom]">
</div>
<p class="help-block">默认使用采集器设置»网页编码中的配置</p>
</div>
<div class="form-group">
<label class="control-label">内容解压缩</label>
<div class="input-group input-select-custom">
<div class="input-group-btn">
<select name="{$_tpl_vars['name']}[url_web][encode]" class="form-control">
<option value="" class="def-config-encode"></option>
<option value="n">系统默认</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="{$_tpl_vars['name']}[url_web][encode_custom]">
</div>
<p class="help-block">默认使用采集器设置»内容解压缩中的配置</p>
</div>
<div class="form-group">
<label>请求方式</label>
<select name="{$_tpl_vars['name']}[url_web][form_method]" class="form-control">
<option value="">GET</option>
<option value="post">POST</option>
</select>
</div>
<div class="form-group c-p-url-web-content-type" style="display:none;">
<label>POST数据类型 <a href="javascript:;" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="tipsCurlPost()"></a></label>
<select name="{$_tpl_vars['name']}[url_web][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 class="control-label">发送数据 <a href="javascript:;" class="glyphicon glyphicon-plus add-url-web-form" title="添加"></a></label>
<div class="table-responsive c-p-url-web-form">
<table class="table table-bordered table-hover">
<thead>
<tr>
<td>名称</td>
<td></td>
<td>删除</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<div class="form-group">
<label>使用全局请求头</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="{$_tpl_vars['name']}[url_web][header_global]" value="" checked="checked"> 默认:<span class="def-config-request-headers-open"></span></label>
<label class="radio-inline"><input type="radio" name="{$_tpl_vars['name']}[url_web][header_global]" value="y"> </label>
<label class="radio-inline"><input type="radio" name="{$_tpl_vars['name']}[url_web][header_global]" value="n"> </label>
</div>
<p class="help-block">默认使用采集器设置»请求头信息»抓取页面中的配置(受全局开启状态影响)</p>
</div>
<div class="form-group">
<label class="control-label">请求头信息 <a href="javascript:;" class="glyphicon glyphicon-plus add-url-web-header" title="添加"></a></label>
<div class="table-responsive c-p-url-web-header">
<table class="table table-bordered table-hover">
<thead>
<tr>
<td>名称</td>
<td></td>
<td>删除</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<p class="help-block">添加新的或者覆盖已有的请求头信息</p>
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default" id="panel_{$_tpl_vars['id']}_renderer">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#{$_tpl_vars['id']}_renderer" aria-expanded="false" class="collapsed">执行页面渲染</a>
</h4>
</div>
<div id="{$_tpl_vars['id']}_renderer" class="panel-collapse collapse" aria-expanded="false">
<div class="panel-body">
<div class="form-group">
<label class="control-label">开启页面渲染</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="{$_tpl_vars['name']}[renderer][open]" value="" checked="checked"> 默认:<span class="def-config-page-render"></span></label>
<label class="radio-inline"><input type="radio" name="{$_tpl_vars['name']}[renderer][open]" value="y"> </label>
<label class="radio-inline"><input type="radio" name="{$_tpl_vars['name']}[renderer][open]" value="n"> </label>
</div>
<p class="help-block">默认:采集器设置»页面渲染的状态</p>
</div>
<div class="form-group">
<label class="control-label">
页面渲染动作
<a href="javascript:;" class="glyphicon glyphicon-plus add-url-renderer" title="添加"></a>
</label>
<div class="table-responsive c-p-url-renderer-list">
<table class="table table-hover">
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{if $_tpl_page_type!='test'}
<div class="panel panel-default" id="panel_{$_tpl_vars['id']}_content_sign"{if $_tpl_page_type=='url'} style="margin-bottom:0;"{/if}>
<div class="panel panel-default" id="panel_{$_tpl_vars['id']}_content_sign">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#{$_tpl_vars['id']}_content_sign" aria-expanded="false" class="collapsed">提取内容标签</a>

9
vendor/skycaiji/app/admin/view/cpattern/set_page_rule.html vendored

@ -13,7 +13,6 @@
$_tpl_name.='[pagination]';
$_tpl_title='分页';
$_tpl_url_required=true;
$_tpl_match_global=false;
}
{/php}
@ -41,7 +40,7 @@
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_match_global}" onclick="ruleInsertSign.match('[name=\'{$_tpl_name}[area]\']',{zimu:{$_tpl_match_global?1:0}})">{:cp_sign('match')}</a></div>
<div>
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_group_global}" onclick="ruleInsertSign.match('[name=\'{$_tpl_name}[area]\']',{group:1,zimu:{$_tpl_match_global?1:0}})">捕获组</a></div>
<div style="display:inline;"><a href="javascript:;" title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="ruleInsertSign.tips({$_tpl_match_global?1:''})"></a></div>
<div style="display:inline;"><a href="javascript:;" title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="ruleInsertSign.tips({$_tpl_match_global?1:''},{$_tpl_is_pagination?1:''})"></a></div>
</div>
</li>
<li data-module="xpath">xpath语法</li>
@ -57,7 +56,7 @@
</div>
<div class="form-group">
<label class="control-label">拼接成最终区域</label>
<div class="input-group c-p-url-page-signs" data-page-type="{$_tpl_page_type}" data-input-name="{$_tpl_name}[area_merge]">
<div class="input-group c-p-url-page-signs" data-page-type="{$_tpl_page_type}" data-input-name="{$_tpl_name}[area_merge]"{$_tpl_is_pagination?' data-is-pagination="1"':''}>
<textarea name="{$_tpl_name}[area_merge]" data-merge-type="area" placeholder="默认拼接区域规则中所有{:cp_sign('match')}标签,{$Think.lang.tips_matchn_area}" class="form-control" rows="2"></textarea>
{if $_tpl_match_global}
<div class="input-group-addon">
@ -102,7 +101,7 @@
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_match_global}" onclick="ruleInsertSign.match('[name=\'{$_tpl_name}[url_rule]\']',{zimu:{$_tpl_match_global?1:0}})">{:cp_sign('match')}</a></div>
<div>
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_group_global}" onclick="ruleInsertSign.match('[name=\'{$_tpl_name}[url_rule]\']',{group:1,zimu:{$_tpl_match_global?1:0}})">捕获组</a></div>
<div style="display:inline;"><a href="javascript:;" title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="ruleInsertSign.tips({$_tpl_match_global?1:''})"></a></div>
<div style="display:inline;"><a href="javascript:;" title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="ruleInsertSign.tips({$_tpl_match_global?1:''},{$_tpl_is_pagination?1:''})"></a></div>
</div>
</li>
<li data-module="xpath">xpath语法</li>
@ -118,7 +117,7 @@
</div>
<div class="form-group">
<label class="control-label">拼接成最终网址</label>
<div class="input-group c-p-url-page-signs" data-page-type="{$_tpl_page_type}" data-input-name="{$_tpl_name}[url_merge]">
<div class="input-group c-p-url-page-signs" data-page-type="{$_tpl_page_type}" data-input-name="{$_tpl_name}[url_merge]"{$_tpl_is_pagination?' data-is-pagination="1"':''}>
<input type="text" class="form-control" name="{$_tpl_name}[url_merge]" data-merge-type="url" placeholder="默认拼接网址规则中所有{:cp_sign('match')}标签,{$Think.lang.tips_matchn_url}" autocomplete="off" />
{if $_tpl_match_global}
<div class="input-group-addon">

202
vendor/skycaiji/app/admin/view/cpattern/set_page_url.html vendored

@ -0,0 +1,202 @@
{assign name="_tpl_page_type" value="[_page_type]" /}
{assign name="_tpl_is_pagination" value="[_is_pagination]" /}
{php}
$_tpl_vars=\util\Tools::cp_page_tpl_vars($_tpl_page_type);
$_tpl_id=$_tpl_vars['id'];
$_tpl_name=$_tpl_vars['name'];
$_tpl_title_page=$_tpl_vars['title'];
$_tpl_title=$_tpl_vars['title'];
if($_tpl_is_pagination){
$_tpl_id.='_pagination';
$_tpl_name.='[pagination]';
$_tpl_title='分页';
}
{/php}
{if $_tpl_is_pagination}
<div class="form-group">
<label class="control-label">使用“{$_tpl_title_page}»请求{$_tpl_title_page}网址”</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="{$_tpl_name}[use_url_web]" value="" checked="checked"> 默认:<span class="def-config-url-web-open"></span></label>
<label class="radio-inline"><input type="radio" name="{$_tpl_name}[use_url_web]" value="y"> </label>
<label class="radio-inline"><input type="radio" name="{$_tpl_name}[use_url_web]" value="n"> </label>
</div>
<p class="help-block">抓取{$_tpl_title_page}分页时发送请求,默认使用“{$_tpl_title_page}»请求{$_tpl_title_page}网址”的配置(受开启状态影响)会被“自定义请求{$_tpl_title}网址”中的选项修改</p>
</div>
{/if}
<div class="panel panel-default" id="panel_{$_tpl_id}_web">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#{$_tpl_id}_web" aria-expanded="false" class="collapsed">{$_tpl_is_pagination?'自定义':''}请求{$_tpl_title}网址</a>
</h4>
</div>
<div id="{$_tpl_id}_web" class="panel-collapse collapse" aria-expanded="false">
<div class="panel-body">
<div class="form-group" style="margin-bottom:0;">
<label class="control-label">自定义请求网址</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="{$_tpl_name}[url_web][open]" value="1"></label>
<label class="radio-inline"><input type="radio" name="{$_tpl_name}[url_web][open]" value="0" checked="checked"></label>
</div>
<p class="help-block">抓取{$_tpl_title}网址时使用自定义设置</p>
</div>
<div id="{$_tpl_id}_web_open" style="display:none;margin-top:15px;">
<div class="form-group">
<label class="control-label">网页编码</label>
<div class="input-group input-select-custom">
<div class="input-group-btn">
<select name="{$_tpl_name}[url_web][charset]" class="form-control">
<option value="" class="def-config-charset"></option>
<option value="auto">自动检测</option>
<option value="utf-8">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="{$_tpl_name}[url_web][charset_custom]">
</div>
<p class="help-block">默认使用采集器设置»网页编码中的配置</p>
</div>
<div class="form-group">
<label class="control-label">内容解压缩</label>
<div class="input-group input-select-custom">
<div class="input-group-btn">
<select name="{$_tpl_name}[url_web][encode]" class="form-control">
<option value="" class="def-config-encode"></option>
<option value="n">系统默认</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="{$_tpl_name}[url_web][encode_custom]">
</div>
<p class="help-block">默认使用采集器设置»内容解压缩中的配置</p>
</div>
<div class="form-group">
<label>请求方式</label>
<select name="{$_tpl_name}[url_web][form_method]" class="form-control">
<option value="">GET</option>
<option value="post">POST</option>
</select>
</div>
<div class="form-group c-p-url-web-content-type" style="display:none;">
<label>POST数据类型 <a href="javascript:;" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="tipsCurlPost()"></a></label>
<select name="{$_tpl_name}[url_web][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 class="control-label">发送数据 <a href="javascript:;" class="glyphicon glyphicon-plus add-url-web-form" title="添加"></a></label>
<div class="table-responsive c-p-url-web-form">
<table class="table table-bordered table-hover">
<thead>
<tr>
<td>名称</td>
<td></td>
<td>删除</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
{if $_tpl_is_pagination}
<p class="help-block">添加新的或者覆盖已有的数据</p>
{/if}
</div>
<div class="form-group">
<label>使用全局请求头</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="{$_tpl_name}[url_web][header_global]" value="" checked="checked"> 默认:<span class="def-config-request-headers-open"></span></label>
<label class="radio-inline"><input type="radio" name="{$_tpl_name}[url_web][header_global]" value="y"> </label>
<label class="radio-inline"><input type="radio" name="{$_tpl_name}[url_web][header_global]" value="n"> </label>
</div>
<p class="help-block">默认使用采集器设置»请求头信息»抓取页面中的配置(受全局开启状态影响)</p>
</div>
<div class="form-group">
<label class="control-label">请求头信息 <a href="javascript:;" class="glyphicon glyphicon-plus add-url-web-header" title="添加"></a></label>
<div class="table-responsive c-p-url-web-header">
<table class="table table-bordered table-hover">
<thead>
<tr>
<td>名称</td>
<td></td>
<td>删除</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<p class="help-block">添加新的或者覆盖已有的请求头信息</p>
</div>
</div>
</div>
</div>
</div>
{if $_tpl_is_pagination}
<div class="form-group">
<label class="control-label">使用“{$_tpl_title_page}»执行页面渲染”</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="{$_tpl_name}[use_renderer]" value="" checked="checked"> 默认:<span class="def-config-page-render"></span><span class="def-config-renderer-open" style="display:none;"></span></label>
<label class="radio-inline"><input type="radio" name="{$_tpl_name}[use_renderer]" value="y"> </label>
<label class="radio-inline"><input type="radio" name="{$_tpl_name}[use_renderer]" value="n"> </label>
</div>
<p class="help-block">抓取{$_tpl_title_page}分页时执行页面渲染,默认使用“{$_tpl_title_page}»执行页面渲染”的配置(受开启状态影响)会被“自定义执行页面渲染”中的选项修改</p>
</div>
{/if}
<div class="panel panel-default" id="panel_{$_tpl_id}_renderer">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#{$_tpl_id}_renderer" aria-expanded="false" class="collapsed">{$_tpl_is_pagination?'自定义':''}执行页面渲染</a>
</h4>
</div>
<div id="{$_tpl_id}_renderer" class="panel-collapse collapse" aria-expanded="false">
<div class="panel-body">
{if $_tpl_is_pagination}
<div class="form-group" style="margin-bottom:0;">
<label class="control-label">自定义页面渲染</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="{$_tpl_name}[renderer][open_pn]" value="1"> </label>
<label class="radio-inline"><input type="radio" name="{$_tpl_name}[renderer][open_pn]" value="" checked="checked"> </label>
</div>
</div>
<div id="{$_tpl_id}_renderer_open_pn" style="display:none;margin-top:15px;">
{/if}
<div class="form-group">
<label class="control-label">开启页面渲染</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="{$_tpl_name}[renderer][open]" value="" checked="checked"> 默认:<span class="def-config-page-render"></span></label>
<label class="radio-inline"><input type="radio" name="{$_tpl_name}[renderer][open]" value="y"> </label>
<label class="radio-inline"><input type="radio" name="{$_tpl_name}[renderer][open]" value="n"> </label>
</div>
<p class="help-block">默认:采集器设置»页面渲染的状态</p>
</div>
<div class="form-group">
<label class="control-label">
页面渲染动作
<a href="javascript:;" class="glyphicon glyphicon-plus add-url-renderer" title="添加"></a>
</label>
<div class="table-responsive c-p-url-renderer-list">
<table class="table table-hover">
<tbody>
</tbody>
</table>
</div>
{if $_tpl_is_pagination}
<p class="help-block">新增或追加渲染动作</p>
{/if}
</div>
{if $_tpl_is_pagination}
</div>
{/if}
</div>
</div>
</div>

25
vendor/skycaiji/app/admin/view/cpattern/set_pagination.html vendored

@ -37,24 +37,13 @@
<input type="number" class="form-control" name="{$_tpl_vars['name']}[pagination][max]" value="10">
<p class="help-block">填0表示不限制会自动循环抓取到最后一页,为防止出现无限循环的情况,最好设置一个数值以便采集到相应数量的分页后跳出循环抓取</p>
</div>
<div class="form-group">
<label class="control-label">使用“请求{$_tpl_vars['title']}网址”</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="{$_tpl_vars['name']}[pagination][use_url_web]" value="" checked="checked"> 默认:<span class="def-config-url-web-open"></span></label>
<label class="radio-inline"><input type="radio" name="{$_tpl_vars['name']}[pagination][use_url_web]" value="y"> </label>
<label class="radio-inline"><input type="radio" name="{$_tpl_vars['name']}[pagination][use_url_web]" value="n"> </label>
</div>
<p class="help-block">抓取{$_tpl_vars['title']}分页时发送请求,默认使用{$_tpl_vars['title']}»请求{$_tpl_vars['title']}网址的配置(受开启状态影响)</p>
</div>
<div class="form-group">
<label class="control-label">使用“执行页面渲染”</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="{$_tpl_vars['name']}[pagination][use_renderer]" value="" checked="checked"> 默认:<span class="def-config-page-render"></span><span class="def-config-renderer-open" style="display:none;"></span></label>
<label class="radio-inline"><input type="radio" name="{$_tpl_vars['name']}[pagination][use_renderer]" value="y"> </label>
<label class="radio-inline"><input type="radio" name="{$_tpl_vars['name']}[pagination][use_renderer]" value="n"> </label>
</div>
<p class="help-block">抓取{$_tpl_vars['title']}分页时执行页面渲染,默认使用{$_tpl_vars['title']}»执行页面渲染的配置(受开启状态影响)</p>
</div>
{if $_tpl_page_type=='source_url'}
{include file="cpattern:set_page_url" _page_type="source_url" _is_pagination="1" /}
{elseif $_tpl_page_type=='level_url' /}
{include file="cpattern:set_page_url" _page_type="level_url" _is_pagination="1" /}
{elseif $_tpl_page_type=='url' /}
{include file="cpattern:set_page_url" _page_type="url" _is_pagination="1" /}
{/if}
</div>
</div>
</div>

14
vendor/skycaiji/app/admin/view/cpattern/set_tpl.html vendored

@ -51,13 +51,13 @@
<td class="td-renderer-type" colspan="3">
<select class="form-control" data-name="[renderer][types][]">
<option value="">--请选择--</option>
<option value="wait_end">等待页面完全渲染</option>
<option value="wait_time">等待时间(秒)</option>
<option value="scroll_half">滚动到中间</option>
<option value="scroll_end">滚动到底部</option>
<option value="scroll_top">滚动到指定位置</option>
<option value="val">赋值</option>
<option value="click">点击</option>
<option value="wait_end">{$Think.lang.render_wait_end}</option>
<option value="wait_time">{$Think.lang.render_wait_time}</option>
<option value="scroll_half">{$Think.lang.render_scroll_half}</option>
<option value="scroll_end">{$Think.lang.render_scroll_end}</option>
<option value="scroll_top">{$Think.lang.render_scroll_top}</option>
<option value="val">{$Think.lang.render_val}</option>
<option value="click">{$Think.lang.render_click}</option>
</select>
</td>
<td class="td-renderer-element">

6
vendor/skycaiji/app/admin/view/cpattern/test_source_urls.html vendored

@ -27,14 +27,14 @@
<li>
[<a href="javascript:;" class="cont_ceshi" data-url="{$url|htmlspecialchars}">测试</a>]
[<a href="javascript:;" class="cont_element" data-url="{$url|htmlspecialchars}">分析</a>]
{$sourceUrlOpened}{$url|htmlspecialchars}
{$sourceUrlOpened}{$url|htmlspecialchars}{:\\util\\Tools::echo_url_msg_link($url)}
</li>
{/foreach}
{else /}
<li>
[<a href="javascript:;" class="cont_ceshi" data-url="{$urls|htmlspecialchars}">测试</a>]
[<a href="javascript:;" class="cont_element" data-url="{$urls|htmlspecialchars}">分析</a>]
{$sourceUrlOpened}{$urls|htmlspecialchars}
{$sourceUrlOpened}{$urls|htmlspecialchars}{:\\util\\Tools::echo_url_msg_link($urls)}
</li>
{/if}
</ul>
@ -43,7 +43,7 @@
{else /}
{foreach name="source_urls" item="source_url"}
<div class="source_url" data-url="{$source_url|htmlspecialchars}">
<p><b>抓取起始页面:</b>{$sourceUrlOpened}{$source_url|htmlspecialchars}</p>
<p><b>抓取起始页面:</b>{$sourceUrlOpened}{$source_url|htmlspecialchars}{:\\util\\Tools::echo_url_msg_link($source_url)}</p>
<p class="cont_urls_num"></p>
<div class="cont_urls_list">
</div>

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

@ -255,7 +255,17 @@
<div class="form-group">
<label>接口地址</label>
<input type="text" name="toapi[url]" class="form-control" />
<p class="help-block">/开头自动补全为{:config('root_website')}/</p>
<div class="help-block">
/开头自动补全为{:config('root_website')}/
<select id="toapi_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 class="form-group">
<label>网页编码</label>
@ -406,24 +416,24 @@
<tbody>
<tr>
<td>id(编号)</td>
<td><input type="text" name="toapi[response][id]" class="form-control" data-placeholder="记录入库的自增id或入库状态" autocomplete="off" /></td>
<td><input type="text" name="toapi[response][id]" class="form-control" data-placeholder="记录入库的自增id或入库状态" placeholder="记录入库的自增id或入库状态,默认:id" autocomplete="off" /></td>
</tr>
<tr>
<td>target(位置)</td>
<td><input type="text" name="toapi[response][target]" class="form-control" data-placeholder="记录入库的数据位置(发布的网址等)" autocomplete="off" /></td>
<td><input type="text" name="toapi[response][target]" class="form-control" data-placeholder="记录入库的数据位置(发布的网址等)" placeholder="记录入库的数据位置(发布的网址等),默认:target" autocomplete="off" /></td>
</tr>
<tr>
<td>desc(描述)</td>
<td><input type="text" name="toapi[response][desc]" class="form-control" data-placeholder="记录入库的数据位置附加信息" autocomplete="off" /></td>
<td><input type="text" name="toapi[response][desc]" class="form-control" data-placeholder="记录入库的数据位置附加信息" placeholder="记录入库的数据位置附加信息,默认:desc" autocomplete="off" /></td>
</tr>
<tr>
<td>error(错误)</td>
<td><input type="text" name="toapi[response][error]" class="form-control" data-placeholder="记录入库失败的错误信息" autocomplete="off" /></td>
<td><input type="text" name="toapi[response][error]" class="form-control" data-placeholder="记录入库失败的错误信息" placeholder="记录入库失败的错误信息,默认:error" autocomplete="off" /></td>
</tr>
<tr>
<td></td>
<td id="toapi_resp_module_help">
<p class="help-block" data-module="">直接输入键名,子节点用:a.b.c</p>
<p class="help-block" data-module="" style="display:block;">直接输入键名,子节点用:a.b.c</p>
<p class="help-block" data-module="xpath">使用xpath规则</p>
<p class="help-block" data-module="rule">
使用正则表达式

51
vendor/skycaiji/app/admin/view/setting/caiji.html vendored

@ -24,19 +24,42 @@
<label>采集运行模式</label>
<select name="server" class="form-control">
<option value="">web服务器(默认)</option>
<option value="cli">cli命令行(推荐)</option>
<option value="cli">cli命令行</option>
<option value="swoole">swoole</option>
</select>
<p class="help-block server-">使用web服务器运行采集,会受web服务器运行超时影响导致采集中断,需修改web服务器的超时时间</p>
<div class="server-cli" style="display:none;">
<p class="help-block server-" data-server="">使用web服务器运行采集,会受web服务器运行超时影响导致采集中断,需修改web服务器的超时时间</p>
<div data-server="cli" style="display:none;">
<p class="help-block">使用php cli命令行模式运行采集,自动采集、后台采集可以稳定运行,需要web服务器拥有执行命令的权限 <a href="https://www.skycaiji.com/manual/q/php%E6%89%A7%E8%A1%8C%E5%91%BD%E4%BB%A4%E6%9D%83%E9%99%90" target="_blank">了解权限</a></p>
<div class="input-group">
<span class="input-group-addon">PHP可执行文件</span>
<input type="text" name="server_php" class="form-control" value="{$caijiConfig['server_php']}" {$phpExeFile?('placeholder="默认:'.$phpExeFile.'"'):''} />
<input type="text" name="server_php" class="form-control" {$phpExeFile?('placeholder="默认:'.$phpExeFile.'"'):''} />
<div class="input-group-btn">
<button type="button" class="btn btn-default" id="btn_test_php">测试</button>
</div>
</div>
<p class="help-block">PHP可执行文件在服务器中的绝对路径或者在系统中的环境变量名称</p>
<p class="help-block" id="error_server_php" style="display:none;color:red;"></p>
</div>
<div data-server="swoole" style="display:none;">
<p class="help-block">使用swoole运行采集,自动采集、后台采集可以稳定运行,需要在服务器中安装swoole扩展并启动服务 <a href="https://www.skycaiji.com/manual/q/swoole" target="_blank">了解swoole</a></p>
<div class="input-group" style="margin-bottom:10px;">
<span class="input-group-addon">swoole服务地址</span>
<input type="text" name="swoole_host" class="form-control" placeholder="默认127.0.0.1" />
<span class="input-group-addon brl_0 brr_0">端口</span>
<input type="text" name="swoole_port" class="form-control" placeholder="默认9501" />
<div class="input-group-btn" id="test_swoole_restart" style="display:none;">
<button type="button" class="btn btn-default">重启</button>
</div>
</div>
<div class="input-group">
<span class="input-group-addon">swoole快捷启动</span>
<input type="text" name="swoole_php" class="form-control" placeholder="选填"/>
<div class="input-group-btn">
<button type="button" class="btn btn-default" id="btn_test_swoole_php">测试</button>
</div>
</div>
<p class="help-block">输入PHP可执行文件在服务器中的绝对路径或者在系统中的环境变量名称可自动启动swoole服务,留空则需要手动操作</p>
<p class="help-block" id="error_server_swoole" style="display:none;color:red;"></p>
</div>
</div>
<div class="form-group">
@ -56,9 +79,9 @@
<p class="help-block run-backstage">将在PHP后台开启一个持续进程用来运行采集,会占用一些服务器资源</p>
<p class="help-block run-visit" style="display:none;">
需在您的网站前端页面中加入一条html代码:<br/>
<em><b>&lt;script src="{:url('admin/index/caiji',null,false,true)}" async&gt;&lt;/script&gt;</b></em>
<em><b>&lt;script src="{:htmlspecialchars(url('admin/index/caiji',null,false,true))}" async&gt;&lt;/script&gt;</b></em>
<br/>添加后,用户访问页面时即可触发采集,您也可以触发指定任务:
<br/><em><b>&lt;script src="{:url('admin/index/caiji?task_ids=',null,false,true)}任务id多个逗号分隔" async&gt;&lt;/script&gt;</b></em>
<br/><em><b>&lt;script src="{:htmlspecialchars(url('admin/index/caiji?task_ids=',null,false,true))}任务id多个逗号分隔" async&gt;&lt;/script&gt;</b></em>
</p>
</div>
</div>
@ -69,37 +92,37 @@
<div class="panel-body">
<div class="form-group">
<label>最大进程数量</label>
<input type="number" name="process_num" class="form-control" value="{$caijiConfig['process_num']|intval}">
<input type="number" name="process_num" class="form-control" />
<p class="help-block">将采集任务平均分配到多个进程中同时运行,默认0:所有任务都在一个进程中依次运行</p>
</div>
<div class="form-group">
<label>{$Think.lang.set_caiji_num}</label>
<input type="number" name="num" class="form-control" value="{$caijiConfig['num']|intval}">
<input type="number" name="num" class="form-control" />
<p class="help-block">每次采集的数据总量,留空或0表示采完为止</p>
</div>
<div class="form-group">
<label>{$Think.lang.set_caiji_interval}(分钟)</label>
<input type="number" name="interval" class="form-control" value="{$caijiConfig['interval']|intval}">
<input type="number" name="interval" class="form-control" />
<p class="help-block">采集完毕隔多久再次运行,可轮询目标的数据更新且有效减轻服务器压力,强烈建议设置时间!留空或0表示不限制(采集量大会造成服务器过载)</p>
</div>
<div class="form-group">
<label>{$Think.lang.set_caiji_timeout}(分钟)</label>
<input type="number" name="timeout" class="form-control" value="{$caijiConfig['timeout']|intval}">
<input type="number" name="timeout" class="form-control" />
<p class="help-block">无论是否采集完毕,到达设置的时间则立刻终止采集,可防止采集太久造成服务器卡顿,留空或0表示不限制</p>
</div>
<div class="form-group">
<label>页面抓取间隔(毫秒,1000毫秒=1秒)</label>
<input type="number" name="interval_html" class="form-control" value="{$caijiConfig['interval_html']|intval}">
<input type="number" name="interval_html" class="form-control" />
<p class="help-block">可防止页面抓取频率太快造成目标网站响应超时或宕机,留空或0表示不限制</p>
</div>
<div class="form-group">
<label>失败等待(秒)</label>
<input type="number" name="wait" class="form-control" value="{$caijiConfig['wait']|intval}">
<input type="number" name="wait" class="form-control" />
<p class="help-block">抓取页面失败,等待一段时间再继续</p>
</div>
<div class="form-group">
<label>失败重试</label>
<input type="number" name="retry" class="form-control" value="{$caijiConfig['retry']|intval}">
<input type="number" name="retry" class="form-control" />
<p class="help-block">页面抓取失败重试次数,留空或0表示不重试</p>
</div>
<div class="form-group">
@ -146,7 +169,7 @@
</div>
<div class="form-group">
<label>网址重定向次数</label>
<input type="number" name="max_redirs" class="form-control" value="{$caijiConfig['max_redirs']|intval}">
<input type="number" name="max_redirs" class="form-control" />
<p class="help-block">最多允许网址重定向多少次,留空或0表示不限制</p>
</div>
</div>

47
vendor/skycaiji/app/admin/view/setting/download_file.html vendored

@ -105,50 +105,21 @@
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><a data-toggle="collapse" href="#panel_file_func" aria-expanded="false" class="collapsed">使用函数</a></h4>
<div class="panel-body">
<div class="form-group">
<label>使用函数</label>
<a href="javascript:;" class="glyphicon glyphicon-plus" id="add_file_func" title="添加"></a>
<div class="panel-group ui-sortable" id="file_funcs" style="margin-bottom:0;">
</div>
<p class="help-block">文件下载后使用函数</p>
</div>
</div>
<div class="panel-collapse collapse" id="panel_file_func">
<div class="panel-body" style="padding-top:5px;">
<p class="help-block">文件下载后使用函数</p>
<div class="form-group">
<label>函数名</label>
<div class="input-group">
<select name="file_func" class="form-control">
<option value="">不使用</option>
</select>
<div class="input-group-addon"><a href="javascript:;" onclick="tipsPluginFunc('downloadFile')">扩展函数</a></div>
</div>
</div>
<div class="form-group">
<label>传入参数</label>
<textarea name="file_func_param" rows="2" class="form-control" data-placeholder="默认传入[文件:文件名]"></textarea>
<div class="help-block">
一行一个值,可输入任何内容或
<div class="dropup dropup-file-params" style="display:inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
调用文件参数
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="javascript:;" data-val="[文件:文件名]">[文件:文件名](包含路径和名称)</a></li>
<li><a href="javascript:;" data-val="[文件:路径]">[文件:路径](保存的目录)</a></li>
<li><a href="javascript:;" data-val="[文件:名称]">[文件:名称](保存的名称)</a></li>
<li><a href="javascript:;" data-val="[文件:链接]">[文件:链接](保存后的链接)</a></li>
<li><a href="javascript:;" data-val="[文件:网址]">[文件:网址](文件源网址)</a></li>
</ul>
</div>
&nbsp;请按函数传参,否则运行出错!
</div>
</div>
</div>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-block">{$Think.lang.save}</button>
</div>
</form>
{include file="setting:download_file_func" func_tpl_id="file_tpl_func" func_list_id="file_funcs" /}
<script type="text/javascript">
settingClass.down_file_init({$fileConfig|json_encode});
</script>

49
vendor/skycaiji/app/admin/view/setting/download_file_func.html vendored

@ -0,0 +1,49 @@
<div id="[func_tpl_id]" style="display:none;">
<div class="panel panel-default" data-func-box="1">
<div class="panel-heading">
<div class="panel-title"
style="font-size: 14px; overflow: hidden; line-height: 20px;">
<a data-toggle="collapse" data-func-a="1" href="#"
data-parent="#[func_list_id]" aria-expanded="false" class="collapsed">使用函数</a>
<div style="float: right; font-size: 12px;">
<a href="javascript:;" data-func-move="1"
class="glyphicon icon-drag-move ui-sortable-handle" title="移动"></a>
<a href="javascript:;" data-func-remove="1"
class="glyphicon glyphicon-remove" title="删除"></a>
</div>
</div>
</div>
<div class="panel-collapse collapse" data-func-panel="1">
<div class="panel-body">
<div class="form-group">
<label>函数名</label> <select class="form-control" data-func-func="1">
<option value="">不使用</option>
</select>
</div>
<div class="form-group">
<label>传入参数</label>
<textarea rows="3" data-func-func-param="1" class="form-control"
data-placeholder="默认传入[文件:文件名]"></textarea>
<div class="help-block">
一行一个值,可输入任何内容或
<div class="dropup" style="display: inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false"> 调用文件参数 <span
class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="javascript:;" data-func-insert="[文件:文件名]">[文件:文件名](包含路径和名称)</a></li>
<li><a href="javascript:;" data-func-insert="[文件:路径]">[文件:路径](保存的目录)</a></li>
<li><a href="javascript:;" data-func-insert="[文件:名称]">[文件:名称](保存的名称)</a></li>
<li><a href="javascript:;" data-func-insert="[文件:链接]">[文件:链接](保存后的链接)</a></li>
<li><a href="javascript:;" data-func-insert="[文件:网址]">[文件:网址](文件源网址)</a></li>
</ul>
</div>
&nbsp;请按函数传参,否则运行出错!<a href="javascript:;"
onclick="pluginFuncOp.tips('downloadFile')">扩展函数</a>
</div>
</div>
</div>
</div>
</div>
</div>

47
vendor/skycaiji/app/admin/view/setting/download_img.html vendored

@ -143,50 +143,21 @@
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title"><a data-toggle="collapse" href="#panel_img_func" aria-expanded="false" class="collapsed">使用函数</a></h4>
<div class="panel-body">
<div class="form-group">
<label>使用函数</label>
<a href="javascript:;" class="glyphicon glyphicon-plus" id="add_img_func" title="添加"></a>
<div class="panel-group ui-sortable" id="img_funcs" style="margin-bottom:0;">
</div>
<p class="help-block">图片下载后使用函数</p>
</div>
</div>
<div class="panel-collapse collapse" id="panel_img_func">
<div class="panel-body" style="padding-top:5px;">
<p class="help-block">图片下载后使用函数</p>
<div class="form-group">
<label>函数名</label>
<div class="input-group">
<select name="img_func" class="form-control">
<option value="">不使用</option>
</select>
<div class="input-group-addon"><a href="javascript:;" onclick="tipsPluginFunc('downloadImg')">扩展函数</a></div>
</div>
</div>
<div class="form-group">
<label>传入参数</label>
<textarea name="img_func_param" rows="2" class="form-control" data-placeholder="默认传入[图片:文件名]"></textarea>
<div class="help-block">
一行一个值,可输入任何内容或
<div class="dropup dropup-img-params" style="display:inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
调用图片参数
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="javascript:;" data-val="[图片:文件名]">[图片:文件名](包含路径和名称)</a></li>
<li><a href="javascript:;" data-val="[图片:路径]">[图片:路径](保存的目录)</a></li>
<li><a href="javascript:;" data-val="[图片:名称]">[图片:名称](保存的名称)</a></li>
<li><a href="javascript:;" data-val="[图片:链接]">[图片:链接](保存后的链接)</a></li>
<li><a href="javascript:;" data-val="[图片:网址]">[图片:网址](图片源网址)</a></li>
</ul>
</div>
&nbsp;请按函数传参,否则运行出错!
</div>
</div>
</div>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary btn-block">{$Think.lang.save}</button>
</div>
</form>
{include file="setting:download_img_func" func_tpl_id="img_tpl_func" func_list_id="img_funcs" /}
<script type="text/javascript">
settingClass.down_img_init({$imgConfig|json_encode});
</script>

49
vendor/skycaiji/app/admin/view/setting/download_img_func.html vendored

@ -0,0 +1,49 @@
<div id="[func_tpl_id]" style="display:none;">
<div class="panel panel-default" data-func-box="1">
<div class="panel-heading">
<div class="panel-title"
style="font-size: 14px; overflow: hidden; line-height: 20px;">
<a data-toggle="collapse" data-func-a="1" href="#"
data-parent="#[func_list_id]" aria-expanded="false" class="collapsed">使用函数</a>
<div style="float: right; font-size: 12px;">
<a href="javascript:;" data-func-move="1"
class="glyphicon icon-drag-move ui-sortable-handle" title="移动"></a>
<a href="javascript:;" data-func-remove="1"
class="glyphicon glyphicon-remove" title="删除"></a>
</div>
</div>
</div>
<div class="panel-collapse collapse" data-func-panel="1">
<div class="panel-body">
<div class="form-group">
<label>函数名</label> <select class="form-control" data-func-func="1">
<option value="">不使用</option>
</select>
</div>
<div class="form-group">
<label>传入参数</label>
<textarea rows="3" data-func-func-param="1" class="form-control"
data-placeholder="默认传入[图片:文件名]"></textarea>
<div class="help-block">
一行一个值,可输入任何内容或
<div class="dropup" style="display: inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false"> 调用图片参数 <span
class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="javascript:;" data-func-insert="[图片:文件名]">[图片:文件名](包含路径和名称)</a></li>
<li><a href="javascript:;" data-func-insert="[图片:路径]">[图片:路径](保存的目录)</a></li>
<li><a href="javascript:;" data-func-insert="[图片:名称]">[图片:名称](保存的名称)</a></li>
<li><a href="javascript:;" data-func-insert="[图片:链接]">[图片:链接](保存后的链接)</a></li>
<li><a href="javascript:;" data-func-insert="[图片:网址]">[图片:网址](图片源网址)</a></li>
</ul>
</div>
&nbsp;请按函数传参,否则运行出错!<a href="javascript:;"
onclick="pluginFuncOp.tips('downloadImg')">扩展函数</a>
</div>
</div>
</div>
</div>
</div>
</div>

91
vendor/skycaiji/app/admin/view/task/save_form.html vendored

@ -55,6 +55,9 @@
<option value="1">循环采集(采集完后间隔一段时间再次运行)</option>
<option value="2">定时采集(指定时间运行采集)</option>
</select>
{if is_empty(g_sc_c('caiji','auto'))}
<p class="help-block" id="config_task_auto_tips" style="display:none;">需要全局<a href="{:url('setting/caiji')}" target="_blank">开启自动采集</a>该功能才会生效</p>
{/if}
</div>
<div class="form-group" id="config_task_timer" style="display:none;">
<input type="hidden" name="task_timer[month]" value="" />
@ -369,39 +372,22 @@
</div>
</div>
</div>
<div class="form-group">
<label>使用函数</label>
<div class="input-group">
<select name="config[img_func]" class="form-control" data-global="{$gConfig['img_func']}">
<option value="">全局设置:{$gConfig['img_func']?$gConfig['img_func']:'不使用'}</option>
<option value="n">不使用</option>
</select>
<div class="input-group-addon"><a href="javascript:;" onclick="tipsPluginFunc('downloadImg')">扩展函数</a></div>
</div>
</div>
<div id="config_img_func" style="display:none;">
<div class="form-group">
<label>传入参数</label>
<textarea name="config[img_func_param]" rows="2" class="form-control" data-placeholder="{$gConfig['img_func_param']?('全局设置:'.$gConfig['img_func_param']):'默认传入[图片:文件名]'}"></textarea>
<div class="help-block">
一行一个值,可输入任何内容或
<div class="dropup dropup-img-params" style="display:inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
调用图片参数
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="javascript:;" data-val="[图片:文件名]">[图片:文件名](包含路径和名称)</a></li>
<li><a href="javascript:;" data-val="[图片:路径]">[图片:路径](保存的目录)</a></li>
<li><a href="javascript:;" data-val="[图片:名称]">[图片:名称](保存的名称)</a></li>
<li><a href="javascript:;" data-val="[图片:链接]">[图片:链接](下载后的链接)</a></li>
<li><a href="javascript:;" data-val="[图片:网址]">[图片:网址](图片源网址)</a></li>
</ul>
</div>
&nbsp;请按函数传参,否则运行出错!
</div>
<div class="form-group">
<label>使用函数</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="config[img_funcs_open]" value="" checked="checked">
全局设置:{$gConfig['img_funcs']?('存在'.count($gConfig['img_funcs']).'个函数'):'无函数'}
</label>
<label class="radio-inline"><input type="radio" name="config[img_funcs_open]" value="y">自定义</label>
<label class="radio-inline"><input type="radio" name="config[img_funcs_open]" value="n">不使用</label>
</div>
</div>
<div class="form-group" id="config_img_funcs_open">
<label>添加函数</label>
<a href="javascript:;" class="glyphicon glyphicon-plus" id="add_config_img_func" title="添加"></a>
<div class="panel-group ui-sortable" id="config_img_funcs" style="margin-bottom:0;">
</div>
</div>
</div>
</div>
<div class="panel-body{$gConfig['download_file']?'':' box-not-enable'}" id="config_download_file" style="border-top:solid 1px #ddd;">
@ -517,36 +503,19 @@
<div class="form-group">
<label>使用函数</label>
<div class="input-group">
<select name="config[file_func]" class="form-control" data-global="{$gConfig['file_func']}">
<option value="">全局设置:{$gConfig['file_func']?$gConfig['file_func']:'不使用'}</option>
<option value="n">不使用</option>
</select>
<div class="input-group-addon"><a href="javascript:;" onclick="tipsPluginFunc('downloadFile')">扩展函数</a></div>
</div>
</div>
<div id="config_file_func" style="display:none;">
<div class="form-group">
<label>传入参数</label>
<textarea name="config[file_func_param]" rows="2" class="form-control" data-placeholder="{$gConfig['file_func_param']?('全局设置:'.$gConfig['file_func_param']):'默认传入[文件:文件名]'}"></textarea>
<div class="help-block">
一行一个值,可输入任何内容或
<div class="dropup dropup-file-params" style="display:inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
调用文件参数
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="javascript:;" data-val="[文件:文件名]">[文件:文件名](包含路径和名称)</a></li>
<li><a href="javascript:;" data-val="[文件:路径]">[文件:路径](保存的目录)</a></li>
<li><a href="javascript:;" data-val="[文件:名称]">[文件:名称](保存的名称)</a></li>
<li><a href="javascript:;" data-val="[文件:链接]">[文件:链接](下载后的链接)</a></li>
<li><a href="javascript:;" data-val="[文件:网址]">[文件:网址](文件源网址)</a></li>
</ul>
</div>
&nbsp;请按函数传参,否则运行出错!
</div>
<label class="radio-inline"><input type="radio" name="config[file_funcs_open]" value="" checked="checked">
全局设置:{$gConfig['file_funcs']?('存在'.count($gConfig['file_funcs']).'个函数'):'无函数'}
</label>
<label class="radio-inline"><input type="radio" name="config[file_funcs_open]" value="y">自定义</label>
<label class="radio-inline"><input type="radio" name="config[file_funcs_open]" value="n">不使用</label>
</div>
</div>
<div class="form-group" id="config_file_funcs_open">
<label>添加函数</label>
<a href="javascript:;" class="glyphicon glyphicon-plus" id="add_config_file_func" title="添加"></a>
<div class="panel-group ui-sortable" id="config_file_funcs" style="margin-bottom:0;">
</div>
</div>
</div>
</div>
</div>
@ -555,6 +524,10 @@
<button type="submit" class="btn btn-primary btn-block">{$Think.lang.save}</button>
</div>
</form>
{include file="setting:download_img_func" func_tpl_id="config_img_tpl_func" func_list_id="config_img_funcs" /}
{include file="setting:download_file_func" func_tpl_id="config_file_tpl_func" func_list_id="config_file_funcs" /}
{php}$nTaskData=is_array($taskData)?json_encode($taskData):'null';$nFieldList=is_array($fieldList)?json_encode($fieldList):'null';{/php}
<script src="__PUBLIC__/static/js/admin/task.js?{$Think.config.html_v}"></script>
<script type="text/javascript">

2
vendor/skycaiji/app/admin/view/user/add.html vendored

@ -35,7 +35,7 @@
<div class="form-group">
<label>{$Think.lang.verifycode}</label>
<div class="input-group">
<input type="text" name="verifycode" class="form-control" />
<input type="text" name="verifycode" class="form-control" autocomplete="off" />
<div class="input-group-btn"><img src="{:url('admin/index/verify')}" class="verify-img" onclick="refreshVerify(this)" onerror="verifyImgError()" /></div>
</div>
</div>

2
vendor/skycaiji/app/admin/view/user/edit.html vendored

@ -41,7 +41,7 @@
<div class="form-group">
<label>{$Think.lang.verifycode}</label>
<div class="input-group">
<input type="text" name="verifycode" class="form-control" />
<input type="text" name="verifycode" class="form-control" autocomplete="off" />
<div class="input-group-btn"><img src="{:url('admin/index/verify')}" class="verify-img" onclick="refreshVerify(this)" onerror="verifyImgError()" /></div>
</div>
</div>

2
vendor/skycaiji/app/command.php vendored

@ -10,5 +10,5 @@
*/
return [
'skycaiji\admin\command\Collect'
'skycaiji\admin\command\Collect'
];

2
vendor/skycaiji/app/common.php vendored

@ -10,7 +10,7 @@
*/
define('SKYCAIJI_VERSION', '2.5.5');
define('SKYCAIJI_VERSION', '2.6');
\think\Loader::addNamespace('plugin', realpath(SKYCAIJI_PATH.'plugin'));
\think\Loader::addNamespace('util',realpath(APP_PATH.'extend/util'));

116
vendor/skycaiji/app/common/command/SkycaijiCli.php vendored

@ -0,0 +1,116 @@
<?php
/*
|--------------------------------------------------------------------------
| SkyCaiji (蓝天采集器)
|--------------------------------------------------------------------------
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|--------------------------------------------------------------------------
| 使用协议 https://www.skycaiji.com/licenses
|--------------------------------------------------------------------------
*/
namespace skycaiji\common\command;
class SkycaijiCli{
protected $rootPath;
protected $swooleSocket;
public function __construct($rootPath){
$this->rootPath=$rootPath;
}
public function start(){
global $argv;
if($argv&&$argv[1]==='swoole'){
$this->start_swoole();
}else{
$this->start_cli();
}
}
public function start_swoole(){
$host=$this->getopt('--host');
$host=explode(':',$host);
if(!preg_match('/^\w+(\.\w+)+$/',$host[0])){
$host[0]='';
}
$host[0]=empty($host[0])?'127.0.0.1':$host[0];
$host[1]=intval($host[1]);
if(in_array($host[1],array(80,8080,443))){
$host[1]=0;
}
$host[1]=$host[1]>0?$host[1]:9501;
$this->swooleSocket=null;
$ws=new \Swoole\WebSocket\Server($host[0], $host[1]);
$processNum=$this->getopt('--process');
$processNum=max(0,intval($processNum));
$ws->set(array(
'daemonize'=>true,
'worker_num' => 5+$processNum,
));
define('CUR_SWOOLE_PROCESS', $processNum);
$ws->on('WorkerStart',function($ws,$worker_id){
define('SKYCAIJI_PATH', $this->rootPath.DIRECTORY_SEPARATOR);
define('VENDOR_PATH', SKYCAIJI_PATH.'vendor'.DIRECTORY_SEPARATOR);
define('APP_PATH', VENDOR_PATH.'skycaiji'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR);
define('RUNTIME_PATH', SKYCAIJI_PATH.'runtime'.DIRECTORY_SEPARATOR);
define('APP_NAMESPACE', 'skycaiji');
require VENDOR_PATH.'skycaiji'.DIRECTORY_SEPARATOR.'tp'.DIRECTORY_SEPARATOR.'base.php';
\think\App::initCommon();
$mconfig=new \skycaiji\common\model\Config();
$caijiConfig=$mconfig->getConfig('caiji','data');
$this->swooleSocket=new \util\SwooleSocket($caijiConfig['swoole_host'],$caijiConfig['swoole_port']);
});
$ws->on('Open',function($ws,$request){
$this->swooleSocket->wsOnOpen($ws,$request);
});
$ws->on('Message',function($ws,$frame){
$this->swooleSocket->wsOnMsg($ws,$frame);
});
$ws->on('Close',function($ws,$fd){
$this->swooleSocket->wsOnClose($ws,$fd);
});
$ws->start();
}
public function start_cli(){
define('SKYCAIJI_PATH', $this->rootPath.DIRECTORY_SEPARATOR);
define('VENDOR_PATH', SKYCAIJI_PATH.'vendor'.DIRECTORY_SEPARATOR);
define('APP_PATH', VENDOR_PATH.'skycaiji'.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR);
define('RUNTIME_PATH', SKYCAIJI_PATH.'runtime'.DIRECTORY_SEPARATOR);
define('APP_NAMESPACE', 'skycaiji');
require VENDOR_PATH.'skycaiji'.DIRECTORY_SEPARATOR.'tp'.DIRECTORY_SEPARATOR.'console.php';
}
protected function getopt($key){
global $argv;
$val='';
$hasKey=false;
foreach ($argv as $k=>$v){
if($hasKey){
if(strpos($v,'-')!==0){
$val=$v;
}
break;
}
if($v===$key){
$hasKey=true;
}
}
return $val;
}
}
?>

2
vendor/skycaiji/app/common/model/Config.php vendored

@ -65,7 +65,7 @@ class Config extends BaseModel {
}
/*缓存所有配置*/
public function cacheConfigList(){
static $arrKeys=array('caiji','download_img','download_file','page_render','proxy','translate','site','email');
static $arrKeys=array('admincp','caiji','download_img','download_file','page_render','proxy','translate','site','email');
$keyConfig='cache_config_all';
$configDbList=$this->column('*');

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

@ -52,6 +52,10 @@ class ChromeSocket{
public static function defaultPort($port){
$port=intval($port);
if(in_array($port,array(80,8080,443))){
$port=0;
}
$port=$port>0?$port:9222;
return $port;
}
@ -73,8 +77,6 @@ class ChromeSocket{
$return=array('error'=>'','info'=>'');
if(empty($port)){
$return['error']='请设置端口';
}elseif($port==80){
$return['error']='不能设置为80端口';
}elseif(!empty($options['user_data_dir'])&&!is_dir($options['user_data_dir'])){
$return['error']='用户配置目录不存在!';
@ -84,36 +86,33 @@ class ChromeSocket{
}
}else{
$hasProcOpen=function_exists('proc_open')?true:false;
if($isTest&&!$hasProcOpen){
$command=$filename;
if(empty($command)){
$return['error']='需开启proc_open函数';
$command='chrome';
}else{
$command=$filename;
if(empty($command)){
$command='chrome';
}else{
$command=\skycaiji\admin\model\Config::cli_safe_filename($command);
}
$command.=' --headless --proxy-server';
if(!empty($options['user_data_dir'])){
$command=sprintf('%s --user-data-dir=%s',$command,$options['user_data_dir']);
}
if($isTest){
$command=sprintf('%s',$command);
}else{
$command=sprintf('%s --remote-debugging-port=%s',$command,$port);
}
if(!$hasProcOpen){
$return['error']='请开启proc_open函数或者手动执行命令:'.$command;
}else{
$return['info']=\util\Tools::proc_open_exec_curl($command,$isTest?'all':true,10,$isTest?true:false);
}
$command=\skycaiji\admin\model\Config::cli_safe_filename($command);
}
$command.=' --headless --proxy-server';
if(!empty($options['user_data_dir'])){
$command=sprintf('%s --user-data-dir=%s',$command,$options['user_data_dir']);
}
if($isTest&&$hasProcOpen){
$command=sprintf('%s',$command);
}else{
$command=sprintf('%s --remote-debugging-port=%s',$command,$port);
}
if(!$hasProcOpen){
$return['error']='页面渲染需开启proc_open或在服务器中执行命令:'.$command;
}else{
$return['info']=\util\Tools::proc_open_exec_curl($command,$isTest?'all':true,10,$isTest?true:false);
}
}
return $return;
@ -135,7 +134,7 @@ class ChromeSocket{
$url=sprintf('ws://%s/devtools/page/%s',$this->address,$this->tabId);
}
$this->loadWebsocket();
\util\Tools::load_websocket();
$this->socket=new \WebSocket\Client($url,$options);
$this->socket->setTimeout(3);
}
@ -672,16 +671,6 @@ class ChromeSocket{
$this->send('Browser.close');
}
}
private function loadWebsocket(){
static $loaded;
if(!isset($loaded)){
$loaded=true;
\think\Loader::addNamespace('WebSocket',realpath(APP_PATH.'extend/websocket'));
}
}
}
?>

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

@ -303,17 +303,6 @@ class Funcs{
}
public static function close_session(){
static $closed=null;
if(!isset($closed)){
$closed=true;
if(session_status()!==PHP_SESSION_ACTIVE){
session_start();
}
session_write_close();
}
}
public static function url_params_charset($url,$params,$charset=null){
if($params&&is_array($params)){
@ -466,6 +455,22 @@ class Funcs{
}
return $suffix;
}
public static function url_auto_encode($url,$charset){
if($url){
$url=preg_replace_callback('/[^\x21-\x7E]+/',function($mstr)use($charset){
$mstr=$mstr[0];
if(!empty($charset)){
$mstr=self::convert_charset($mstr,'utf-8',$charset);
}
$mstr=rawurlencode($mstr);
return $mstr;
},$url);
}
return $url;
}
}
?>

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

@ -55,6 +55,16 @@ class Param{
return \skycaiji\admin\model\CacheModel::getInstance()->getCache('collect_auto_backstage_key', 'data');
}
public static function set_swoole_server_key(){
$key=\util\Funcs::uniqid('collect_swoole_server_key');
\skycaiji\admin\model\CacheModel::getInstance()->setCache('collect_swoole_server_key', $key);
return $key;
}
public static function get_swoole_server_key(){
return \skycaiji\admin\model\CacheModel::getInstance()->getCache('collect_swoole_server_key', 'data');
}
public static function set_proc_open_exec_key(){
$key=\util\Funcs::uniqid('proc_open_exec_key');
\skycaiji\admin\model\CacheModel::getInstance()->setCache('proc_open_exec_key', $key);
@ -125,6 +135,21 @@ class Param{
}
return $data;
}
public static function set_echo_url_msg($key,$data){
set_g_sc(['echo_url_msg_data',$key], $data);
}
public static function get_echo_url_msg($key){
$data=null;
if(empty($key)){
$data=g_sc('echo_url_msg_data');
}else{
$data=g_sc('echo_url_msg_data',$key);
self::set_echo_url_msg($key, null);
}
return $data;
}
}
?>

408
vendor/skycaiji/app/extend/util/SwooleSocket.php vendored

@ -0,0 +1,408 @@
<?php
/*
|--------------------------------------------------------------------------
| SkyCaiji (蓝天采集器)
|--------------------------------------------------------------------------
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|--------------------------------------------------------------------------
| 使用协议 https://www.skycaiji.com/licenses
|--------------------------------------------------------------------------
*/
namespace util;
class SwooleSocket{
protected $timeout=30;
protected $host;
protected $port;
protected $socket;
protected $startTime=0;
public function __construct($host,$port,$timeout=30,$options=array()){
$this->host=$this->defaultHost($host);
$this->port=$this->defaultPort($port);
$timeout=intval($timeout);
$this->timeout=$timeout<=0?30:$timeout;
}
public function server(){
$ws=new \Swoole\WebSocket\Server($this->host, $this->port);
$ws->set(array('daemonize'=>true));
return $ws;
}
public function websocket($headers=array(),$options=array()){
$this->startTime=time();
\util\Tools::cli_cache_config(true);
$headers=is_array($headers)?$headers:array();
$headers=array_change_key_case($headers,CASE_LOWER);
$options=is_array($options)?$options:array();
$options['timeout']=$options['timeout']>0?$options['timeout']:$this->timeout;
if(!empty($headers)){
$options['headers']=is_array($options['headers'])?$options['headers']:array();
$options['headers']=\util\Funcs::array_key_merge($options['headers'],$headers);
}
\util\Tools::load_websocket();
$this->socket=new \WebSocket\Client('ws://'.$this->getHostPort(),$options);
$this->socket->setTimeout(3);
}
public function cmdStr(){
$processNum=g_sc_c('caiji','process_num');
$processNum=intval($processNum);
$cmd='swoole --host '.$this->getHostPort();
if($processNum>0){
$cmd.=' --process '.$processNum;
}
return $cmd;
}
public function processNumChanged($process1,$process2){
$process1=max(0,intval($process1));
$process2=max(0,intval($process2));
return $process1==$process2?false:true;
}
public function websocketError(){
$error='';
$msg='请使用“swoole快捷启动”或在服务器命令行中执行:<b>php '.htmlspecialchars(config('root_path').DIRECTORY_SEPARATOR).'skycaiji '.htmlspecialchars($this->cmdStr()).'</b>';
try{
$this->websocket();
$data=$this->sendReceive('is_open');
if(empty($data)||empty($data['is_open'])){
$error='swoole服务未开启,'.$msg;
}
}catch (\Exception $ex){
$exMsg=$ex->getMessage();
$encode=mb_detect_encoding($exMsg, array('ASCII','UTF-8','GB2312','GBK','BIG5'));
$exMsg=\util\Funcs::convert_charset($exMsg,$encode,'utf-8');
$error='swoole错误:'.$exMsg.' '.$msg;
}
return $error;
}
public function send($method,$params=array(),$id=0){
\util\Tools::cli_cache_config(true);
$this->startTime=time();
if(empty($id)){
static $no=1;
$no++;
$id=$no;
}
$data=array(
'id'=>$id,
'method'=>$method,
'params'=>$params
);
$this->socket->send(json_encode($data));
return $data;
}
public function sendReceive($method,$params=array(),$id=0){
$data=$this->send($method,$params,$id);
$data=$this->receiveById($data['id']);
return $data;
}
public function receive(){
try {
$data=$this->socket->receive();
}catch (\Exception $ex){
$data=null;
}
return $data?json_decode($data,true):null;
}
public function receiveById($id,$returnAll=false){
$result=null;
$all=array();
while((time()-$this->startTime)<=$this->timeout){
$data=$this->receive();
if(!$data){
break;
}
if($data['id']==$id){
$result=$data;
break;
}
if($returnAll){
$all[]=$data;
}
}
if($returnAll){
return array('all'=>$all,'result'=>$result);
}else{
return $result;
}
}
public function getHostPort(){
return $this->host.':'.$this->port;
}
public function defaultHost($host){
if(!preg_match('/^\w+(\.\w+)+$/',$host)){
$host='';
}
$host=empty($host)?'127.0.0.1':$host;
return $host;
}
public function defaultPort($port){
$port=intval($port);
if(in_array($port,array(80,8080,443))){
$port=0;
}
$port=$port>0?$port:9501;
return $port;
}
public function startWs($server,$swoolePhp,$restart=false){
$error=$this->websocketError();
if($error){
if(model('Config')->server_is_swoole_php(true,$server,$swoolePhp)){
$sskey=\util\Param::set_swoole_server_key();
@get_html(url('admin/index/swoole_server?key='.$sskey,null,false,true),null,array('timeout'=>2));
}
}else{
if($restart){
$this->sendReceive('restart');
}
}
}
public function checkPhp($server,$swoolePhp,$allowPhpEmpty=false,$checkPhpM=false){
$return=return_result('');
$mconfig=model('Config');
if(empty($swoolePhp)){
if($allowPhpEmpty){
$return['success']=true;
}else{
$return['msg']='未设置php可执行文件';
}
}
if(!$return['success']){
if($mconfig->server_is_swoole_php(true,$server,$swoolePhp)){
if(!function_exists('proc_open')){
$return['msg']='需开启proc_open函数';
}else{
$phpResult=$mconfig->php_is_valid($swoolePhp,$checkPhpM);
if(empty($phpResult['success'])){
$return['msg']=$phpResult['msg'];
}else{
if($checkPhpM){
if(empty($phpResult['swoole'])){
$return['msg']='php未安装swoole模块';
}else{
$return['success']=true;
$return['v']=$phpResult['v'];
}
}else{
$return['success']=true;
$return['v']=$phpResult['v'];
}
}
}
}
}
if(!$return['success']&&$return['msg']){
$return['msg']='swoole快捷启动:'.$return['msg'];
}
return $return;
}
private function killProcess($pid, $sig, $wait = 0)
{
\Swoole\Process::kill($pid, $sig);
if ($wait) {
$start = time();
do {
if (!$this->isRunning($pid)) {
break;
}
sleep(10);
} while (time() < $start + $wait);
}
return $this->isRunning($pid);
}
private function isRunning($pid)
{
if (empty($pid)) {
return false;
}
$status=false;
try {
$status=\Swoole\Process::kill($pid, 0);
} catch (\Exception $e) {
$status=false;
}
return $status;
}
public function wsIsChange(){
\util\Tools::cli_cache_config();
\util\Tools::set_url_compatible();
\util\Tools::close_session();
$mconfig=new \skycaiji\admin\model\Config();
$caijiConfig=$mconfig->getConfig('caiji','data');
init_array($caijiConfig);
$version=$mconfig->getConfig('version','data');
if(version_compare(SKYCAIJI_VERSION, $version)!==0||$this->getHostPort()!=($this->defaultHost($caijiConfig['swoole_host']).':'.$this->defaultPort($caijiConfig['swoole_port']))){
return true;
}
return false;
}
protected $wsTimer;
public function wsOnOpen($ws,$request){
if(empty($this->wsTimer)){
$this->wsTimer=\Swoole\Timer::tick(60000,function()use($ws){
if($this->wsIsChange()){
$ws->shutdown();
}
});
}
}
public function wsOnClose($ws,$fd){
}
public function wsOnMsg($ws,$frame){
$data=$frame->data;
if($data){
$data=json_decode($data,true);
}
init_array($data);
if($this->wsIsChange()){
$ws->shutdown();
$data['shutdown']=1;
}else{
$method='ws_m_'.$data['method'];
if($method&&method_exists($this,$method)){
$data['ws']=1;
init_array($data['params']);
$data=$this->$method($data,$ws);
}
}
$data=json_encode($data);
$ws->push($frame->fd, $data);
}
protected function ws_m_is_open($data,$ws){
$data['is_open']=1;
return $data;
}
protected function ws_m_restart($data,$ws){
$mconfig=new \skycaiji\admin\model\Config();
$caijiConfig=$mconfig->getConfig('caiji','data');
if($this->processNumChanged(CUR_SWOOLE_PROCESS, $caijiConfig['process_num'])){
$ws->shutdown();
}else{
$ws>reboot();
}
return $data;
}
protected function ws_m_shutdown($data,$ws){
$ws->shutdown();
$data['shutdown']=1;
return $data;
}
protected function ws_m_php_ver($data,$ws){
$data['php_ver']=phpversion();
return $data;
}
protected function ws_m_collect_process($data,$ws){
$urlParams=$data['params']['url_params'];
if(!empty($urlParams)&&is_array($urlParams)){
$urlParams='&'.http_build_query($urlParams);
}else{
$urlParams='';
}
$rootUrl=\think\Config::get('root_website').'/index.php?s=';
$curUrl=$rootUrl.'/admin/index/collect_process'.$urlParams;
\think\Request::create($curUrl);
define('BIND_MODULE', "admin/index/collect_process");
\think\App::run()->send();
$data['collect_process']='end';
return $data;
}
protected function ws_m_auto_backstage($data,$ws){
$rootUrl=\think\Config::get('root_website').'/index.php?s=';
$curKey=\util\Param::get_auto_backstage_key();
do{
\skycaiji\admin\model\CacheModel::getInstance()->setCache('collect_backstage_time',time());
$autoBsKey=\util\Param::get_auto_backstage_key();
if(empty($curKey)||$curKey!=$autoBsKey){
$data['error']='密钥错误,请在后台运行';
return $data;
}
$mconfig=new \skycaiji\admin\model\Config();
$caijiConfig=$mconfig->getConfig('caiji','data');
init_array($caijiConfig);
if(!$mconfig->server_is_swoole(true,$caijiConfig['server'])){
$data['error']='不是swoole模式';
return $data;
}
if(empty($caijiConfig['auto'])){
$data['error']='未开启自动采集';
return $data;
}
if($caijiConfig['run']!='backstage'){
$data['error']='不是后台运行方式';
return $data;
}
\skycaiji\admin\model\Collector::collect_run_auto($rootUrl);
sleep(15);
}while(1==1);
$data['auto_backstage']='end';
return $data;
}
}
?>

112
vendor/skycaiji/app/extend/util/Tools.php vendored

@ -32,7 +32,9 @@ class Tools{
public static function set_url_compatible(){
\think\Url::root(config('root_url').'/index.php?s=');
define('URL_IS_COMPATIBLE', true);
if(!defined('URL_IS_COMPATIBLE')){
define('URL_IS_COMPATIBLE', true);
}
}
public static function load_data_config(){
@ -191,25 +193,45 @@ class Tools{
return $vars;
}
public static function cli_command_exec($paramStr){
if(config('cli_cache_config')){
$cacheConfig=\skycaiji\admin\model\CacheModel::getInstance()->getCache('cli_cache_config','data');
$cliConfig=array();
foreach (config('cli_cache_config') as $key){
$cliConfig[$key]=config($key);
public static function cli_cache_config($set=false){
if($set){
if(config('cli_cache_config')){
$cacheConfig=\skycaiji\admin\model\CacheModel::getInstance()->getCache('cli_cache_config','data');
$cliConfig=array();
foreach (config('cli_cache_config') as $key){
$cliConfig[$key]=config($key);
}
if(serialize($cacheConfig)!=serialize($cliConfig)){
\skycaiji\admin\model\CacheModel::getInstance()->setCache('cli_cache_config',$cliConfig);
}
}
if(serialize($cacheConfig)!=serialize($cliConfig)){
\skycaiji\admin\model\CacheModel::getInstance()->setCache('cli_cache_config',$cliConfig);
}else{
$cacheConfig=\skycaiji\admin\model\CacheModel::getInstance()->getCache('cli_cache_config','data');
if(is_array($cacheConfig)){
\think\Config::set($cacheConfig);
}
}
}
public static function cli_command_exec($paramStr){
self::cli_cache_config(true);
$commandStr=g_sc_c('caiji','server_php');
if(empty($commandStr)){
$commandStr='';
if(preg_match('/^\s*collect\b/i', $paramStr)){
$commandStr=g_sc_c('caiji','server_php');
if(empty($commandStr)){
$commandStr=\skycaiji\admin\model\Config::detect_php_exe();
}
}elseif(preg_match('/^\s*swoole\b/i', $paramStr)){
$commandStr=\skycaiji\admin\model\Config::detect_php_exe();
$commandStr=g_sc_c('caiji','swoole_php');
}
if(!empty($commandStr)){
$commandStr=\skycaiji\admin\model\Config::cli_safe_filename($commandStr);
@ -219,12 +241,11 @@ class Tools{
$commandStr.=' '.config('root_path').DIRECTORY_SEPARATOR.'skycaiji '.$paramStr;
\util\Funcs::close_session();
self::proc_open_exec($commandStr);
}
exit();
}
@ -660,5 +681,64 @@ class Tools{
return 'name="'.$name.'['.$namePre.$nameKey.']"';
}
}
public static function load_websocket(){
static $loaded;
if(!isset($loaded)){
$loaded=true;
\think\Loader::addNamespace('WebSocket',realpath(config('app_path').'/extend/websocket'));
}
}
public static function close_session(){
if(session_status()===PHP_SESSION_ACTIVE){
\think\Session::boot();
\think\Session::pause();
}
}
public static function echo_url_msg_id($url,$clearId=false){
static $reg='/\#(post_|render_|post_render_){1,}\w{32}$/i';
if($clearId){
$url=preg_replace($reg, '', $url);
return $url;
}else{
$id='';
if(preg_match($reg,$url,$mid)){
$id=$mid[0];
}
return $id;
}
}
public static function echo_url_msg_link($url,$returnArray=false){
$data=null;
if(strpos($url,'#')!==false){
$urlId=\util\Tools::echo_url_msg_id($url);
if($urlId){
$urlInfo=\util\Param::get_echo_url_msg($urlId);
if(!empty($urlInfo)){
$urlInfo=json_encode($urlInfo);
$data=array(
' <a href="javascript:;" onclick="window.parent.window.collectorEchoMsg.echo_url_msg(%s);">[查看信息]</a>',
$urlInfo
);
if(!$returnArray){
$data=vsprintf($data[0],htmlspecialchars($data[1],ENT_QUOTES));
}
}
}
}
return $data;
}
}
?>

90
vendor/skycaiji/app/extend/util/UnmaxPost.php vendored

@ -0,0 +1,90 @@
<?php
/*
|--------------------------------------------------------------------------
| SkyCaiji (蓝天采集器)
|--------------------------------------------------------------------------
| Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
|--------------------------------------------------------------------------
| 使用协议 https://www.skycaiji.com/licenses
|--------------------------------------------------------------------------
*/
namespace util;
class UnmaxPost extends \think\Request{
public $post;
public static function val($key = '', $default = null, $filter = ''){
if (0 === strpos($key, '?')) {
$key = substr($key, 1);
$has = true;
}
$method='post';
$request=self::instance();
if (isset($has)) {
return $request->has($key, $method, $default);
} else {
return $request->$method($key, $default, $filter);
}
}
public static function init_post_data($postName){
$postData=input('?'.$postName)?input($postName,'','trim'):'';
if(!is_empty($postData,true)){
$postData=explode('&',$postData);
$data=array();
foreach ($postData as $v){
$v=explode('=',$v,2);
$key=isset($v[0])?trim(urldecode($v[0])):'';
$val=isset($v[1])?$v[1]:'';
parse_str('data='.$val,$val);
$val=isset($val['data'])?$val['data']:'';
$isAutoArr=false;
if(preg_match('/\[\]$/', $key)){
$isAutoArr=true;
}
$key=str_replace('[', '|', $key);
$key=str_replace(']', '|', $key);
$key=trim($key,'|');
$key=preg_replace('/[\|]+/', '|', $key);
$key=explode('|', $key);
$keyData=&$data;
foreach ($key as $ki=>$kk){
$isArr=false;
if(($ki+1)<count($key)){
$isArr=true;
}else if($isAutoArr){
$isArr=true;
}
if($isArr){
if(!isset($keyData[$kk])||!is_array($keyData[$kk])){
$keyData[$kk]=array();
}
}else{
if(!isset($keyData[$kk])){
$keyData[$kk]='';
}
}
$keyData=&$keyData[$kk];
}
if($isAutoArr){
$keyData[]=$val;
}else{
$keyData=$val;
}
}
$request=self::instance();
$request->post=$data;
}
}
}
?>

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

2
vendor/skycaiji/app/public/think_exception.tpl vendored

@ -440,7 +440,7 @@
<?php } ?>
<div class="copyright">
<span><a href="https://www.skycaiji.com" style="color:#333;text-decoration:none;">蓝天采集器</a>使用框架tp5.0</span>
<span><a href="https://www.skycaiji.com" target="_blank" style="color:#333;text-decoration:none;">蓝天采集器</a></span>
</div>
<?php if(\think\App::$debug) { ?>
<script>

2
vendor/skycaiji/tp/base.php vendored

@ -9,7 +9,7 @@
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
define('THINK_VERSION', '5.0.24');
define('THINK_VERSION', '1.0 scj');//[修改]版本号
define('THINK_START_TIME', microtime(true));
define('THINK_START_MEM', memory_get_usage());
define('EXT', '.php');

Loading…
Cancel
Save