Browse Source

2.5.5

master v2.5.5
skycaiji 1 year ago
parent
commit
31bb709f1d
  1. 0
      data/files/index.html
  2. 0
      plugin/func/downloadFile/index.html
  3. 80
      plugin/skycaiji.php
  4. 22
      public/addon/adminlte/jquery-ui.min.js
  5. 17
      public/static/css/admin.css
  6. 26
      public/static/js/admin.js
  7. 7
      public/static/js/admin/code_editor.js
  8. 56
      public/static/js/admin/collector.js
  9. 7
      public/static/js/admin/release.js
  10. 7
      public/static/js/admin/setting.js
  11. 19
      public/static/js/admin/task.js
  12. 26
      public/static/js/jquery-ui.min.js
  13. 2
      public/static/js/langs/zh-cn.js
  14. 24
      vendor/skycaiji/app/admin/common.php
  15. 2
      vendor/skycaiji/app/admin/controller/Backstage.php
  16. 2
      vendor/skycaiji/app/admin/controller/CollectController.php
  17. 61
      vendor/skycaiji/app/admin/controller/Cpattern.php
  18. 33
      vendor/skycaiji/app/admin/controller/CpatternTest.php
  19. 49
      vendor/skycaiji/app/admin/controller/Develop.php
  20. 52
      vendor/skycaiji/app/admin/controller/Index.php
  21. 139
      vendor/skycaiji/app/admin/controller/Setting.php
  22. 171
      vendor/skycaiji/app/admin/controller/Task.php
  23. 182
      vendor/skycaiji/app/admin/event/Cpattern.php
  24. 32
      vendor/skycaiji/app/admin/event/CpatternBase.php
  25. 68
      vendor/skycaiji/app/admin/event/CpatternColl.php
  26. 133
      vendor/skycaiji/app/admin/event/CpatternEvent.php
  27. 2
      vendor/skycaiji/app/admin/event/Rcms.php
  28. 2
      vendor/skycaiji/app/admin/event/Rdb.php
  29. 2
      vendor/skycaiji/app/admin/event/Rdiy.php
  30. 453
      vendor/skycaiji/app/admin/event/ReleaseBase.php
  31. 4
      vendor/skycaiji/app/admin/event/Rfile.php
  32. 69
      vendor/skycaiji/app/admin/event/Rtoapi.php
  33. 18
      vendor/skycaiji/app/admin/lang/zh-cn.php
  34. 60
      vendor/skycaiji/app/admin/model/Collector.php
  35. 423
      vendor/skycaiji/app/admin/model/Config.php
  36. 11
      vendor/skycaiji/app/admin/model/FuncApp.php
  37. 100
      vendor/skycaiji/app/admin/model/Task.php
  38. 3
      vendor/skycaiji/app/admin/view/common/header_public.html
  39. 1
      vendor/skycaiji/app/admin/view/cpattern/front_url.html
  40. 1
      vendor/skycaiji/app/admin/view/cpattern/process.html
  41. 132
      vendor/skycaiji/app/admin/view/cpattern/process_module.html
  42. 56
      vendor/skycaiji/app/admin/view/cpattern/rule_module.html
  43. 72
      vendor/skycaiji/app/admin/view/cpattern/set.html
  44. 24
      vendor/skycaiji/app/admin/view/cpattern/set_page_rule.html
  45. 5
      vendor/skycaiji/app/admin/view/cpattern/set_tpl.html
  46. 10
      vendor/skycaiji/app/admin/view/develop/editor.html
  47. 29
      vendor/skycaiji/app/admin/view/develop/editor_code.html
  48. 11
      vendor/skycaiji/app/admin/view/develop/plugin_skycaiji_method.html
  49. 36
      vendor/skycaiji/app/admin/view/release/set.html
  50. 5
      vendor/skycaiji/app/admin/view/setting/caiji.html
  51. 1
      vendor/skycaiji/app/admin/view/setting/caiji_nav.html
  52. 155
      vendor/skycaiji/app/admin/view/setting/download_file.html
  53. 45
      vendor/skycaiji/app/admin/view/setting/download_img.html
  54. 2
      vendor/skycaiji/app/admin/view/setting/proxy.html
  55. 2
      vendor/skycaiji/app/admin/view/setting/translate.html
  56. 470
      vendor/skycaiji/app/admin/view/task/save_form.html
  57. 34
      vendor/skycaiji/app/common.php
  58. 6
      vendor/skycaiji/app/common/exception/CommonHandle.php
  59. 2
      vendor/skycaiji/app/common/model/Config.php
  60. 3
      vendor/skycaiji/app/extend/util/ChromeSocket.php
  61. 33
      vendor/skycaiji/app/extend/util/Curl.php
  62. 9
      vendor/skycaiji/app/extend/util/Funcs.php
  63. 17
      vendor/skycaiji/app/extend/util/Param.php
  64. 24
      vendor/skycaiji/app/extend/util/Tools.php
  65. 2
      vendor/skycaiji/app/extend/util/Translator.php
  66. 2
      vendor/skycaiji/app/install/data/check_db
  67. 2
      vendor/skycaiji/app/install/data/check_file
  68. 2
      vendor/skycaiji/app/install/event/LocSystem.php

0
data/files/index.html

0
plugin/func/downloadFile/index.html

80
plugin/skycaiji.php

@ -6,6 +6,51 @@ namespace plugin;
* 使用:\plugin\skycaiji::方法名(参数)
*/
class skycaiji{
/**
* 调试输出内容
* @param mixed $data 任何数据
* @param bool $goOn 继续运行,默认终止
*/
public static function output($data,$goOn=false){
$data=print_r($data,true);
$data='<p>调试输出内容'.($goOn?'':'并终止运行').':</p><textarea style="width:100%;margin:5px 0;" rows="'.($goOn?5:20).'">'.htmlspecialchars($data).'</textarea>';
\util\Tools::collect_output($data,'black',$goOn?false:true);
}
/**
* 请求网址
* @param string $url 网址
* @param mixed $post (bool)post模式 或者 (array)post数据
* @param string $charset 网页编码,默认自动识别
* @param array $headers 头信息
* @param array $options 选项:timeout超时秒数,curlopts附加curl的选项值
* @return array 返回数组:(bool)success抓取成功,(int)code页面状态码,(string)header头信息,(string)content页面内容,(array)error错误,(array)info资源信息
*/
public static function curl($url,$post=null,$charset=null,$headers=array(),$options=array()){
$charset=$charset?$charset:'auto';//默认auto自动识别
$options=is_array($options)?$options:array();
$options['timeout']=$options['timeout']?:30;//超时时间(秒)
$options['return_info']=$options['return_info']?:1;//返回curl句柄信息
$options['return_body']=$options['return_body']?:1;//返回非成功状态的页面内容
$options['curlopts']=is_array($options['curlopts'])?$options['curlopts']:array();//curl的选项值列表,以CURLOPT_XXX为键名
$data=get_html($url,$headers,$options,$charset,$post,true);
$data=is_array($data)?$data:array();
$data=array(
'success'=>$data['ok']?true:false,
'code'=>intval($data['code']),
'header'=>$data['header']?:'',
'content'=>$data['html']?:'',
'error'=>$data['error']?:array(),
'info'=>$data['info']?:array(),
);
return $data;
}
/**
* 数据库对象
* @return \think\db\Query
*/
public static function db(){
return db();
}
/**
* 蓝天采集器的根目录
* @param string $filename 附加的文件名称
@ -60,39 +105,4 @@ class skycaiji{
$url=isset($url)?$url:'';
return self::root_url('app/'.$url);
}
/**
* 请求网址
* @param string $url 网址
* @param mixed $post (bool)post模式 或者 (array)post数据
* @param string $charset 网页编码,默认自动识别
* @param array $headers 头信息
* @param array $options 选项:timeout超时秒数,curlopts附加curl的选项值
* @return array 返回数组:(bool)success抓取成功,(int)code页面状态码,(string)header头信息,(string)content页面内容,(array)error错误,(array)info资源信息
*/
public static function curl($url,$post=null,$charset=null,$headers=array(),$options=array()){
$charset=$charset?$charset:'auto';//默认auto自动识别
$options=is_array($options)?$options:array();
$options['timeout']=$options['timeout']?:30;//超时时间(秒)
$options['return_info']=$options['return_info']?:1;//返回curl句柄信息
$options['return_body']=$options['return_body']?:1;//返回非成功状态的页面内容
$options['curlopts']=is_array($options['curlopts'])?$options['curlopts']:array();//curl的选项值列表,以CURLOPT_XXX为键名
$data=get_html($url,$headers,$options,$charset,$post,true);
$data=is_array($data)?$data:array();
$data=array(
'success'=>$data['ok']?true:false,
'code'=>intval($data['code']),
'header'=>$data['header']?:'',
'content'=>$data['html']?:'',
'error'=>$data['error']?:array(),
'info'=>$data['info']?:array(),
);
return $data;
}
/**
* 数据库对象
* @return \think\db\Query
*/
public static function db(){
return db();
}
}

22
public/addon/adminlte/jquery-ui.min.js vendored

File diff suppressed because one or more lines are too long

17
public/static/css/admin.css

@ -57,7 +57,8 @@ div.in-line-mg{display:inline;margin-right:5px;}
.wrapper-not-enable .tab-content{background:#f1f1f1;opacity:0.7;}
.wrapper-not-enable .panel-collapse{background:#f1f1f1;opacity:0.7;}
.box-not-enable{background:#f1f1f1;opacity:0.7;}
.box-enable-wrapper{margin-top:15px;display:block;padding:5px 0 5px 15px;border-left:3px solid #eee;border-radius:3px;}
.box-not-enable .box-enable-wrapper{display:none;}
#confirm_right .cr-msg p:last-child{margin-bottom:0;}
@ -220,10 +221,10 @@ table.table thead .sorting_desc:after {
border-bottom:0;
}
/*请求头信息*/
.c-p-request-headers table,.c-p-request-headers-img table{margin-bottom:0}
.c-p-request-headers .delete-request-header,.c-p-request-headers-img .delete-request-header-img{margin-top:8px;}
.c-p-request-headers td:first-child,.c-p-request-headers-img td:first-child{width:200px;}
.c-p-request-headers td:last-child,.c-p-request-headers-img td:last-child{width:50px;text-align:center;}
.c-p-request-headers table,.c-p-request-headers-img table,.c-p-request-headers-file table{margin-bottom:0}
.c-p-request-headers .delete-request-header,.c-p-request-headers-img .delete-request-header-img,.c-p-request-headers-file .delete-request-header-file{margin-top:8px;}
.c-p-request-headers td:first-child,.c-p-request-headers-img td:first-child,.c-p-request-headers-file td:first-child{width:200px;}
.c-p-request-headers td:last-child,.c-p-request-headers-img td:last-child,.c-p-request-headers-file td:last-child{width:50px;text-align:center;}
/*内容标签*/
.c-p-url-content-signs{
width:auto;
@ -327,6 +328,7 @@ table.table thead .sorting_desc:after {
.p-m-api-table table,.p-m-api-header-table table{margin-bottom:0;}
.p-m-api-table td:first-child,.p-m-api-header-table td:first-child{width:200px;}
.p-m-api-table td:last-child,.p-m-api-header-table td:last-child{width:50px;text-align:center;}
.p-m-api-rule-module{display:none;}
.p-m-html-tags{}
.p-m-html-tags a{font-size:12px;font-weight:normal;cursor:pointer;margin-right:5px;}
@ -335,6 +337,8 @@ table.table thead .sorting_desc:after {
.p-m-if-val-func a.input-group-addon{border-left:0;}
.p-m-if-val-func .input-group-btn>select{border-left:0;width:auto;padding:0;padding-left:5px;text-align:center;}
.p-m-if-op{width:70px;padding:15px 0 0 8px!important;font-size:11px;}
.p-m-download-op{display:none;margin-top:15px;}
/*发布设置*/
.rele-db-error{margin-top:10px;color:red;font-weight:bold;}
.db-table-bind-params{padding:0;margin-bottom:0;border:0;}
@ -358,6 +362,8 @@ table.table thead .sorting_desc:after {
.toapi-param-table table,.toapi-header-table table{margin-bottom:0;}
.toapi-param-table td:first-child,.toapi-header-table td:first-child{width:200px;}
.toapi-param-table td:last-child,.toapi-header-table td:last-child{width:50px;text-align:center;}
#toapi_resp_module_help .help-block{display:none;margin:0;}
/*步骤条*/
.steps-bar{width:100%;overflow:hidden;color:#999;}
.steps-bar a{color:#999;}
@ -481,6 +487,7 @@ table.table thead .sorting_desc:after {
/*开发*/
.deve-editor-left{padding-right:0px;}
.deve-editor-right{padding-left:1px;}
.deve-editor-apps-nav{margin-bottom:0;}
.deve-editor-apps{padding-left:5px;list-style:none;}
.deve-editor-apps li{padding:2px 0;width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}

26
public/static/js/admin.js

@ -36,10 +36,10 @@ var rows=2;if(placeholder){var regLine=new RegExp("[\\r\\n]+",'g');var matchLine
if(rows>8){rows=8}
if(rows<2){rows=2}
paramObj.attr('placeholder',placeholder).attr('rows',rows)})}}
var setFuncVal=function(){funcObj.val(funcVal).trigger('change')};if(funcObj.attr('data-is-loaded')){setFuncVal()}else{if(params.cache&&window[winCacheName]){funcObj.attr('data-is-loaded',1).append(window[winCacheName]);setFuncVal()}else{ajaxOpen({type:'GET',dataType:'json',url:ulink('collector/plugin_func'),async:params.cache?false:!0,data:{module:params.module},success:function(data){if(funcObj.attr('data-is-loaded')){setFuncVal()}else{funcObj.attr('data-is-loaded',1);if(data.code==1){var html='';var apps=data.data;if(apps&&typeof(apps)=='object'){for(var app in apps){var appData=apps[app];appData=appData?appData:{};var methods=appData.methods;if(methods){html+='<optgroup label="'+htmlspecialchars(appData.name+'('+app+')')+'">';for(var m in methods){var mMethod=methods[m];mMethod=mMethod?mMethod:{};html+='<option value="'+app+':'+m+'" data-params="'+(mMethod.params?mMethod.params:'')+'" data-comment="'+(mMethod.comment?mMethod.comment:'')+'">'+m+':'+(mMethod.comment_cut?mMethod.comment_cut:'')+'</option>'}
var setFuncVal=function(){funcObj.val(funcVal).trigger('change')};if(funcObj.attr('data-is-loaded')){setFuncVal()}else{if(params.cache&&window[winCacheName]){funcObj.attr('data-is-loaded',1).append(window[winCacheName]);setFuncVal()}else{var funcUrl=ulink('collector/plugin_func?module=_module_',{'_module_':params.module});ajaxOpen({type:'GET',dataType:'json',url:funcUrl,async:params.cache?false:!0,success:function(data){if(funcObj.attr('data-is-loaded')){setFuncVal()}else{funcObj.attr('data-is-loaded',1);if(data.code==1){var html='';var apps=data.data;if(apps&&typeof(apps)=='object'){for(var app in apps){var appData=apps[app];appData=appData?appData:{};var methods=appData.methods;if(methods){html+='<optgroup label="'+htmlspecialchars(appData.name+'('+app+')')+'">';for(var m in methods){var mMethod=methods[m];mMethod=mMethod?mMethod:{};html+='<option value="'+app+':'+m+'" data-params="'+(mMethod.params?mMethod.params:'')+'" data-comment="'+(mMethod.comment?mMethod.comment:'')+'">'+m+':'+(mMethod.comment_cut?mMethod.comment_cut:'')+'</option>'}
html+='</optgroup>'}}}
funcObj.append(html);if(params.cache){window[winCacheName]=html}}}},error:function(xhr,status,error){funcObj.removeAttr('data-is-loaded');toastr.error('函数插件载入失败:'+status+' '+error)},complete:function(xhr,status){setFuncVal()}})}}}
function tipsPluginFunc(module){var tips='';if(module=='process'){tips='<p>如需扩展系统函数,请在根目录/data/config.php中添加配置:</p>'+"<p>'EXTEND_PROCESS_FUNC'=&gt;array('PHP函数名'=&gt;'描述')</p>"+'<p>如需扩展插件函数,可创建<a href="'+ulink('develop/func?module=process')+'" target="_blank">函数插件</a></p>'}else if(module=='processIf'){tips='<p>选择函数,取反可获取函数结果的相反值</p>'+'<p>默认将当前字段作为参数传入,如需传入多个参数,一行一个值,可输入任何内容或调用字段</p>'+'<p>请按函数传参,否则运行出错!</p>'+'<p>如需扩展系统函数,请在根目录/data/config.php中添加配置:</p>'+"<p>'EXTEND_PROCESS_IF'=&gt;array('PHP函数名'=&gt;'描述')</p>"+'<p>如需扩展插件函数,可创建<a href="'+ulink('develop/func?module=processIf')+'" target="_blank">函数插件</a></p>'}else if(module=='downloadImg'||module=='contentSign'){window.open(ulink('develop/func?module='+module));return!1}
funcObj.append(html);if(params.cache){window[winCacheName]=html}}}},error:function(xhr,status,error){funcObj.removeAttr('data-is-loaded');toastr.error('函数插件载入失败:'+status+' '+error+' <a href="'+funcUrl+'" target="_blank" style="color:#ddd;">查看详细</a>')},complete:function(xhr,status){setFuncVal()}})}}}
function tipsPluginFunc(module){var tips='';if(module=='process'){tips='<p>如需扩展系统函数,请在根目录/data/config.php中添加配置:</p>'+"<p>'EXTEND_PROCESS_FUNC'=&gt;array('PHP函数名'=&gt;'描述')</p>"+'<p>如需扩展插件函数,可创建<a href="'+ulink('develop/func?module=process')+'" target="_blank">函数插件</a></p>'}else if(module=='processIf'){tips='<p>选择函数,取反可获取函数结果的相反值</p>'+'<p>默认将当前字段作为参数传入,如需传入多个参数,一行一个值,可输入任何内容或调用字段</p>'+'<p>请按函数传参,否则运行出错!</p>'+'<p>如需扩展系统函数,请在根目录/data/config.php中添加配置:</p>'+"<p>'EXTEND_PROCESS_IF'=&gt;array('PHP函数名'=&gt;'描述')</p>"+'<p>如需扩展插件函数,可创建<a href="'+ulink('develop/func?module=processIf')+'" target="_blank">函数插件</a></p>'}else if(module=='downloadImg'||module=='downloadFile'||module=='contentSign'){window.open(ulink('develop/func?module='+module));return!1}
confirmRight({msg:tips,yes:'确定',width:500,textAlign:'left'})}
function tipsCurlPost(){var tips='<p>表单数据:模拟form表单输入的数据</p><p>表单上传:模拟form表单输入并上传的数据</p>'+'<p>JSON数组:以json格式发送数据,可在“发送数据”的“值”中直接输入json字符串。在“名称”中填入json数组键名,根节点名称使用###表示,子节点名称使用.分隔,例如:a.b.c</p>';confirmRight({msg:tips,yes:'确定',width:500,textAlign:'left'})}
function collectorWindow(title,uri,uriVals,options){options=options?options:{};options.backdrop_static=1;title=isNull(title)?'':title;title+='<div class="loading-sm" style="margin-left:5px;"></div>';window.win_collector_window_params={title:title,uri:uri,uriVals:uriVals,options:options};windowModal(title,ulink('admin/collector/echo_msg?op=run'),{lg:options.lg})}
@ -65,5 +65,21 @@ var taskIds=[];$('#win_bk_tasks_box_0').find('[id^="win_bk_collected_"]').each(f
var isVisible=$('#win_bk_tasks_box_0').is(':visible');var isEnd=!0;$('#win_bk_tasks_box_0').find('a[href^="#win_bk_collected_"]').each(function(){if(!$(this).attr('data-is-end')){isEnd=!1;return!1}});if(!isEnd&&isVisible){winBackstageTask.status_set_timeout=window.setTimeout(function(){winBackstageTask.status(!0)},3000)}else{window.clearTimeout(winBackstageTask.status_set_timeout)}}})}}};function ajax_check_userpwd(ajaxSet){var oldSuccess=ajaxSet.success;ajaxSet.success=function(data){if(data.data&&data.data._check_pwd_){if(data.msg){toastr.error(data.msg)}
var msg='<div style="text-align:left;"><div style="margin-bottom:8px;">该操作需要验证您的登录密码</div>'+'<input class="form-control" type="password" id="confirm_ipt_check_pwd" placeholder="登录密码" />'+'<div class="checkbox" style="margin-bottom:0;"><label><input type="checkbox" value="1" id="confirm_ipt_check_skip" > 1小时内不再验证</label></div></div>';confirmRight({closeAfterFunc:!0,yes:'确定',no:'取消',msg:msg},function(){var ajaxSetData=isNull(ajaxSet.data)?{}:ajaxSet.data;var checkPwd=$('#confirm_ipt_check_pwd').val();var checkSkip=$('#confirm_ipt_check_skip').is(':checked')?1:'';if(typeof(ajaxSetData)=='object'){ajaxSetData._check_pwd_=checkPwd;ajaxSetData._check_skip_=checkSkip}else{ajaxSetData=ajaxSetData?(ajaxSetData+'&'):'';ajaxSetData+='_check_pwd_='+encodeURIComponent(checkPwd);ajaxSetData+='&_check_skip_='+encodeURIComponent(checkSkip)}
ajaxSet.data=ajaxSetData;ajaxSet.success=oldSuccess;ajax_check_userpwd(ajaxSet)});$('body').on('keyup','#confirm_ipt_check_pwd',function(event){if(event.keyCode=="13"){$('#confirm_right .cr-btn-yes').trigger("click")}})}else{if(oldSuccess&&typeof(oldSuccess)=='function'){oldSuccess(data)}}};ajaxOpen(ajaxSet)}
function editorCodeIfr(ifrEle,options){options=isObject(options)?options:{};if(options.set_value!=null&&typeof(options.set_value)!='undefined'){$(document).ready(function(){$(ifrEle).attr('src','');$(ifrEle).attr('src',ulink('develop/editor_code'));$(ifrEle).off('load').bind('load',function(){if(options.set_value&&$(ifrEle)[0].contentWindow.set_editor_code){$(ifrEle)[0].contentWindow.set_editor_code(options.set_value)}})})}else if(options.get_value){var ifrEle=$(ifrEle)[0];var val='';if(ifrEle&&ifrEle.contentWindow.get_editor_code){val=ifrEle.contentWindow.get_editor_code()}
return val}}
function editorCodeIfr(ifrEle,options){options=isObject(options)?options:{};if(options.set_value!=null&&typeof(options.set_value)!='undefined'){$(document).ready(function(){$(ifrEle).attr('src','');$(ifrEle).attr('src',ulink('develop/editor_code'));$(ifrEle).off('load').bind('load',function(){if(options.set_value&&$(ifrEle)[0].contentWindow.editor_code_op){$(ifrEle)[0].contentWindow.editor_code_op.set(options.set_value)}})})}else if(options.get_value){var ifrEle=$(ifrEle)[0];var val='';if(ifrEle&&ifrEle.contentWindow.editor_code_op){val=ifrEle.contentWindow.editor_code_op.get()}
return val}}
var ruleInsertSign={match:function(toObj,options){if(!options){options={}}
var sign=window.tpl_lang.sign_match;var group='(?<nr{:id}>[\\s\\S]*?)';if(options.only){sign=sign.replace('{:id}','');var curVal=$(toObj).val();if(curVal.indexOf(sign)<0&&curVal.indexOf('(?<nr>')<0&&curVal.indexOf('(?<content>')<0){if(options.group){sign=group.replace('{:id}','')}
insertAtCaret($(toObj),sign)}else{toastr.error('存在'+sign+'或捕获组')}}else{var regSign=new RegExp(sign.replace('{:id}','(\\w*)').replace('[','\\[').replace(']','\\]'),'g');var regZimu=new RegExp("^([a-zA-Z]+)(\\d+)$",'i');var regP=new RegExp("\\(\\?<(?:content|nr)(\\w*)>",'g');var list=null;var max=0;var zm='';while((list=regSign.exec($(toObj).val()))!=null){var num=0;if(options.zimu){var zimu=regZimu.exec(list[1]);if(zimu){zm=zimu[1];num=parseInt(zimu[2])}}else{num=parseInt(list[1])}
if(num>max){max=num}}
list=null;while((list=regP.exec($(toObj).val()))!=null){var num=0;if(options.zimu){var zimu=regZimu.exec(list[1]);if(zimu){zm=zimu[1];num=parseInt(zimu[2])}}else{num=parseInt(list[1])}
if(num>max){max=num}}
if(options.group){sign=group}
var signId='';if(options.zimu){if(!zm){var ranNum=Math.ceil(Math.random()*25);zm=String.fromCharCode(('A').charCodeAt(0)+ranNum);ranNum=Math.ceil(Math.random()*25);zm+=String.fromCharCode(('a').charCodeAt(0)+ranNum)}
signId=zm+(max+1)}else{signId=max+1}
sign=sign.replace('{:id}',signId);insertAtCaret($(toObj),sign)}},matchN(fromObj,toObj,options){if(!options){options={}}
var sign=window.tpl_lang.sign_match;var rule='';if(fromObj){rule=$(fromObj).val()}else if(options.rule){rule=options.rule}
var reP=new RegExp("\\(\\?<(?:content|nr)(\\w*)>.*?\\)",'g');rule=rule.replace(reP,sign.replace('{:id}',"$1"));var regSign=new RegExp(sign.replace('{:id}','(\\w*)').replace('[','\\[').replace(']','\\]'),'g');var list=null;var hasSign=!1;var returnList=new Array();while((list=regSign.exec(rule))!=null){hasSign=!0;var each=list[0];if(!toObj){returnList.push(each)}else if($(toObj).is('select')){if($(toObj).find('option[value="'+each+'"]').length<=0){$(toObj).append('<option value="'+each+'">'+each+'</option>')}}else{if($(toObj).val().indexOf(each)<0){insertAtCaret($(toObj),each)}}}
if(!hasSign){if(options.def){sign=sign.replace('{:id}','');if(!toObj){returnList.push(sign)}else if($(toObj).is('select')){if($(toObj).find('option[value="'+sign+'"]').length<=0){$(toObj).append('<option value="'+sign+'">'+sign+'</option>')}}else{if($(toObj).val().indexOf(sign)<0){insertAtCaret($(toObj),sign)}}}}
if(!toObj){return returnList}},wildcard:function(toObj,options){if(!options){options={}}
var wildcard=window.tpl_lang.sign_wildcard;if(options.only){if($(toObj).val().indexOf(wildcard)<0){insertAtCaret($(toObj),wildcard)}}else{insertAtCaret($(toObj),wildcard)}},tips:function(isPage){var tips='<p>1、规则中的特殊字符:<b>^$.*+|?[]{}()</b> 必须加上“\\”才能转义为字符,否则会识别为正则符号</p><p>2、[内容]标签的标识可由数字、字母及下划线组成</p>';if(isPage){tips+='<p>3、页面级别:多级页 &gt; 多级页子页 &gt; 内容页 &gt; 关联页 &gt; 关联页子页</p>';tips+='<p>4、[内容]标签可全局调用,但只能调用比自己级别高的页面中的标签,即内容页可调用多级页中的标签而不能调用关联页中的标签</p>';tips+='<p>5、同一页面中有相同标识的[内容]标签时,后面的标签会覆盖前面的同名标签。不同页面中有相同标识的[内容]标签时,低级别页面会覆盖高级别页面中的同名标签</p>'}
confirmRight({msg:tips,yes:'确定',width:500,textAlign:'left'})}}

7
public/static/js/admin/code_editor.js

@ -8,6 +8,9 @@
|--------------------------------------------------------------------------
*/
'use strict';function CodeEditorClass(){}
CodeEditorClass.prototype={constructor:CodeEditorClass,init_deve:function(config){var $_o=this;config=config?config:{};$('#btn_editor_save').bind('click',function(){ajax_check_userpwd({type:'POST',dataType:'json',url:ulink('develop/editor_save'),data:{type:config.type,module:config.module,app:config.app,appcode:$_o.editor_get_value()},beforeSend:function(){$('#btn_editor_save').attr('disabled',!0)},success:function(data){ajaxDataMsg(data)},complete:function(){$('#btn_editor_save').removeAttr('disabled')}})});var editorHeight=$(document.body).height()-$('#deve_editor_main').offset().top;editorHeight=parseInt(editorHeight)-60;$('#code_editor_box').height(editorHeight);$_o.editor_iframe($('#code_editor_txt').val());var appsScroll=!1;var deveAppsNav=$('#deve_editor_main .deve-editor-apps-nav');if(deveAppsNav.height()>editorHeight){appsScroll=!0;deveAppsNav.css('overflow-y','scroll')}
deveAppsNav.css('height',editorHeight+'px');if(appsScroll){var curApp=$('.deve-editor-apps .cur');if(curApp.length>0){var curAppTop=curApp.offset().top-deveAppsNav.offset().top;if(curAppTop>editorHeight){deveAppsNav.scrollTop(curAppTop-(editorHeight/2)-20)}}}},editor_iframe:function(appcode){var $_o=this;$('#code_editor_ifr').attr('src',ulink('develop/editor_code'));$('#code_editor_ifr').off('load').bind('load',function(){$_o.editor_set_value(appcode)})},editor_get_value:function(){return $('#code_editor_ifr')[0].contentWindow.get_editor_code()},editor_set_value:function(val){$('#code_editor_ifr')[0].contentWindow.set_editor_code(val)}}
CodeEditorClass.prototype={constructor:CodeEditorClass,init_deve:function(config){var $_o=this;config=config?config:{};$('#btn_editor_save').bind('click',function(){ajax_check_userpwd({type:'POST',dataType:'json',url:ulink('develop/editor_save'),data:{type:config.type,module:config.module,app:config.app,appcode:$_o.editor_get_value()},beforeSend:function(){$('#btn_editor_save').attr('disabled',!0)},success:function(data){if(data){data.url=''}
ajaxDataMsg(data)},complete:function(){$('#btn_editor_save').removeAttr('disabled')}})});var editorHeight=$(document.body).height()-$('#deve_editor_main').offset().top;editorHeight=parseInt(editorHeight)-60;$('#code_editor_box').height(editorHeight);$_o.editor_iframe($('#code_editor_txt').val());var appsScroll=!1;var deveAppsNav=$('#deve_editor_main .deve-editor-apps-nav');if(deveAppsNav.height()>editorHeight){appsScroll=!0;deveAppsNav.css('overflow-y','scroll')}
deveAppsNav.css('height',editorHeight+'px');if(appsScroll){var curApp=$('.deve-editor-apps .cur');if(curApp.length>0){var curAppTop=curApp.offset().top-deveAppsNav.offset().top;if(curAppTop>editorHeight){deveAppsNav.scrollTop(curAppTop-(editorHeight/2)-20)}}}
$('#plugin_skycaiji_ul').on('click','a[data-scj-method]',function(){var method=$(this).attr('data-scj-method');windowModal('方法:\\plugin\\skycaiji::'+method+'()',ulink('develop/plugin_skycaiji?op=method&method=_method_',{'_method_':method}),{lg:1,'full_height':1})});ajaxOpen({type:'GET',dataType:'json',url:ulink('develop/plugin_skycaiji'),async:!0,success:function(data){data=data.data;var html='';for(var i in data){html+='<li><a href="javascript:;" data-scj-method="'+i+'"><b>\\plugin\\skycaiji::'+i+'()</b><br>'+data[i]+'</a></li>'}
$('#plugin_skycaiji_ul').html(html)}})},editor_iframe:function(appcode){var $_o=this;$('#code_editor_ifr').attr('src',ulink('develop/editor_code'));$('#code_editor_ifr').off('load').bind('load',function(){$_o.editor_set_value(appcode);$('#code_editor_ifr')[0].contentWindow.editor_code_op.ctrl_s(function(){$('#btn_editor_save').trigger('click')})})},editor_get_value:function(){return $('#code_editor_ifr')[0].contentWindow.editor_code_op.get()},editor_set_value:function(val){$('#code_editor_ifr')[0].contentWindow.editor_code_op.set(val)}}
var codeEditorClass=new CodeEditorClass()

56
public/static/js/admin/collector.js

@ -8,9 +8,9 @@
|--------------------------------------------------------------------------
*/
'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+' .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.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}}}
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?field=_field_",{'_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?type=common");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);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)}}
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)}}
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)}
@ -24,11 +24,13 @@ showPanelCollapse('#coll_pattern_relation_url')}
if(config.field_list&&config.field_list.length>0){this.cpField.clearall();for(var i in config.field_list){var fieldProcess=null;if(config.field_process){fieldProcess=config.field_process[i]}
this.cpField.add(null,config.field_list[i],fieldProcess)}}
if(config.field_title){$(this.formid+' [name="config[field_title]"]').each(function(){if($(this).val()==config.field_title){$(this).prop('checked',!0)}})}
if(config.common_process&&config.common_process.length>0){showPanelCollapse('#coll_pattern_process');ajaxOpen({type:'post',url:ulink("cpattern/process?type=common&op=load"),data:{process:config.common_process},dataType:'html',beforeSend:function(){$($_o.cpProcess.processForm+' .c-p-process-accordion').append('<div class="loading" style="margin:5px 0 0 -5px;"></div>')},success:function(data){$('body').append(data)},complete:function(){$($_o.cpProcess.processForm+' .c-p-process-accordion').find('.loading').remove()}})}
if(config.common_process&&config.common_process.length>0){showPanelCollapse('#coll_pattern_process');ajaxOpen({type:'post',url:ulink("cpattern/process?task_id=_tid_&type=common&op=load",{'_tid_':$_o.get_task_id()}),data:{process:config.common_process},dataType:'html',beforeSend:function(){$($_o.cpProcess.processForm+' .c-p-process-accordion').append('<div class="loading" style="margin:5px 0 0 -5px;"></div>')},success:function(data){$('body').append(data)},complete:function(){$($_o.cpProcess.processForm+' .c-p-process-accordion').find('.loading').remove()}})}
if(config.request_headers){$(this.formid+' [name="config[request_headers][useragent]"]').val(config.request_headers.useragent);$(this.formid+' [name="config[request_headers][cookie]"]').val(config.request_headers.cookie);$(this.formid+' [name="config[request_headers][referer]"]').val(config.request_headers.referer);if(config.request_headers.custom_names){var r_h_vals=config.request_headers.custom_vals?config.request_headers.custom_vals:{};for(var i in config.request_headers.custom_names){$_o.add_request_header(config.request_headers.custom_names[i],r_h_vals[i])}}
config.request_headers.open=toInt(config.request_headers.open);config.request_headers.img=toInt(config.request_headers.img);$(this.formid+' [name="config[request_headers][open]"][value="'+config.request_headers.open+'"]').prop('checked',!0).trigger('click');$(this.formid+' [name="config[request_headers][img]"][value="'+config.request_headers.img+'"]').prop('checked',!0);$(this.formid+' [name="config[request_headers][img_use_page]"][value="'+config.request_headers.img_use_page+'"]').prop('checked',!0);if(config.request_headers.open>0){showPanelCollapse('#coll_pattern_request_headers');showPanelCollapse('#c_p_request_headers_open')}
config.request_headers.open=toInt(config.request_headers.open);config.request_headers.img=toInt(config.request_headers.img);config.request_headers.file=toInt(config.request_headers.file);$(this.formid+' [name="config[request_headers][open]"][value="'+config.request_headers.open+'"]').prop('checked',!0).trigger('click');$(this.formid+' [name="config[request_headers][img]"][value="'+config.request_headers.img+'"]').prop('checked',!0);$(this.formid+' [name="config[request_headers][img_use_page]"][value="'+config.request_headers.img_use_page+'"]').prop('checked',!0);$(this.formid+' [name="config[request_headers][file]"][value="'+config.request_headers.file+'"]').prop('checked',!0);$(this.formid+' [name="config[request_headers][file_use_page]"][value="'+config.request_headers.file_use_page+'"]').prop('checked',!0);if(config.request_headers.open>0){showPanelCollapse('#coll_pattern_request_headers');showPanelCollapse('#c_p_request_headers_open')}
if(config.request_headers.img>0){showPanelCollapse('#coll_pattern_request_headers');showPanelCollapse('#c_p_request_headers_img')}
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.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'}
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])}
@ -55,14 +57,14 @@ $('#myModal').modal('hide')}}else{toastr.error(data.msg)}},error:function(data){
if(!$_o.source_is_url()){options+='<option value="source_url">起始页</option>';var level_urls=new Array();$('#c_p_level_urls [id^="level_url_"]').each(function(){var levelName=$(this).find('.name').attr('data-val');level_urls.push('<option value="level_url:'+levelName+'">多级页:'+levelName+'</option>')});if(level_urls.length>0){options+=level_urls.join('')}}
options+='<option value="'+(setOptUrlVal?'url':'')+'" selected="selected">内容页</option>';var relation_urls=new Array();$('#c_p_relation_urls [id^="relation_url_"]').each(function(){var relationName=$(this).find('.name').attr('data-val');relation_urls.push('<option value="relation_url:'+relationName+'">关联页:'+relationName+'</option>')});if(relation_urls.length>0){options+=relation_urls.join('')}
return options},field_delete_tr:function(subEle){$(subEle).parents('tr[id^="field_"]').eq(0).remove()},field_editor:function(subEle,hiddenFunc){var field=null;var objid=null;var title='添加字段';if(subEle){objid=$(subEle).parents('tr[id^="field_"]').eq(0).attr('id');if(objid){field=$('#'+objid).find('input[name="config[field_list][]"]').val();title='编辑字段'}}
var options={hidden_func:hiddenFunc};options.ajax={type:'post',data:{objid:objid,field:field}};windowModal(title,ulink('cpattern/field'),options)},process_paste:function(){var $_o=this;$('body').off('click','#window_process_paste').on('click','#window_process_paste',function(){ajaxOpen({type:'get',dataType:'json',url:ulink('cpattern/clone_process?op=paste'),success:function(data){if(data.code==1){$_o.cpProcess.add(data.data);toastr.success(data.msg)}else{toastr.error(data.msg)}}})})},add_request_header:function(name,val){var $_o=this;name=name?name:'';val=val?val:'';var tr=$_o.clone_tpl('#coll_tpl_request_headers');tr.find('[name="config[request_headers][custom_names][]"]').val(name);tr.find('[name="config[request_headers][custom_vals][]"]').val(val);$($_o.formid+' #coll_pattern_request_headers .c-p-request-headers tbody').append(tr)},add_request_header_img:function(name,val){var $_o=this;name=name?name:'';val=val?val:'';var tr=$_o.clone_tpl('#coll_tpl_request_headers_img');tr.find('[name="config[request_headers][img_names][]"]').val(name);tr.find('[name="config[request_headers][img_vals][]"]').val(val);$($_o.formid+' #coll_pattern_request_headers .c-p-request-headers-img tbody').append(tr)},get_field_names:function(sortField){var fields=new Array();var trs=$(this.formid+' #coll_pattern_field .c-p-field-list').find('tr[id^="field_"]');if(sortField){var fieldsNormal=new Array();var fieldsExtract=new Array();var fieldsMerge=new Array();trs.each(function(){var fmodule=$(this).find('.field-module').attr('data-val');var fname=$(this).find('.field-name').attr('data-val');if(fname){if(fmodule=='extract'){fieldsExtract.push(fname)}else if(fmodule=='merge'){fieldsMerge.push(fname)}else{fieldsNormal.push(fname)}}});for(var i in fieldsNormal){fields.push(fieldsNormal[i])}
var options={hidden_func:hiddenFunc};options.ajax={type:'post',data:{objid:objid,field:field}};windowModal(title,ulink('cpattern/field'),options)},process_paste:function(){var $_o=this;$('body').off('click','#window_process_paste').on('click','#window_process_paste',function(){ajaxOpen({type:'get',dataType:'json',url:ulink('cpattern/clone_process?op=paste'),success:function(data){if(data.code==1){$_o.cpProcess.add(data.data);toastr.success(data.msg)}else{toastr.error(data.msg)}}})})},add_request_header:function(name,val){var $_o=this;name=name?name:'';val=val?val:'';var tr=$_o.clone_tpl('#coll_tpl_request_headers');tr.find('[name="config[request_headers][custom_names][]"]').val(name);tr.find('[name="config[request_headers][custom_vals][]"]').val(val);$($_o.formid+' #coll_pattern_request_headers .c-p-request-headers tbody').append(tr)},add_request_header_img:function(name,val){var $_o=this;name=name?name:'';val=val?val:'';var tr=$_o.clone_tpl('#coll_tpl_request_headers_img');tr.find('[name="config[request_headers][img_names][]"]').val(name);tr.find('[name="config[request_headers][img_vals][]"]').val(val);$($_o.formid+' #coll_pattern_request_headers .c-p-request-headers-img tbody').append(tr)},add_request_header_file:function(name,val){var $_o=this;name=name?name:'';val=val?val:'';var tr=$_o.clone_tpl('#coll_tpl_request_headers_file');tr.find('[name="config[request_headers][file_names][]"]').val(name);tr.find('[name="config[request_headers][file_vals][]"]').val(val);$($_o.formid+' #coll_pattern_request_headers .c-p-request-headers-file tbody').append(tr)},get_field_names:function(sortField){var fields=new Array();var trs=$(this.formid+' #coll_pattern_field .c-p-field-list').find('tr[id^="field_"]');if(sortField){var fieldsNormal=new Array();var fieldsExtract=new Array();var fieldsMerge=new Array();trs.each(function(){var fmodule=$(this).find('.field-module').attr('data-val');var fname=$(this).find('.field-name').attr('data-val');if(fname){if(fmodule=='extract'){fieldsExtract.push(fname)}else if(fmodule=='merge'){fieldsMerge.push(fname)}else{fieldsNormal.push(fname)}}});for(var i in fieldsNormal){fields.push(fieldsNormal[i])}
for(var i in fieldsExtract){fields.push(fieldsExtract[i])}
for(var i in fieldsMerge){fields.push(fieldsMerge[i])}}else{trs.each(function(){var fname=$(this).find('.field-name').attr('data-val');if(fname){fields.push(fname)}})}
return fields},rule_module_slt:function(curObj){curObj=$(curObj);var module=curObj.val();if(curObj.attr('data-module-input')){var ipt=$('[name="'+curObj.attr('data-module-input')+'"]');ipt.attr('data-val-'+module,ipt.val())}
curObj.off('change').on('change',function(){var obj=$(this);var name=obj.attr('name');var changeModule=obj.val();$('[data-module-select="'+name+'"]').find('[data-module]').hide();$('[data-module-select="'+name+'"]').find('[data-module="'+changeModule+'"]').show();if(obj.attr('data-module-input')){var ipt=$('[name="'+obj.attr('data-module-input')+'"]');if(!ipt.attr('data-placeholder-')){ipt.attr('data-placeholder-',ipt.prop('placeholder')+' ')}
if(ipt.attr('data-placeholder-'+changeModule)){ipt.prop('placeholder',ipt.attr('data-placeholder-'+changeModule))}else{ipt.prop('placeholder','')}
if(ipt.attr('data-val-'+changeModule)){ipt.val(ipt.attr('data-val-'+changeModule))}else{ipt.val('')}}})},clone_tpl:function(tplId,namePre){namePre=namePre?namePre:'';var tpl=$(tplId).clone();tpl.removeAttr('id');tpl.find('[data-name]').each(function(){$(this).attr('name',namePre+$(this).attr('data-name'));$(this).removeAttr('data-name')});return tpl},get_content_signs:function(contentSignEle){var contentSigns=[];$(contentSignEle).each(function(){var csVal=$(this).val();csVal=decode_urlbase2json(csVal);contentSigns.push(csVal)});return contentSigns},page_signs:function(pageConfig,returnMergeSigns,noDefSign){var signs={area:[],url:[],content:[]};if(!isObject(pageConfig)){pageConfig={}}
var areaRule=pageConfig.area?pageConfig.area:'';var urlRule=pageConfig.url_rule?pageConfig.url_rule:'';var contentSigns=pageConfig.content_signs;var allowDefSign=noDefSign?0:!0;signs.area=cpMatchN(null,null,{rule:areaRule,def:allowDefSign});signs.url=cpMatchN(null,null,{rule:urlRule,def:allowDefSign});var signMatch=window.tpl_lang.sign_match;if(isObject(contentSigns)){for(var i in contentSigns){if(isObject(contentSigns[i])){if(contentSigns[i].identity){signs.content.push(signMatch.replace('{:id}',contentSigns[i].identity))}}}}
var areaRule=pageConfig.area?pageConfig.area:'';var urlRule=pageConfig.url_rule?pageConfig.url_rule:'';var contentSigns=pageConfig.content_signs;var allowDefSign=noDefSign?0:!0;signs.area=ruleInsertSign.matchN(null,null,{rule:areaRule,def:allowDefSign});signs.url=ruleInsertSign.matchN(null,null,{rule:urlRule,def:allowDefSign});var signMatch=window.tpl_lang.sign_match;if(isObject(contentSigns)){for(var i in contentSigns){if(isObject(contentSigns[i])){if(contentSigns[i].identity){signs.content.push(signMatch.replace('{:id}',contentSigns[i].identity))}}}}
for(var i in signs){if(!isObject(signs[i])){signs[i]=[]}}
if(returnMergeSigns){var mergeSigns=[];for(var i in signs.area){var curSign=signs.area[i];if(mergeSigns.indexOf(curSign)<=-1&&signs.url.indexOf(curSign)<=-1&&signs.content.indexOf(curSign)<=-1){mergeSigns.push(curSign)}}
for(var i in signs.url){var curSign=signs.url[i];if(mergeSigns.indexOf(curSign)<=-1&&signs.content.indexOf(curSign)<=-1){mergeSigns.push(curSign)}}
@ -77,18 +79,19 @@ pageConfig.area=$(formId).find('[name="'+namePre+'[area]"]').val();pageConfig.ur
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:''}
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=cpMatchN(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},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>'}
html+='</td>'}
html+='</tr>'}
if(dropdownMenu.length>0){var signsObj=$_o.clone_tpl('#coll_tpl_page_signs');$(dropdownMenu).append(signsObj);$(dropdownMenu).find('table tbody').html(html);$(dropdownMenu).find('a[data-val]').bind('click',function(){if(iptObj){insertAtCaret(iptObj,$(this).attr('data-val'))}});var sortObj=$(dropdownMenu).find('th.sorting');sortObj.removeClass('sorting');sortObj.addClass(pageSort=='asc'?'sorting_asc':'sorting_desc');sortObj.attr('title','页面'+(pageSort=='asc'?'升序':'降序')+'排列');sortObj.bind('click',function(){ajaxOpen({type:'get',dataType:'json',url:ulink("cpattern/page_signs_sort"),success:function(data){toastr.success(data.msg)}})})}}}})},field_is_loop:function(){var hasLoop=$(this.formid+' #coll_pattern_field .c-p-field-list').find('.field-module[data-is-loop]');if(hasLoop&&hasLoop.length>0){hasLoop=1}else{hasLoop=''}
return hasLoop}}
return hasLoop},get_task_id:function(){var taskId=$(this.formid+' [name="task_id"]').val();taskId=taskId?taskId:'';return taskId}}
function CpFrontUrl(cpClass){this.$_cp=cpClass;this.formObj='#form_front_url'}
CpFrontUrl.prototype={constructor:CpFrontUrl,init:function(front_url){var $_o=this;$($_o.formObj).bind('submit',function(){$_o.add_sub();return!1});$_o.$_cp.init_page('front_url');$($_o.formObj).on('click','.c-p-url-page-signs .btn-page-signs',function(){$_o.$_cp.parent_page_signs(this)});if(front_url){var loadParams=['name','url'];for(var i in loadParams){if(front_url[loadParams[i]]){$($_o.formObj+' [name="front_url['+loadParams[i]+']"]').val(front_url[loadParams[i]])}}
if(front_url.use_cookie){$($_o.formObj+' [name="front_url[use_cookie]"][value="'+toInt(front_url.use_cookie)+'"]').prop('checked',!0)}
if(front_url.use_cookie_img){$($_o.formObj+' [name="front_url[use_cookie_img]"][value="'+toInt(front_url.use_cookie_img)+'"]').prop('checked',!0)}
if(front_url.use_cookie_file){$($_o.formObj+' [name="front_url[use_cookie_file]"][value="'+toInt(front_url.use_cookie_file)+'"]').prop('checked',!0)}
$_o.$_cp.load_page('front_url',front_url)}},add:function(objid,front_url){var $_o=this;var pageSigns=$_o.$_cp.page_signs(front_url,!0,!0);var objEle=null;if(objid){objEle=$($_o.$_cp.formid+' #'+objid)}else{objEle=$_o.$_cp.clone_tpl('#coll_tpl_front_url');objEle.attr('id','front_url_'+generateUUID());$($_o.$_cp.formid+' #c_p_front_urls').append(objEle)}
objEle.find('.name').attr('data-val',front_url.name).text(front_url.name);objEle.find('[name="config[front_urls][]"]').val(encode_json2urlbase(front_url));pageSigns=pageSigns.join(' ');pageSigns=pageSigns?pageSigns:'无';objEle.find('.signs').val(pageSigns)},add_sub:function(){var $_o=this;var objid=$($_o.formObj+' input[name="objid"]').val();var checkName=!0;if(objid){var name=$($_o.$_cp.formid+' #'+objid).find('.name').attr('data-val');if(name==$($_o.formObj+' [name="front_url[name]"]').val()){checkName=!1}}
if(checkName){var hasName=!1;$('#c_p_front_urls [id^="front_url_"] .name').each(function(){if($($_o.formObj+' [name="front_url[name]"]').val()==$(this).attr('data-val')){hasName=!0;return!1}});if(hasName){toastr.error('该名称已存在!');return!1}}
@ -187,7 +190,8 @@ $($_o.processBox+' .process-add').bind('click',function(){var module=$($_o.proce
$($_o.processForm).on('click','.p-m-html-tags a[data-val]',function(){var tag=$(this).attr('data-val');var moduleHtml=$(this).parents('.p-m-html-tags').eq(0).attr('module-html');var tagsObj=$(this).parents('section').eq(0).find('input[data-process="html:'+moduleHtml+'"]');var tags=tagsObj.val()+','+tag;tags=tags.replace(/(^,+)|(,+$)/,'');tagsObj.val(tags)});$($_o.processForm).on('change','[data-process="insert:insert_loc"]',function(){var helpEle=$(this).siblings('.help-block');if($(this).val()=='rand'){helpEle.show()}else{helpEle.hide()}});inputSelectCustom(null,null,{box:$_o.processForm,slt:'[data-process="translate:translate_from"]',ipt:'[data-process="translate:translate_from_custom"]'});inputSelectCustom(null,null,{box:$_o.processForm,slt:'[data-process="translate:translate_to"]',ipt:'[data-process="translate:translate_to_custom"]'});$_o.txt_insert_field($_o.processForm,'.p-m-func-field',function(sltObj){return $(sltObj).parents('section').eq(0).find('[data-process="func:func_param"]')});$($_o.processForm).on('click','.p-m-if-add',function(){var ifTable=$(this).parents('section').eq(0).find('.p-m-if-table');ifTable.append('<tr>'+ifTable.attr('data-tpl')+'</tr>')});$($_o.processForm).on('click','.p-m-if-del',function(){var tr=$(this).parents('tr').eq(0);confirmRight('确定删除?',function(){tr.remove()})});$($_o.processForm).on('change','[data-process="if:if_cond:"]',function(){var ifCond=$(this).val();var ifTr=$(this).parents('tr').eq(0);var ifTd=ifTr.find('.p-m-if-val').eq(0);var ifVal=ifTd.find('[data-process="if:if_val:"]').eq(0);var ifValInfo={name:ifVal.attr('name'),val:ifVal.val(),process:ifVal.attr('data-process')};var ifValType='def';if(ifCond=='func'){ifValType='func'}else if(ifCond.indexOf('time_')>-1){ifValType='time'}
ifTd.find('.p-m-if-val-def,.p-m-if-val-time,.p-m-if-val-func').hide();ifTd.find('[data-process="if:if_val:"]').removeAttr('name').removeAttr('data-process');var ifValBox=ifTd.find('.p-m-if-val-'+ifValType);var ifValEle=ifValBox.find('.p-m-if-val-ele');ifValEle.attr('name',ifValInfo.name).attr('data-process',ifValInfo.process).val(ifValInfo.val);ifValBox.show();if(ifValType=='func'){$_o.load_if_func(ifTd,null)}});$($_o.processForm).on('change','.p-m-if-val-time-date select',function(){$(this).parents('tr').eq(0).find('[data-process="if:if_val:"]').val($(this).val())});$($_o.processForm).on('click','.p-m-if-val-func-info',function(){tipsPluginFunc('processIf')});$_o.txt_insert_field($_o.processForm,'.p-m-if-val-func-field select',function(sltObj){return $(sltObj).parents('td').eq(0).find('[data-process="if:if_val:"]')});$($_o.processForm).on('click','.p-m-if-info',function(){var tips='<p>执行顺序:从上至下判断,逻辑符“并且”的优先级高于“或者”</p>'+'<p>例如(字母表示条件):</p>'+'<p>a &amp;&amp; b || c &amp;&amp; d &amp;&amp; e || f || g &amp;&amp; h &amp;&amp; i &amp;&amp; j 等同于</p>'+'<p>(a &amp;&amp; b) || (c &amp;&amp; d &amp;&amp; e) || f || (g &amp;&amp; h &amp;&amp; i &amp;&amp; j)</p>'+'<p>括号中的条件都为真时才是真否则为假,整条语句中任意一个括号的结果为真最终结果为真,都为假最终结果为假</p>';confirmRight({msg:tips,yes:'确定',width:500,textAlign:'left'})});$($_o.processForm).on('click','.p-m-api-add',function(){var apiTable=$(this).parents('section').eq(0).find('.p-m-api-table table');apiTable.find('tbody').append('<tr>'+apiTable.attr('data-tpl')+'</tr>')});$($_o.processForm).on('click','.p-m-api-del',function(){var tr=$(this).parents('tr').eq(0);tr.remove()});inputSelectCustom(null,null,{box:$_o.processForm,slt:'[data-process="api:api_charset"]',ipt:'[data-process="api:api_charset_custom"]'});inputSelectCustom(null,null,{box:$_o.processForm,slt:'[data-process="api:api_encode"]',ipt:'[data-process="api:api_encode_custom"]'});$($_o.processForm).on('change','[data-process="api:api_params:val:"],[data-process="api:api_headers:val:"]',function(){var isHeader=!1;if($(this).attr('data-process')=='api:api_headers:val:'){isHeader=!0}
var val=$(this).val();var tdObj=$(this).parents('td').eq(0);var iptObj=tdObj.find('[data-process="api:'+(isHeader?'api_headers':'api_params')+':addon:"]');var sltObj=tdObj.find('.p-m-api-'+(isHeader?'header':'val')+'-field');iptObj.hide();sltObj.hide();if(val=='time'||val=='custom'){if(val=='time'){iptObj.attr('placeholder','默认格式:Y-m-d H:i:s')}else if(val=='custom'){iptObj.attr('placeholder','输入任何内容');sltObj.css('display','table-cell')}
iptObj.show()}});$_o.txt_insert_field($_o.processForm,'.p-m-api-val-field select',function(sltObj){return $(sltObj).parents('td').eq(0).find('[data-process="api:api_params:addon:"]')});$_o.txt_insert_field($_o.processForm,'.p-m-api-header-field select',function(sltObj){return $(sltObj).parents('td').eq(0).find('[data-process="api:api_headers:addon:"]')});$($_o.processForm).on('click','.p-m-api-header-add',function(){var apiHdTable=$(this).parents('section').eq(0).find('.p-m-api-header-table table');apiHdTable.find('tbody').append('<tr>'+apiHdTable.attr('data-tpl')+'</tr>')});$($_o.processForm).on('click','.p-m-api-header-del',function(){var tr=$(this).parents('tr').eq(0);tr.remove()});$($_o.processForm).on('change','[data-process="api:api_type"]',function(){var obj=$(this).parents('section').eq(0).find('.p-m-api-content-type');if($(this).val()=='post'){obj.show()}else{obj.hide()}});$($_o.processForm).on('change','[data-process="api:api_json_arr"]',function(){var ipt=$(this).parent().find('.p-m-api-json-implode');if($(this).val()=='implode'){ipt.show()}else{ipt.hide()}});$($_o.processForm).on('click','.sign-wildcard',function(){var toObj=$(this).parent().siblings('[data-process="replace:replace_from"]');cpWildcard(toObj)});$($_o.processForm).on('click','.c-p-process-title',function(){var panelTitle=$(this).parents('.panel').eq(0).find('.panel-title-title');if(panelTitle.find('input').is(':visible')){panelTitle.find('*').show();panelTitle.find('input').hide()}else{panelTitle.find('*').hide();panelTitle.find('input').show()}});(function(processForm,processBox){$(processForm).on('click','.c-p-process-clone',function(){var panelObj=$(this).parents('.panel[data-name^="process"]').eq(0);var formEle=document.createElement('form');$(formEle).append(panelObj.clone());$(panelObj).find('[name^="process"]').each(function(index){var processEle=$(formEle).find('[name^="process"]').eq(index);if($(this).is('input:radio')||$(this).is('input:checkbox')){processEle.prop('checked',$(this).is(':checked'))}else{processEle.val($(this).val())}});confirmRight({msg:'拷贝或复制数据处理',yes:'复制',no:'拷贝',close:!0},function(){ajaxOpen({type:'POST',dataType:'json',url:ulink('cpattern/clone_process'),data:$(formEle).serialize(),success:function(data){if(data.code==1){$_o.processForm=processForm;$_o.processBox=processBox;$_o.add(data.data);toastr.success(data.msg)}}})},function(){ajaxOpen({type:'POST',dataType:'json',url:ulink('cpattern/clone_process?op=copy'),data:$(formEle).serialize(),success:function(data){if(data.code==1){toastr.success(data.msg)}}})})})})($_o.processForm,$_o.processBox);$($_o.processForm).on('click','.c-p-process-del',function(){$_o.del(this)});eleExchange($_o.processForm+' .c-p-process-accordion','.panel-title-ops .icon-drag-move','.panel');if(processData){for(var i in processData){if(processData[i]){$_o.add(processData[i])}}}
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}
@ -197,12 +201,14 @@ var processName='process[i_'+generateUUID()+']';moduleHtml='<input type="hidden"
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=='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:'')}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)}
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();$(curCollapse).find('[data-process="api:api_url"]').val(params.api_url?params.api_url:'');$(curCollapse).find('[data-process="api:api_type"]').val(params.api_type?params.api_type:'').trigger('change');$(curCollapse).find('[data-process="api:api_content_type"]').val(params.api_content_type?params.api_content_type:'');$(curCollapse).find('[data-process="api:api_charset"]').val(params.api_charset?params.api_charset:'').trigger('change');$(curCollapse).find('[data-process="api:api_charset_custom"]').val(params.api_charset_custom?params.api_charset_custom:'');$(curCollapse).find('[data-process="api:api_encode"]').val(params.api_encode?params.api_encode:'').trigger('change');$(curCollapse).find('[data-process="api:api_encode_custom"]').val(params.api_encode_custom?params.api_encode_custom:'');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]:'')}}
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]:'')}}
if(params.api_headers){params.api_headers.name=params.api_headers.name?params.api_headers.name:{};params.api_headers.val=params.api_headers.val?params.api_headers.val:{};params.api_headers.addon=params.api_headers.addon?params.api_headers.addon:{};for(var i in params.api_headers.name){var trId='p-m-api-header_'+generateUUID();var trTpl='<tr id="'+trId+'">'+apiHdTable.attr('data-tpl')+'</tr>';apiHdTable.find('tbody').append(trTpl);apiHdTable.find('#'+trId+' [data-process="api:api_headers:name:"]').val(params.api_headers.name[i]);apiHdTable.find('#'+trId+' [data-process="api:api_headers:val:"]').val(params.api_headers.val[i]?params.api_headers.val[i]:'').trigger('change');apiHdTable.find('#'+trId+' [data-process="api:api_headers:addon:"]').val(params.api_headers.addon[i]?params.api_headers.addon[i]:'')}}
$(curCollapse).find('[data-process="api:api_json"]').val(params.api_json?params.api_json:'');$(curCollapse).find('[data-process="api:api_json_arr"]').val(params.api_json_arr?params.api_json_arr:'implode').trigger('change');$(curCollapse).find('[data-process="api:api_json_implode"]').val(params.api_json_implode?params.api_json_implode:'');$(curCollapse).find('[data-process="api:api_interval"]').val(params.api_interval?params.api_interval:'');$(curCollapse).find('[data-process="api:api_wait"]').val(params.api_wait?params.api_wait:'');$(curCollapse).find('[data-process="api:api_retry"]').val(params.api_retry?params.api_retry:'')}
params.api_json_arr=params.api_json_arr?params.api_json_arr:'implode';for(var i in params){if(isObject(params[i])){continue}
$(curCollapse).find('[data-process="api:'+i+'"]').val(params[i]?params[i]:'')}
$(curCollapse).find('[data-process="api:api_type"]').trigger('change');$(curCollapse).find('[data-process="api:api_charset"]').trigger('change');$(curCollapse).find('[data-process="api:api_encode"]').trigger('change');$(curCollapse).find('[data-process="api:api_rule_module"]').trigger('change');cpRuleModuleLoad(curCollapse,processName,'api_',params)}
if($_o.processForm!=$_o.processFormField){$('#myModal').modal('hide')}},txt_insert_field:function(boxEle,sltEle,txtObjFunc){var $_o=this;$(boxEle).on('mouseover',sltEle,function(){if(!$(this).attr('data-loaded')){var fieldNames=$_o.$_cp.get_field_names(!0);var html='<option value="">插入字段</option><option value="###">###表示当前字段</option>';if(fieldNames){var formField=$(this).parents($_o.processFormField).eq(0).find('[name="field"]').val();if(formField){for(var i=0;i<fieldNames.length;i++){var curField=fieldNames[i];if(formField&&formField==curField){if(i<fieldNames.length-1){html+='<optgroup label="不能调用当前字段顺序后面的字段,可移动字段位置使之生效"></optgroup>'}
break}
html+='<option value="[字段:'+curField+']">字段:'+curField+'</option>'}}else{html+='<optgroup label="通用数据处理仅支持调用当前字段"></optgroup>'}}
@ -228,28 +234,10 @@ 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=[]}
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:'';$(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()}})}
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()}})}}
function cpRuleModuleLoad(boxId,name,namePre,config){namePre=namePre?namePre:'';if(config){$(boxId+' [name="'+name+'['+namePre+'rule]"]').val(config[namePre+'rule']);$(boxId+' [name="'+name+'['+namePre+'rule_merge]"]').val(config[namePre+'rule_merge']);if(config[namePre+'rule_multi']){$(boxId+' [name="'+name+'['+namePre+'rule_multi]"]').prop('checked',!0).trigger('change')}
$(boxId+' [name="'+name+'['+namePre+'rule_multi_type]"][value="'+(config[namePre+'rule_multi_type']?config[namePre+'rule_multi_type']:'')+'"]').prop('checked',!0);$(boxId+' [name="'+name+'['+namePre+'xpath]"]').val(config[namePre+'xpath']);if(config[namePre+'xpath_multi']){$(boxId+' [name="'+name+'['+namePre+'xpath_multi]"]').prop('checked',!0).trigger('change')}
$(boxId+' [name="'+name+'['+namePre+'xpath_multi_type]"][value="'+(config[namePre+'xpath_multi_type']?config[namePre+'xpath_multi_type']:'')+'"]').prop('checked',!0);if(config[namePre+'json_loop']){$(boxId+' [name="'+name+'['+namePre+'json_loop]"]').prop('checked',!0)}
if(config[namePre+'json_arr']){$(boxId+' [name="'+name+'['+namePre+'json_arr]"]').val(config[namePre+'json_arr']).trigger('change')}
$(boxId+' [name="'+name+'['+namePre+'json_arr_implode]"]').val(config[namePre+'json_arr_implode'])}}
function cpRuleTips(isPage){var tips='<p>1、规则中的特殊字符:<b>^$.*+|?[]{}()</b> 必须加上“\\”才能转义为字符,否则会识别为正则符号</p><p>2、[内容]标签的标识可由数字、字母及下划线组成</p>';if(isPage){tips+='<p>3、页面级别:多级页 &gt; 多级页子页 &gt; 内容页 &gt; 关联页 &gt; 关联页子页</p>';tips+='<p>4、[内容]标签可全局调用,但只能调用比自己级别高的页面中的标签,即内容页可调用多级页中的标签而不能调用关联页中的标签</p>';tips+='<p>5、同一页面中有相同标识的[内容]标签时,后面的标签会覆盖前面的同名标签。不同页面中有相同标识的[内容]标签时,低级别页面会覆盖高级别页面中的同名标签</p>'}
confirmRight({msg:tips,yes:'确定',width:500,textAlign:'left'})}
function cpDelimiterTips(){var tips='<p>如需使用换行符,请注意区别:</p><p>文本换行符:<b>\\r\\n</b>(适用于系统文件中)</p><p>标签换行符:<b>&lt;br /&gt;</b>(适用于网页HTML中)</p>';confirmRight({msg:tips,yes:'确定',width:350,textAlign:'left'})}
function cpMatch(toObj,options){if(!options){options={}}
var sign=window.tpl_lang.sign_match;var group='(?<nr{:id}>[\\s\\S]*?)';if(options.only){sign=sign.replace('{:id}','');var curVal=$(toObj).val();if(curVal.indexOf(sign)<0&&curVal.indexOf('(?<nr>')<0&&curVal.indexOf('(?<content>')<0){if(options.group){sign=group.replace('{:id}','')}
insertAtCaret($(toObj),sign)}else{toastr.error('存在'+sign+'或捕获组')}}else{var regSign=new RegExp(sign.replace('{:id}','(\\w*)').replace('[','\\[').replace(']','\\]'),'g');var regZimu=new RegExp("^([a-zA-Z]+)(\\d+)$",'i');var regP=new RegExp("\\(\\?<(?:content|nr)(\\w*)>",'g');var list=null;var max=0;var zm='';while((list=regSign.exec($(toObj).val()))!=null){var num=0;if(options.zimu){var zimu=regZimu.exec(list[1]);if(zimu){zm=zimu[1];num=parseInt(zimu[2])}}else{num=parseInt(list[1])}
if(num>max){max=num}}
list=null;while((list=regP.exec($(toObj).val()))!=null){var num=0;if(options.zimu){var zimu=regZimu.exec(list[1]);if(zimu){zm=zimu[1];num=parseInt(zimu[2])}}else{num=parseInt(list[1])}
if(num>max){max=num}}
if(options.group){sign=group}
var signId='';if(options.zimu){if(!zm){var ranNum=Math.ceil(Math.random()*25);zm=String.fromCharCode(('A').charCodeAt(0)+ranNum);ranNum=Math.ceil(Math.random()*25);zm+=String.fromCharCode(('a').charCodeAt(0)+ranNum)}
signId=zm+(max+1)}else{signId=max+1}
sign=sign.replace('{:id}',signId);insertAtCaret($(toObj),sign)}}
function cpMatchN(fromObj,toObj,options){if(!options){options={}}
var sign=window.tpl_lang.sign_match;var rule='';if(fromObj){rule=$(fromObj).val()}else if(options.rule){rule=options.rule}
var reP=new RegExp("\\(\\?<(?:content|nr)(\\w*)>.*?\\)",'g');rule=rule.replace(reP,sign.replace('{:id}',"$1"));var regSign=new RegExp(sign.replace('{:id}','(\\w*)').replace('[','\\[').replace(']','\\]'),'g');var list=null;var hasSign=!1;var returnList=new Array();while((list=regSign.exec(rule))!=null){hasSign=!0;var each=list[0];if(!toObj){returnList.push(each)}else if($(toObj).is('select')){if($(toObj).find('option[value="'+each+'"]').length<=0){$(toObj).append('<option value="'+each+'">'+each+'</option>')}}else{if($(toObj).val().indexOf(each)<0){insertAtCaret($(toObj),each)}}}
if(!hasSign){if(options.def){sign=sign.replace('{:id}','');if(!toObj){returnList.push(sign)}else if($(toObj).is('select')){if($(toObj).find('option[value="'+sign+'"]').length<=0){$(toObj).append('<option value="'+sign+'">'+sign+'</option>')}}else{if($(toObj).val().indexOf(sign)<0){insertAtCaret($(toObj),sign)}}}}
if(!toObj){return returnList}}
function cpWildcard(toObj,options){if(!options){options={}}
var wildcard=window.tpl_lang.sign_wildcard;if(options.only){if($(toObj).val().indexOf(wildcard)<0){insertAtCaret($(toObj),wildcard)}}else{insertAtCaret($(toObj),wildcard)}}
function cpDelimiterTips(){var tips='<p>如需使用换行符,请注意区别:</p><p>文本换行符:<b>\\r\\n</b>(适用于系统文件中)</p><p>标签换行符:<b>&lt;br /&gt;</b>(适用于网页HTML中)</p>';confirmRight({msg:tips,yes:'确定',width:350,textAlign:'left'})}

7
public/static/js/admin/release.js

@ -7,14 +7,15 @@
| 使用协议 https://www.skycaiji.com/licenses
|--------------------------------------------------------------------------
*/
'use strict';function ReleaseClass(formid,releid){this.formid='#'+formid;this.releid=releid}
'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)});$('#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')}
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]}
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()}
$($_o.formid+' [name="diy[app]"]').parent().find('.diy-app-name').text(appName+'.php');$($_o.formid+' [name="diy[app]"]').parent().find('.diy-app-editor').show().find('.btn_diy_editor').attr('href',ulink('develop/editor?type=release&module=diy&app=_app_',{'_app_':appName}))}
if($_o.has_diy_editor()&&data.config.diy.code){editorCodeIfr('#diy_editor_ifr',{'set_value':data.config.diy.code})}})}}else if('toapi'==data.module){var config=data.config.toapi;if(config){$($_o.formid+' [name="toapi[module]"]').val(config.module);$($_o.formid+' [name="toapi[url]"]').val(config.url);$($_o.formid+' [name="toapi[type]"]').val(config.type).trigger('change');$($_o.formid+' [name="toapi[content_type]"]').val(config.content_type);$($_o.formid+' [name="toapi[charset_custom]"]').val(config.charset_custom);$($_o.formid+' [name="toapi[charset]"]').val(config.charset).trigger('change');$($_o.formid+' [name="toapi[encode_custom]"]').val(config.encode_custom);$($_o.formid+' [name="toapi[encode]"]').val(config.encode).trigger('change');if(config.response){for(var i in config.response){$($_o.formid+' [name="toapi[response]['+i+']"]').val(config.response[i])}}
if(config.param_name){config.param_val=config.param_val?config.param_val:{};for(var i in config.param_name){var pname=config.param_name[i]?config.param_name[i]:'';var pval=config.param_val[i]?config.param_val[i]:'';$_o.toapi_add_param({name:pname,val:pval},i)}}
$($_o.formid+' [name="toapi[response][module]"]').trigger('change');if(config.param_name){config.param_val=config.param_val?config.param_val:{};for(var i in config.param_name){var pname=config.param_name[i]?config.param_name[i]:'';var pval=config.param_val[i]?config.param_val[i]:'';$_o.toapi_add_param({name:pname,val:pval},i)}}
if(config.header_name){config.header_val=config.header_val?config.header_val:{};for(var i in config.header_name){var hname=config.header_name[i]?config.header_name[i]:'';var hval=config.header_val[i]?config.header_val[i]:'';$_o.toapi_add_header({name:hname,val:hval},i)}}
$($_o.formid+' [name="toapi[app_url]"]').val(config.app_url);config.interval=toInt(config.interval);config.wait=toInt(config.wait);config.retry=toInt(config.retry);$($_o.formid+' [name="toapi[interval]"]').val(config.interval);$($_o.formid+' [name="toapi[wait]"]').val(config.wait);$($_o.formid+' [name="toapi[retry]"]').val(config.retry);$(document).ready(function(){$('#toapi_tab a[href="#toapi_tab_'+config.module+'"]').tab('show').trigger('click');if(config.interval>0||config.wait>0||config.retry>0){showPanelCollapse('#panel_toapi')}})}}}},cms_detect:function(){var $_o=this;$('#cms_list').html('').addClass('loading');ajaxOpen({type:'get',url:ulink("release/cmsDetect"),dataType:'json',success:function(data){$('#cms_list').removeClass('loading');if(data.code==1){var html='<p>点击选择CMS</p>';for(var x in data.data){var list=data.data[x];html+='<label>'+x+'</label><ul>';for(var y in list){html+='<li><a href="javascript:;" path="'+list[y]+'">'+list[y]+'</a></li>'}
html+='</ul>'}

7
public/static/js/admin/setting.js

@ -7,10 +7,13 @@
| 使用协议 https://www.skycaiji.com/licenses
|--------------------------------------------------------------------------
*/
'use strict';function SettingClass(){this.caijiForm='#form_set';this.downImgForm='#form_set';this.pageRenderForm='#form_set';this.transForm='#form_set';this.siteForm='#form_set';this.emailForm='#form_set';this.storeForm='#form_set'}
'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");loadPluginFunc({module:'downloadImg',boxObj:$_o.downImgForm,funcObj:'[name="img_func"]',paramObj:'[name="img_func_param"]',funcVal:imgConfig.img_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}}
$($_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}}
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

@ -11,13 +11,16 @@
$('#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}
if(open){$('#config_proxy').removeClass('box-not-enable')}else{$('#config_proxy').addClass('box-not-enable')}});$('#form_item [name="config[download_img]"]').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_img').removeClass('box-not-enable')}else{$('#config_download_img').addClass('box-not-enable')}});$('#form_item [name="config[img_name]"]').bind('change',function(){var val=$(this).val();if(val=='custom'){$('#config_img_name_custom').show()}else{$('#config_img_name_custom').hide()}});$('#config_img_name_custom').on('click','.name-custom-path a[data-val]',function(){insertAtCaret($('[name="config[name_custom_path]"]'),$(this).attr('data-val'))});$('#config_img_name_custom').on('click','.name-custom-name a[data-val]',function(){insertAtCaret($('[name="config[name_custom_name]"]'),$(this).attr('data-val'))});$('#form_item [name="config[img_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_img_func').show()}else{$('#config_img_func').hide()}});$('#form_item .dropup-img-params .dropdown-menu a').bind('click',function(){var val=$(this).attr('data-val');if(val){var obj=$('#form_item [name="config[img_func_param]"]');var objVal=obj.val();objVal=objVal?(objVal+"\r\n"):'';obj.val(objVal+val)}})},task_load:function(taskData,fieldList){taskOpClass.task_init();var imgFunc='';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_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(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;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 if(ele.is('input')&&eleType=='number'){task_config[i]=toInt(task_config[i]);if(task_config[i]!=0){ele.val(task_config[i])}}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_name]"]').trigger('change');$('#form_item [name="config[img_func]"]').trigger('change')}
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')}
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('');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)}}}
loadPluginFunc({module:'downloadImg',boxObj:'#form_item',funcObj:'[name="config[img_func]"]',funcVal:imgFunc,paramObj:'[name="config[img_func_param]"]'})}}
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')}
$('#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()}}}

26
public/static/js/jquery-ui.min.js vendored

File diff suppressed because one or more lines are too long

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

File diff suppressed because one or more lines are too long

24
vendor/skycaiji/app/admin/common.php vendored

@ -41,3 +41,27 @@ function trim_input_array($arrName){
$data=\util\Funcs::array_array_map('trim', $data);
return $data;
}
function trim_input_process($formName,$data=null){
if(!empty($formName)){
$data=input($formName,array(),null);
}
init_array($data);
static $passModules=array('substr','insert','replace');
foreach ($data as $k=>$v){
init_array($v);
if(isset($v['title'])){
$v['title']=trim($v['title']);
}
if(isset($v['module'])){
$v['module']=trim($v['module']);
}
if(!in_array($v['module'], $passModules)){
$v=\util\Funcs::array_array_map('trim',$v);
}
$data[$k]=$v;
}
return $data;
}

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

@ -183,8 +183,6 @@ class Backstage extends BaseController{
$cacheTimeout=time()-(3600*24);
CacheModel::getInstance('cont_url')->db()->where('dateline','<',$cacheTimeout)->delete();
CacheModel::getInstance('temp')->db()->where('dateline','<',$cacheTimeout)->delete();
$mconfig=model('Config');

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

@ -181,7 +181,6 @@ class CollectController extends \skycaiji\admin\controller\BaseController{
return $this->_collect_echo_end($isBatch, lang('task_error_empty_task'));
}
$taskData=$taskData->toArray();
$taskTips='任务:'.$taskData['name'].' » ';
if(empty($taskData['module'])){
@ -203,7 +202,6 @@ class CollectController extends \skycaiji\admin\controller\BaseController{
}
$collData=$collData->toArray();
$releData=$releData->toArray();
$taskData['config']=unserialize($taskData['config']?:'');
$mtask->loadConfig($taskData);
$taskData['caijitime']=intval($taskData['caijitime']);

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

@ -259,15 +259,59 @@ class Cpattern extends BaseController {
$this->assign('type',$type);
$op=input('op');
$taskId=input('task_id/d',0);
$transApiLangs=null;
if(!is_empty(g_sc_c('translate'))&&!is_empty(g_sc_c('translate','open'))){
$transApiLangs=\util\Translator::get_api_langs(g_sc_c('translate','api'));
$transApiLangs=$transApiLangs?$transApiLangs:null;
$downImgUrl='';
$downFileUrl='';
if(is_empty(g_sc_c('download_img','download_img'))){
$downImgUrl=url('setting/download_img');
}
if(is_empty(g_sc_c('download_file','download_file'))){
$downFileUrl=url('setting/download_file');
}
$transUrl='';
if(is_empty(g_sc_c('translate','open'))){
$transUrl=url('setting/translate');
}
$transApiLangs=\util\Translator::get_api_langs(g_sc_c('translate','api'));
init_array($transApiLangs);
$this->assign('transApiLangs',$transApiLangs);
if($taskId>0){
$taskData=model('Task')->getById($taskId);
model('Task')->loadConfig($taskData);
if(is_empty(g_sc_c('download_img','download_img'))){
if(!empty($taskData['config']['download_img'])){
$downImgUrl=url('task/save?id='.$taskId);
}
}else{
$downImgUrl='';
}
if(is_empty(g_sc_c('download_file','download_file'))){
if(!empty($taskData['config']['download_file'])){
$downFileUrl=url('task/save?id='.$taskId);
}
}else{
$downFileUrl='';
}
if(is_empty(g_sc_c('translate','open'))){
if(!empty($taskData['config']['translate'])){
$transUrl=url('task/save?id='.$taskId);
}
}else{
$transUrl='';
}
}
$this->assign('downImgUrl',$downImgUrl);
$this->assign('downFileUrl',$downFileUrl);
$this->assign('transUrl',$transUrl);
if(empty($type)){
if(empty($op)){
@ -281,7 +325,7 @@ class Cpattern extends BaseController {
return $this->fetch();
}elseif($op=='sub'){
$process=trim_input_array('process');
$process=trim_input_process('process/a');
if(empty($process)){
$process='';
}else{
@ -296,7 +340,7 @@ class Cpattern extends BaseController {
return $this->fetch();
}elseif($op=='load'){
$process=trim_input_array('process');
$process=trim_input_process('process/a');
$this->assign('process',$process);
return $this->fetch('process_load');
}
@ -309,7 +353,7 @@ class Cpattern extends BaseController {
if(request()->isPost()){
$process=trim_input_array('process');
$process=trim_input_process('process/a');
if(is_array($process)){
$process=reset($process);
@ -387,6 +431,7 @@ class Cpattern extends BaseController {
$front_url['use_cookie']=intval($front_url['use_cookie']);
$front_url['use_cookie_img']=intval($front_url['use_cookie_img']);
$front_url['use_cookie_file']=intval($front_url['use_cookie_file']);
$front_url=controller('admin/Cpattern','event')->page_set_config('front_url',$front_url);

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

@ -76,7 +76,8 @@ class CpatternTest extends BaseController {
if(!empty($this->eCpattern->config['front_urls'])){
$keyUseCookie=\util\Param::key_gsc_use_cookie();
$keyUseCookieImg=\util\Param::key_gsc_use_cookie(true);
$keyUseCookieImg=\util\Param::key_gsc_use_cookie('img');
$keyUseCookieFile=\util\Param::key_gsc_use_cookie('file');
$cacheFrontData=cache($cacheFrontKey);
if($clearCache||empty($cacheFrontData)||($cacheFrontData['update_time']!=$collData['uptime'])){
@ -88,7 +89,8 @@ class CpatternTest extends BaseController {
'page_content_matches'=>$this->eCpattern->page_content_matches,
'cur_front_urls'=>$this->eCpattern->cur_front_urls,
$keyUseCookie=>\util\Param::get_gsc_use_cookie(),
$keyUseCookieImg=>\util\Param::get_gsc_use_cookie(true),
$keyUseCookieImg=>\util\Param::get_gsc_use_cookie('img'),
$keyUseCookieFile=>\util\Param::get_gsc_use_cookie('file'),
'update_time'=>$collData['uptime']
);
cache($cacheFrontKey,$cacheFrontData,1200);
@ -110,10 +112,13 @@ class CpatternTest extends BaseController {
}
if($cacheFrontData[$keyUseCookie]){
\util\Param::set_gsc_use_cookie(false,$cacheFrontData[$keyUseCookie]);
\util\Param::set_gsc_use_cookie('',$cacheFrontData[$keyUseCookie]);
}
if($cacheFrontData[$keyUseCookieImg]){
\util\Param::set_gsc_use_cookie(true,$cacheFrontData[$keyUseCookieImg]);
\util\Param::set_gsc_use_cookie('img',$cacheFrontData[$keyUseCookieImg]);
}
if($cacheFrontData[$keyUseCookieFile]){
\util\Param::set_gsc_use_cookie('file',$cacheFrontData[$keyUseCookieFile]);
}
}
}
@ -962,7 +967,6 @@ class CpatternTest extends BaseController {
$msg='通过数据处理筛除了'.$num.'条数据';
}
}
foreach ($val_list as $v_k=>$vals){
foreach ($vals as $k=>$v){
$vals[$k]=$v['value'];
@ -1260,20 +1264,12 @@ class CpatternTest extends BaseController {
if($type=='rule'){
$rule=$this->eCpattern->convert_sign_match($field['rule']);
$rule=$this->eCpattern->correct_reg_pattern($rule);
$rule_merge=$this->eCpattern->set_merge_default($rule, $field['rule_merge']);
if(empty($rule_merge)){
$rule_merge=cp_sign('match');
}
$val=$this->eCpattern->get_rule_module_rule_data(array(
'rule' => $rule,
'rule_merge' => $rule_merge,
$val=$this->eCpattern->rule_module_rule_data_get(array(
'rule' => $field['rule'],
'rule_merge' => $field['rule_merge'],
'rule_multi' => $field['rule_multi'],
'rule_multi_str' => $field['rule_multi_str']
'rule_multi_str' => $field['rule_multi_str'],
'rule_flags'=>$this->eCpattern->config['reg_regexp_flags'],
), $content,array(),true);
}elseif($type=='xpath'){
@ -1289,7 +1285,6 @@ class CpatternTest extends BaseController {
'json_arr' => $field['json_arr'],
'json_arr_implode' => $field['json_arr_implode'],
), $content);
$val = trim($val);
}
$this->success($val);
}else{

49
vendor/skycaiji/app/admin/controller/Develop.php vendored

@ -1058,7 +1058,7 @@ EOF;
'插件编辑器',
$setTitle,
$setNav
);
);
$this->assign('config',array('type'=>$type,'module'=>$module,'app'=>$app));
$this->assign('type',$type);
@ -1116,11 +1116,56 @@ EOF;
if(empty($filename)){
$this->error('插件文件错误');
}
file_put_contents($filename, $appcode);
write_dir_file($filename, $appcode);
$uri=sprintf('develop/editor?type=%s&module=%s&app=%s',$type,$module,$app);
$this->success('操作成功',$uri);
}else{
$this->error('提交错误');
}
}
public function plugin_skycaijiAction(){
$op=input('op');
$scjPlugin = new \ReflectionClass('\\plugin\\skycaiji');
$scjMethods=$scjPlugin->getMethods(\ReflectionMethod::IS_PUBLIC);
if(empty($op)){
$scjMethods1=array();
foreach ($scjMethods as $scjMethod){
$methodName=$scjMethod->name;
if(empty($methodName)||strpos($methodName,'__')===0){
continue;
}
$methodCmt=$scjMethod->getDocComment();
if($methodCmt){
$methodCmt=preg_replace('/^[\/\*\s]+/m', '', $methodCmt);
$methodCmt=trim($methodCmt);
$methodCmt=htmlspecialchars($methodCmt,ENT_QUOTES);
$methodCmt=preg_replace('/[\r\n]+/', '<br>', $methodCmt);
}
$scjMethods1[$methodName]=$methodCmt;
}
$scjMethods=$scjMethods1;
$this->success('','',$scjMethods);
}elseif($op=='method'){
$method=input('method','');
$code=file(config('plugin_path').'/skycaiji.php');
$methodCmt='';
$methodCode='';
foreach ($scjMethods as $scjMethod){
if($scjMethod->name==$method){
$methodCmt=$scjMethod->getDocComment();
$methodStart=$scjMethod->getStartLine();
$methodEnd=$scjMethod->getEndLine();
$methodCode=array_slice($code, $methodStart-1, $methodEnd-$methodStart+1);
$methodCode=is_array($methodCode)?implode('',$methodCode):'';
break;
}
}
$this->assign('methodCmt',$methodCmt);
$this->assign('methodCode',$methodCode);
return $this->fetch('plugin_skycaiji_method');
}
}
}

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

@ -419,19 +419,50 @@ class Index extends CollectController{
if(g_sc_c('caiji','run')!='visit'){
$this->error('不是访问触发方式');
}
$taskIds=input('task_ids','');
$cacheKey='collect_visit_time'.($taskIds?('_'.$taskIds):'');
$cacheKey=md5($cacheKey);
$url='admin/index/caiji'.($taskIds?('?task_ids='.rawurlencode($taskIds)):'');
$mcache=CacheModel::getInstance();
$collectVisitTime=$mcache->getCache('collect_visit_time','data');
$collectVisitTime=$mcache->getCache($cacheKey,'data');
$nowTime=time();
if($collectVisitTime&&$nowTime-$collectVisitTime<=15){
$this->success('正在运行','admin/index/caiji',null,10);
$this->success('正在运行',$url,null,10);
}
$mcache->setCache($cacheKey,$nowTime);
$mcache->setCache('collect_visit_time',$nowTime);
\skycaiji\admin\model\Collector::collect_run_auto();
$this->success('正在采集...','admin/index/caiji',null,10);
$autoIds=array();
if($taskIds){
$taskIds=explode(',',$taskIds);
init_array($taskIds);
$taskIds=array_map('intval',$taskIds);
$autoIds=model('Task')->where(array(
'id'=>array('in',$taskIds),
'auto'=>array('>',0),
'module'=>'pattern',
))->order('caijitime asc')->column('id');
foreach ($taskIds as $k=>$v){
if(in_array($v, $autoIds)){
unset($taskIds[$k]);
}
}
if($taskIds){
$taskIds='<br/>id:'.implode(',', $taskIds).'不是自动采集任务';
}
}
$taskIds=$taskIds?:'';
\skycaiji\admin\model\Collector::collect_run_auto('',$autoIds);
$this->success('正在采集...'.$taskIds,$url,null,10);
}
/*运行自动采集*/
public function auto_collectAction(){
@ -445,7 +476,18 @@ class Index extends CollectController{
}
$this->collect_create_or_run(function(){
$taskIds=model('Task')->where("auto>0 and module='pattern'")->order('caijitime asc')->column('id');
$cond=array();
$taskIds=input('task_ids','');
if($taskIds){
$taskIds=explode(',', $taskIds);
init_array($taskIds);
$taskIds=array_map('intval',$taskIds);
$cond['id']=array('in',$taskIds);
}
$cond['auto']=array('>',0);
$cond['module']='pattern';
$taskIds=model('Task')->where($cond)->order('caijitime asc')->column('id');
if(empty($taskIds)){
$this->echo_msg_exit('没有可自动采集的任务 <a href="'.url('admin/task/list').'" target="_blank">设置</a>');
}

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

@ -193,18 +193,15 @@ class Setting extends BaseController {
$config['img_func']=input('img_func','');
$config['img_func_param']=input('img_func_param','');
$config['img_watermark']=input('img_watermark/d',0);
$config['img_wm_logo']=input('img_wm_logo','');
$config['img_wm_right']=input('img_wm_right/d',0);
$config['img_wm_bottom']=input('img_wm_bottom/d',0);
$config['img_wm_opacity']=input('img_wm_opacity/d',0);
$config['img_wm_opacity']=min(100,max(0,$config['img_wm_opacity']));
if(!empty($config['more_suffix'])){
if(preg_match_all('/\b[a-zA-Z]\w+\b/i', $config['more_suffix'],$msuffix)){
$msuffix=$msuffix[0];
$msuffix=implode(',', $msuffix);
$config['more_suffix']=strtolower($msuffix);
}else{
$config['more_suffix']='';
}
}
$config['more_suffix']=\skycaiji\admin\model\Config::process_suffix($config['more_suffix']);
if(!empty($config['img_path'])){
@ -257,6 +254,14 @@ class Setting extends BaseController {
$this->error('请输入系统编码自定义内容');
}
$upResult=$mconfig->upload_img_watermark_logo('img_wm_logo_upload');
if(!$upResult['success']){
$this->error($upResult['msg']);
}elseif($upResult['file_name']){
$config['img_wm_logo']=$upResult['file_name'];
}
$mconfig->setConfig('download_img',$config);
$this->success(lang('op_success'),'setting/download_img');
@ -265,7 +270,7 @@ class Setting extends BaseController {
'图片本地化设置',
'图片本地化设置',
breadcrumb(array(array('url'=>url('setting/caiji'),'title'=>lang('setting_caiji')),array('url'=>url('setting/download_img'),'title'=>'图片本地化')))
);
);
$imgConfig=$mconfig->getConfig('download_img','data');
init_array($imgConfig);
if(empty($imgConfig)){
@ -295,10 +300,122 @@ class Setting extends BaseController {
}
}
$imgWmError='';
$LocSystem=new \skycaiji\install\event\LocSystem();
$LocSystem=$LocSystem->environmentPhp();
if(empty($LocSystem['gd']['loaded'])){
$imgWmError='php未启用gd模块';
}
$this->assign('imgWmError',$imgWmError);
$this->assign('imgConfig',$imgConfig);
return $this->fetch('download_img');
}
}
/*文件本地化设置*/
public function download_fileAction(){
$mconfig=model('Config');
if(request()->isPost()){
$config=array();
$config['download_file']=input('download_file/d',0);
$config['file_interval']=input('file_interval/d',0);
$config['file_timeout']=input('file_timeout/d',0);
$config['retry']=input('retry/d',0);
$config['wait']=input('wait/d',0);
$config['file_path']=trim(input('file_path',''));
$config['file_url']=input('file_url','','trim');
$config['file_name']=input('file_name','');
$config['name_custom_path']=input('name_custom_path','');
$config['name_custom_name']=input('name_custom_name','');
$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','');
if(!empty($config['file_path'])){
$checkFilePath=$mconfig->check_file_path($config['file_path']);
if(!$checkFilePath['success']){
$this->error($checkFilePath['msg']);
}
}
if(!empty($config['file_url'])){
$checkFileUrl=$mconfig->check_file_url($config['file_url']);
if(!$checkFileUrl['success']){
$this->error($checkFileUrl['msg']);
}
}
$checkNamePath=$mconfig->check_file_name_path($config['name_custom_path']);
if($config['file_name']=='custom'){
if(empty($config['name_custom_path'])){
$this->error('请输入文件名称自定义路径');
}
if(!$checkNamePath['success']){
$this->error($checkNamePath['msg']);
}
}else{
if(!$checkNamePath['success']){
$config['name_custom_path']='';
}
}
$checkNameName=$mconfig->check_file_name_name($config['name_custom_name']);
if($config['file_name']=='custom'){
if(!empty($config['name_custom_name'])&&!$checkNameName['success']){
$this->error($checkNameName['msg']);
}
}else{
if(!$checkNameName['success']){
$config['name_custom_name']='';
}
}
if($config['charset']=='custom'&&empty($config['charset_custom'])){
$this->error('请输入系统编码自定义内容');
}
$mconfig->setConfig('download_file',$config);
$this->success(lang('op_success'),'setting/download_file');
}else{
$this->set_html_tags(
'文件本地化设置',
'文件本地化设置',
breadcrumb(array(array('url'=>url('setting/caiji'),'title'=>lang('setting_caiji')),array('url'=>url('setting/download_file'),'title'=>'文件本地化')))
);
$fileConfig=$mconfig->getConfig('download_file','data');
init_array($fileConfig);
if(empty($fileConfig)){
$fileConfig['file_timeout']=0;
$fileConfig['file_max']=0;
$fileConfig['file_interval']=0;
$fileConfig['wait']=0;
$fileConfig['retry']=0;
}
$this->assign('fileConfig',$fileConfig);
return $this->fetch('download_file');
}
}
/*代理设置*/
public function proxyAction(){
$mconfig=model('Config');

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

@ -272,6 +272,7 @@ class Task extends CollectController {
}
$isAdd=true;
if(!empty($taskData)){
$taskData['config']=$mtask->compatible_config($taskData['config']);
$isAdd=false;
}
if(request()->isPost()){
@ -333,13 +334,7 @@ class Task extends CollectController {
}
}
/*导入规则*/
$ruleId=input('rule_id');
if(!empty($taskData)&&!empty($ruleId)){
$this->_import_rule($taskData, $ruleId);
}
model('TaskTimer')->addTimer($tid,$taskTimerData);
$this->_save_common($taskData, $taskTimerData);
$this->success(lang('op_success'),input('referer','','trim')?input('referer','','trim'):('task/save?id='.$tid));
}else{
@ -357,13 +352,8 @@ class Task extends CollectController {
if($mtask->strict(false)->where(array('id'=>intval($taskData['id'])))->update($newData)>=0){
$taskData=$mtask->getById($taskData['id']);
/*导入规则*/
$ruleId=input('rule_id');
if(!empty($taskData)&&!empty($ruleId)){
$this->_import_rule($taskData, $ruleId);
}
model('TaskTimer')->addTimer($taskData['id'],$taskTimerData);
$this->_save_common($taskData, $taskTimerData);
$this->success(lang('op_success'),'task/save?id='.$taskData['id']);
}else{
@ -380,10 +370,6 @@ class Task extends CollectController {
breadcrumb(array(array('url'=>url('task/list'),'title'=>lang('task_list')),array('url'=>url('task/save'),'title'=>lang('task_add'))))
);
}else{
$taskData=$taskData->getData();
$taskData=is_array($taskData)?$taskData:array();
$taskData['config']=unserialize($taskData['config']?:'');
$taskData['config']=is_array($taskData['config'])?$taskData['config']:array();
if(input('?show_config')){
$taskData['_show_config']=1;
@ -391,7 +377,7 @@ class Task extends CollectController {
$this->set_html_tags(
'任务:'.$taskData['name'],
lang('task_edit').':'.$taskData['name'],
lang('task_edit').':'.$taskData['name'].'(id:'.$taskData['id'].')',
breadcrumb(array(array('url'=>url('task/list'),'title'=>lang('task_list')),array('url'=>url('task/save?id='.$taskData['id']),'title'=>$taskData['name'])))
);
@ -412,11 +398,15 @@ class Task extends CollectController {
$taskData['_task_timer']=$timerData;
$timerInfo=$mtimer->timer_info($timerData);
$timerInfo=$timerInfo?('<br><b>定时:</b>'.$timerInfo):'';
$this->assign('taskData',$taskData);
$this->assign('timerInfo',$timerInfo);
$this->assign('fieldList',$fieldList);
}
$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);
@ -425,26 +415,53 @@ class Task extends CollectController {
}else{
$imgFuncParam='';
}
$proxyGroupId=g_sc_c('proxy','group_id');
$proxyGroupId=intval($proxyGroupId);
$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')),
'interval'=>intval(g_sc_c('caiji','interval')),
'interval_html'=>intval(g_sc_c('caiji','interval_html')),
'num_interval'=>intval(g_sc_c('caiji','interval')),
'num_interval_html'=>intval(g_sc_c('caiji','interval_html')),
'same_url'=>g_sc_c('caiji','same_url')>0?'允许':'过滤',
'same_title'=>g_sc_c('caiji','same_title')>0?'允许':'过滤',
'real_time'=>g_sc_c('caiji','real_time')>0?'是':'否',
'translate'=>g_sc_c('translate','open')>0?'1':'',
'proxy'=>g_sc_c('proxy','open')>0?'1':'',
'proxy_group_id'=>$proxyGroupId<=0?'全部':model('ProxyGroup')->getNameById($proxyGroupId),
'download_img'=>g_sc_c('download_img','download_img')>0?'1':'',
'img_path'=>g_sc_c('download_img','img_path')?g_sc_c('download_img','img_path'):(config('root_path').DS.'data'.DS.'images'),
'img_url'=>g_sc_c('download_img','img_url')?g_sc_c('download_img','img_url'):(config('root_website').'/data/images'),
'img_name'=>g_sc_c('download_img','img_name'),
'name_custom_path'=>g_sc_c('download_img','name_custom_path')?g_sc_c('download_img','name_custom_path'):'无',
'name_custom_name'=>lang('down_img_name_custom_name_'.g_sc_c('download_img','name_custom_name')),
'interval_img'=>intval(g_sc_c('download_img','interval_img')),
'num_interval_img'=>intval(g_sc_c('download_img','interval_img')),
'img_watermark'=>g_sc_c('download_img','img_watermark')>0?'1':'',
'img_wm_logo'=>g_sc_c('download_img','img_wm_logo'),
'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_func_param'=>$imgFuncParam,
'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'),
'file_url'=>g_sc_c('download_file','file_url')?g_sc_c('download_file','file_url'):(config('root_website').'/data/files'),
'file_name'=>g_sc_c('download_file','file_name'),
'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,
);
$this->assign('gConfig',$gConfig);
$this->assign('tgSelect',$tgSelect);
@ -469,18 +486,32 @@ class Task extends CollectController {
$this->error();
}
}
private function _save_common($taskData,$taskTimerData){
$ruleId=input('rule_id');
if(!empty($taskData)&&!empty($ruleId)){
$this->_import_rule($taskData, $ruleId);
}
model('TaskTimer')->addTimer($taskData['id'],$taskTimerData);
$upResult=model('Config')->upload_img_watermark_logo('img_wm_logo_upload','task'.$taskData['id']);
if($upResult['success']&&$upResult['file_name']){
$taskData['config']['img_wm_logo']=$upResult['file_name'];
model('Task')->strict(false)->where(array('id'=>intval($taskData['id'])))->update(array('config'=>serialize($taskData['config'])));
}
}
private function _save_config($config=array()){
$config=is_array($config)?$config:array();
$config['num']=intval($config['num']);
$config['interval']=intval($config['interval']);
$config['interval_html']=intval($config['interval_html']);
$config=is_array($config)?$config:array();
$config['num']=empty($config['num'])?'':$config['num'];
$config['img_path']=trim($config['img_path']);
$config['img_url']=trim($config['img_url']);
$config['interval_img']=intval($config['interval_img']);
$config['proxy_group_id']=trim($config['proxy_group_id']);
$mconfig=model('Config');
if(!empty($config['img_path'])){
@ -501,12 +532,15 @@ class Task extends CollectController {
$checkNamePath=$mconfig->check_img_name_path($config['name_custom_path']);
if($config['img_name']=='custom'){
if(empty($config['name_custom_path'])&&is_empty(g_sc_c('download_img','name_custom_path'))){
$this->error('请输入图片名称自定义路径');
}
if(!$checkNamePath['success']){
$this->error($checkNamePath['msg']);
if(empty($config['name_custom_path'])){
if(is_empty(g_sc_c('download_img','name_custom_path'))){
$this->error('请输入图片名称自定义路径');
}
}else{
if(!$checkNamePath['success']){
$this->error($checkNamePath['msg']);
}
}
}else{
@ -528,6 +562,67 @@ class Task extends CollectController {
}
}
$checkWmLogo=$mconfig->check_img_watermark_logo('img_wm_logo_upload');
if(!$checkWmLogo['success']){
$this->error($checkWmLogo['msg']);
}
if(!is_empty($config['img_wm_opacity'],true)){
$config['img_wm_opacity']=min(100,max(0,$config['img_wm_opacity']));
}
$config['file_path']=trim($config['file_path']);
$config['file_url']=trim($config['file_url']);
if(!empty($config['file_path'])){
$checkFilePath=$mconfig->check_file_path($config['file_path']);
if(!$checkFilePath['success']){
$this->error($checkFilePath['msg']);
}
}
if(!empty($config['file_url'])){
$checkFileUrl=$mconfig->check_file_url($config['file_url']);
if(!$checkFileUrl['success']){
$this->error($checkFileUrl['msg']);
}
}
$checkNamePath=$mconfig->check_file_name_path($config['file_custom_path']);
if($config['file_name']=='custom'){
if(empty($config['file_custom_path'])){
if(is_empty(g_sc_c('download_file','file_custom_path'))){
$this->error('请输入文件名称自定义路径');
}
}else{
if(!$checkNamePath['success']){
$this->error($checkNamePath['msg']);
}
}
}else{
if(!$checkNamePath['success']){
$config['file_custom_path']='';
}
}
$checkNameName=$mconfig->check_file_name_name($config['file_custom_name']);
if($config['file_name']=='custom'){
if(!empty($config['file_custom_name'])&&!$checkNameName['success']){
$this->error($checkNameName['msg']);
}
}else{
if(!$checkNameName['success']){
$config['file_custom_name']='';
}
}
return $config;
}
@ -553,7 +648,7 @@ class Task extends CollectController {
$result=controller('admin/Mystore')->_upload_addon(true,'rule_file',false,true);
if(!$result['success']){
$this->error($result['msg'],'');
$this->error($result['msg'],'task/save?id='.$taskData['id']);
}else{
$ruleData=$result['ruleData'];
}

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

@ -20,6 +20,7 @@ class Cpattern extends CpatternEvent{
$config['page_render']=intval($config['page_render']);
$config['url_repeat']=intval($config['url_repeat']);
$config['url_no_name']=intval($config['url_no_name']);
$config['url_encode']=intval($config['url_encode']);
if(!is_array($config['regexp_flags'])){
$config['regexp_flags']=array();
@ -33,6 +34,8 @@ class Cpattern extends CpatternEvent{
\util\Funcs::filter_key_val_list($config['request_headers']['img_names'], $config['request_headers']['img_vals']);
\util\Funcs::filter_key_val_list($config['request_headers']['file_names'], $config['request_headers']['file_vals']);
if(is_array($config['front_urls'])){
@ -90,7 +93,7 @@ class Cpattern extends CpatternEvent{
$config['field_process'][$k]=$this->set_process($config['field_process'][$k]);
}
}
$config['common_process']=input('process/a',array(),'trim');
$config['common_process']=trim_input_process('process/a');
$config['common_process']=$this->set_process($config['common_process']);
@ -153,12 +156,18 @@ class Cpattern extends CpatternEvent{
if(is_array($this->config_params['headers'])){
set_g_sc('task_img_headers',$this->config_params['headers']['img']);
set_g_sc('task_file_headers',$this->config_params['headers']['file']);
}
if(!is_array(g_sc('task_img_headers'))){
set_g_sc('task_img_headers',array());
}
\util\Param::set_gsc_use_cookie(false,null);
\util\Param::set_gsc_use_cookie(true,null);
if(!is_array(g_sc('task_file_headers'))){
set_g_sc('task_file_headers',array());
}
\util\Param::set_gsc_use_cookie('',null);
\util\Param::set_gsc_use_cookie('img',null);
\util\Param::set_gsc_use_cookie('file',null);
}
public function initConfig($config){
@ -404,7 +413,7 @@ class Cpattern extends CpatternEvent{
$signs=array();
$headers=array('page'=>array(),'page_headers'=>array(),'img'=>array());
$headers=array('page'=>array(),'page_headers'=>array(),'img'=>array(),'file'=>array());
if(!empty($config['request_headers']['useragent'])){
$headers['page']['useragent']=$config['request_headers']['useragent'];
}
@ -432,13 +441,28 @@ class Cpattern extends CpatternEvent{
$headers['img']=$headers['page_headers'];
}
$imgHeaders=$this->arrays_to_key_val($config['request_headers']['img_names'], $config['request_headers']['img_vals']);
if(!empty($imgHeaders)&&is_array($imgHeaders)){
$headers['img']=\util\Funcs::array_key_merge($headers['img'],$imgHeaders);
unset($imgHeaders);
}
if(empty($config['request_headers']['file_use_page'])){
$headers['file']=empty($config['request_headers']['open'])?array():$headers['page_headers'];
}elseif($config['request_headers']['file_use_page']=='y'){
$headers['file']=$headers['page_headers'];
}
$fileHeaders=$this->arrays_to_key_val($config['request_headers']['file_names'], $config['request_headers']['file_vals']);
if(!empty($fileHeaders)&&is_array($fileHeaders)){
$headers['file']=\util\Funcs::array_key_merge($headers['file'],$fileHeaders);
unset($fileHeaders);
}
if(empty($config['request_headers']['open'])){
$headers['page']=null;
@ -457,6 +481,11 @@ class Cpattern extends CpatternEvent{
$headers['img']=null;
}
if(empty($config['request_headers']['file'])){
$headers['file']=null;
}
if(!is_array($this->config_params)){
$this->config_params=array();
}
@ -502,6 +531,9 @@ class Cpattern extends CpatternEvent{
if(g_sc_c('download_img','download_img')){
$opened_tools[]='图片本地化';
}
if(g_sc_c('download_file','download_file')){
$opened_tools[]='文件本地化';
}
if(g_sc_c('proxy','open')){
$opened_tools[]='代理';
}
@ -697,8 +729,9 @@ class Cpattern extends CpatternEvent{
public function collFrontUrls($resetColl=false){
if($resetColl){
\util\Param::set_gsc_use_cookie(false,null);
\util\Param::set_gsc_use_cookie(true,null);
\util\Param::set_gsc_use_cookie('',null);
\util\Param::set_gsc_use_cookie('img',null);
\util\Param::set_gsc_use_cookie('file',null);
}elseif($this->front_collected){
return;
@ -722,7 +755,7 @@ class Cpattern extends CpatternEvent{
$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');
$htmlInfo=$this->get_page_html($frontUrl,'front_url',$fuv['name'],false,true);
if($fuv['use_cookie']||$fuv['use_cookie_img']){
if($fuv['use_cookie']||$fuv['use_cookie_img']||$fuv['use_cookie_file']){
$mUseCookie=array();
if($htmlInfo['header']){
@ -752,15 +785,21 @@ class Cpattern extends CpatternEvent{
if($fuv['use_cookie']){
$gUseCookie=\util\Param::get_gsc_use_cookie();
init_array($gUseCookie);
\util\Param::set_gsc_use_cookie(false,array_merge($gUseCookie,$mUseCookie));
\util\Param::set_gsc_use_cookie('',array_merge($gUseCookie,$mUseCookie));
$this->echo_msg('获取前置页cookie并在全局抓取页面时使用','black');
}
if($fuv['use_cookie_img']){
$gUseCookieImg=\util\Param::get_gsc_use_cookie(true);
$gUseCookieImg=\util\Param::get_gsc_use_cookie('img');
init_array($gUseCookieImg);
\util\Param::set_gsc_use_cookie(true,array_merge($gUseCookieImg,$mUseCookie));
\util\Param::set_gsc_use_cookie('img',array_merge($gUseCookieImg,$mUseCookie));
$this->echo_msg('获取前置页cookie并在全局下载图片时使用','black');
}
if($fuv['use_cookie_file']){
$gUseCookieFile=\util\Param::get_gsc_use_cookie('file');
init_array($gUseCookieFile);
\util\Param::set_gsc_use_cookie('file',array_merge($gUseCookieFile,$mUseCookie));
$this->echo_msg('获取前置页cookie并在全局下载文件时使用','black');
}
}
}
}
@ -995,7 +1034,7 @@ class Cpattern extends CpatternEvent{
$field_name=$field_params['name'];
if(!isset($this->field_val_list[$field_name])){
$this->field_val_list[$field_name]=array('values'=>array(),'imgs'=>array());
$this->field_val_list[$field_name]=array('values'=>array(),'imgs'=>array(),'files'=>array());
}
if(!empty($field_params['source'])&&in_array($module, array('rule','xpath','json','auto','sign'))){
@ -1066,7 +1105,8 @@ class Cpattern extends CpatternEvent{
foreach ($this->field_val_list[$field_params['extract']]['values'][$cur_url_md5] as $k=>$v){
$extract_field_val=array(
'value'=>$v,
'img'=>$this->field_val_list[$field_params['extract']]['imgs'][$cur_url_md5][$k],
'img'=>$this->field_val_list[$field_params['extract']]['imgs'][$cur_url_md5][$k],
'file'=>$this->field_val_list[$field_params['extract']]['files'][$cur_url_md5][$k],
);
$val[$k]=$this->field_module_extract($field_params, $extract_field_val, $url_info);
}
@ -1074,7 +1114,8 @@ class Cpattern extends CpatternEvent{
$extract_field_val=array(
'value'=>$this->field_val_list[$field_params['extract']]['values'][$cur_url_md5],
'img'=>$this->field_val_list[$field_params['extract']]['imgs'][$cur_url_md5],
'img'=>$this->field_val_list[$field_params['extract']]['imgs'][$cur_url_md5],
'file'=>$this->field_val_list[$field_params['extract']]['files'][$cur_url_md5],
);
$val=$this->field_module_extract($field_params, $extract_field_val, $url_info);
}
@ -1086,7 +1127,8 @@ class Cpattern extends CpatternEvent{
foreach ($this->field_val_list as $k=>$v){
$cur_field_val_list[$k]=array(
'value'=>$v['values'][$cur_url_md5],
'img'=>$v['imgs'][$cur_url_md5]
'img'=>$v['imgs'][$cur_url_md5],
'file'=>$v['files'][$cur_url_md5]
);
}
$val=$this->field_module_merge($field_params,$cur_field_val_list);
@ -1100,7 +1142,8 @@ class Cpattern extends CpatternEvent{
foreach ($this->field_val_list as $k=>$v){
$cur_field_val_list[$k]=array(
'value'=>(is_array($v['values'][$cur_url_md5])?$v['values'][$cur_url_md5][$v_k]:$v['values'][$cur_url_md5]),
'img'=>((is_array($v['imgs'][$cur_url_md5])&&is_array($v['imgs'][$cur_url_md5][$v_k]))?$v['imgs'][$cur_url_md5][$v_k]:$v['imgs'][$cur_url_md5])
'img'=>((is_array($v['imgs'][$cur_url_md5])&&is_array($v['imgs'][$cur_url_md5][$v_k]))?$v['imgs'][$cur_url_md5][$v_k]:$v['imgs'][$cur_url_md5]),
'file'=>((is_array($v['files'][$cur_url_md5])&&is_array($v['files'][$cur_url_md5][$v_k]))?$v['files'][$cur_url_md5][$v_k]:$v['files'][$cur_url_md5])
);
}
$val[$v_k]=$this->field_module_merge($field_params,$cur_field_val_list);
@ -1149,6 +1192,18 @@ class Cpattern extends CpatternEvent{
foreach ($vals as $v_k=>$val){
$loopIndex=$is_loop?$v_k:-1;
$this->field_url_complete=true;
$this->field_down_img=true;
if($is_loop){
if(!isset($this->field_val_list[$field_name]['values'][$cur_url_md5])){
$this->field_val_list[$field_name]['values'][$cur_url_md5]=array();
$this->field_val_list[$field_name]['imgs'][$cur_url_md5]=array();
$this->field_val_list[$field_name]['files'][$cur_url_md5]=array();
}
}
if(!empty($field_process)){
$val=$this->process_field($field_name,$val,$field_process,$cur_url_md5,$loopIndex,$cont_url_md5);
@ -1165,6 +1220,7 @@ class Cpattern extends CpatternEvent{
unset($this->field_val_list[$f_k]['values'][$cur_url_md5]);
unset($this->field_val_list[$f_k]['imgs'][$cur_url_md5]);
unset($this->field_val_list[$f_k]['files'][$cur_url_md5]);
}
return;
}else{
@ -1177,6 +1233,7 @@ class Cpattern extends CpatternEvent{
unset($this->field_val_list[$f_k]['values'][$cur_url_md5]);
unset($this->field_val_list[$f_k]['imgs'][$cur_url_md5]);
unset($this->field_val_list[$f_k]['files'][$cur_url_md5]);
}
return;
}else{
@ -1191,6 +1248,10 @@ class Cpattern extends CpatternEvent{
unset($this->field_val_list[$f_k]['imgs'][$cur_url_md5][$v_k]);
}
if(is_array($this->field_val_list[$f_k]['files'][$cur_url_md5])){
unset($this->field_val_list[$f_k]['files'][$cur_url_md5][$v_k]);
}
}
continue;
}
@ -1198,29 +1259,32 @@ class Cpattern extends CpatternEvent{
}
}
$val=preg_replace_callback('/(\bhref\s*=\s*[\'\"])([^\'\"]*)([\'\"])/i',function($matche) use ($url_info){
$matche[2]=\util\Tools::create_complete_url($matche[2], $url_info);
return $matche[1].$matche[2].$matche[3];
},$val);
$val=preg_replace_callback('/(\bsrc\s*=\s*[\'\"])([^\'\"]*)([\'\"])/i',function($matche) use ($url_info){
$matche[2]=\util\Tools::create_complete_url($matche[2], $url_info);
return $matche[1].$matche[2].$matche[3];
},$val);
if($this->field_url_complete){
$val=preg_replace_callback('/(\bhref\s*=\s*[\'\"])([^\'\"]*)([\'\"])/i',function($matche) use ($url_info){
$matche[2]=\util\Tools::create_complete_url($matche[2], $url_info);
return $matche[1].$matche[2].$matche[3];
},$val);
$val=preg_replace_callback('/(\bsrc\s*=\s*[\'\"])([^\'\"]*)([\'\"])/i',function($matche) use ($url_info){
$matche[2]=\util\Tools::create_complete_url($matche[2], $url_info);
return $matche[1].$matche[2].$matche[3];
},$val);
}
if($is_loop){
if(!isset($this->field_val_list[$field_name]['values'][$cur_url_md5])){
$this->field_val_list[$field_name]['values'][$cur_url_md5]=array();
$this->field_val_list[$field_name]['imgs'][$cur_url_md5]=array();
$this->field_val_list[$field_name]['files'][$cur_url_md5]=array();
}
$this->field_val_list[$field_name]['values'][$cur_url_md5][$v_k]=$val;
}else{
$this->field_val_list[$field_name]['values'][$cur_url_md5]=$val;
}
if(!is_empty(g_sc_c('download_img','download_img'))&&!empty($val)){
if(!is_empty(g_sc_c('download_img','download_img'))&&!empty($val)&&$this->field_down_img){
$valImgs=array();
if(preg_match_all('/<img\b[^<>]*\bsrc\s*=\s*[\'\"](\w+\:[^\'\"]+?)[\'\"]/i',$val,$imgUrls)){
@ -1231,30 +1295,23 @@ class Cpattern extends CpatternEvent{
$valImgs=array_merge($valImgs,array($val));
}
$noImgVal=preg_replace_callback('/\{\[img\]\}(http[s]{0,1}\:\/\/[^\s]+?)\{\[\/img\]\}/i',function($matche) use (&$valImgs){
$valImgs[]=$matche[1];
return $matche[1];
},$val);
if($noImgVal!=$val){
if(!empty($valImgs)){
$fieldImgs=array();
if($is_loop){
$this->field_val_list[$field_name]['values'][$cur_url_md5][$v_k]=$noImgVal;
$fieldImgs=$this->field_val_list[$field_name]['imgs'][$cur_url_md5][$v_k];
}else{
$this->field_val_list[$field_name]['values'][$cur_url_md5]=$noImgVal;
$fieldImgs=$this->field_val_list[$field_name]['imgs'][$cur_url_md5];
}
}
if(!empty($valImgs)){
$valImgs=array_unique($valImgs);
$valImgs=array_values($valImgs);
init_array($fieldImgs);
$fieldImgs=array_merge($fieldImgs,$valImgs);
$fieldImgs=array_unique($fieldImgs);
$fieldImgs=array_values($fieldImgs);
if($is_loop){
$this->field_val_list[$field_name]['imgs'][$cur_url_md5][$v_k]=$valImgs;
$this->field_val_list[$field_name]['imgs'][$cur_url_md5][$v_k]=$fieldImgs;
}else{
$this->field_val_list[$field_name]['imgs'][$cur_url_md5]=$valImgs;
$this->field_val_list[$field_name]['imgs'][$cur_url_md5]=$fieldImgs;
}
}
}
@ -1510,7 +1567,26 @@ class Cpattern extends CpatternEvent{
$val_imgs=array_values($val_imgs);
}
}
$val_list[$fieldName]=array('name'=>$fieldName,'value'=>$val_values,'img'=>$val_imgs);
$val_files=array();
if(!empty($fieldVal['files'])){
foreach ($fieldVal['files'] as $v){
if(!empty($v)){
if(is_array($v)){
$val_files=array_merge($val_files,$v);
}else{
$val_files[]=$v;
}
}
}
if(!empty($val_files)){
$val_files=array_unique($val_files);
$val_files=array_filter($val_files);
$val_files=array_values($val_files);
}
}
$val_list[$fieldName]=array('name'=>$fieldName,'value'=>$val_values,'img'=>$val_imgs,'file'=>$val_files);
}
}else{
@ -1529,17 +1605,24 @@ class Cpattern extends CpatternEvent{
$val_values=$fieldVals['values'][$page_key][$loop_index];
$val_imgs=$fieldVals['imgs'][$page_key][$loop_index];
$val_files=$fieldVals['files'][$page_key][$loop_index];
}else{
$val_values=$fieldVals['values'][$page_key];
$val_imgs=$fieldVals['imgs'][$page_key];
$val_files=$fieldVals['files'][$page_key];
}
if(!empty($val_imgs)){
$val_imgs=array_unique($val_imgs);
$val_imgs=array_filter($val_imgs);
$val_imgs=array_values($val_imgs);
}
$vals[$fieldName]=array('name'=>$fieldName,'value'=>$val_values,'img'=>$val_imgs);
if(!empty($val_files)){
$val_files=array_unique($val_files);
$val_files=array_filter($val_files);
$val_files=array_values($val_files);
}
$vals[$fieldName]=array('name'=>$fieldName,'value'=>$val_values,'img'=>$val_imgs,'file'=>$val_files);
}
$val_list[]=$vals;
}
@ -1555,6 +1638,9 @@ class Cpattern extends CpatternEvent{
foreach ($processList as $k=>$v){
if('replace'==$v['module']){
$v['replace_from']=$this->correct_reg_pattern($v['replace_from']);
}elseif('download'==$v['module']){
$v['download_file_must']=$this->correct_reg_pattern($v['download_file_must']);
$v['download_file_ban']=$this->correct_reg_pattern($v['download_file_ban']);
}
$processList[$k]=$v;
}

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

@ -18,6 +18,7 @@ class CpatternBase extends CollectBase{
public function init($config){}
public function collect($num=10){}
/*正则规则匹配数据*/
public function rule_module_rule_data($configParams,$html,$parentMatches=array(),$whole=false,$returnMatch=false){
$val=null;
@ -125,6 +126,22 @@ class CpatternBase extends CollectBase{
return $val;
}
}
public function rule_module_rule_data_get($configParams,$html,$parentMatches=array(),$whole=false,$returnMatch=false){
init_array($configParams);
$rule=$this->convert_sign_match($configParams['rule']);
$rule=$this->correct_reg_pattern($rule);
$ruleMerge=$this->set_merge_default($rule, $configParams['rule_merge']);
if(empty($ruleMerge)){
$ruleMerge=cp_sign('match');
}
$configParams['rule']=$rule;
$configParams['rule_merge']=$ruleMerge;
return $this->rule_module_rule_data($configParams,$html,$parentMatches,$whole,$returnMatch);
}
/*拼接替换标签*/
public function merge_match_signs($matches,$merge){
if(!is_array($matches)){
@ -160,6 +177,7 @@ class CpatternBase extends CollectBase{
public function rule_module_xpath_data($configParams,$html){
$vals='';
if(!empty($configParams['xpath'])){
$html=$this->filter_html_tags($html,array('script'));
$dom=new \DOMDocument;
$libxml_previous_state = libxml_use_internal_errors(true);
@$dom->loadHTML('<meta http-equiv="Content-Type" content="text/html;charset=utf-8">'.$html);
@ -297,7 +315,7 @@ class CpatternBase extends CollectBase{
}else{
if($key!='*'){
$val=$val[$key];
$val=is_array($val)?$val[$key]:'';
}
}
$prevKey=$key;
@ -456,8 +474,12 @@ class CpatternBase extends CollectBase{
}
/*修正规则中的正则表达式*/
public function correct_reg_pattern($str){
$str=preg_replace('/\\\*([\'\/])/', "\\\\$1",$str);
$str=$this->convert_sign_wildcard($str);
if(isset($str)){
$str=preg_replace('/\\\*([\'\/])/', "\\\\$1",$str);
$str=$this->convert_sign_wildcard($str);
}else{
$str='';
}
return $str;
}
/*转换(*)通配符*/
@ -543,7 +565,7 @@ class CpatternBase extends CollectBase{
/*保存数据处理时过滤配置参数*/
public function set_process($processList){
if(is_array($processList)){
$processList=\util\Funcs::array_array_map('trim',$processList);
$processList=trim_input_process(null,$processList);
foreach ($processList as $k=>$v){
init_array($v);
$v['module']=strtolower($v['module']);
@ -573,6 +595,8 @@ class CpatternBase extends CollectBase{
}elseif('if'==$v['module']){
init_array($v['if_addon']);
\util\Funcs::filter_key_val_list5($v['if_cond'],$v['if_logic'],$v['if_val'],$v['if_addon']['func'],$v['if_addon']['turn']);
}elseif('download'==$v['module']){
$v['download_file_tag']=\skycaiji\admin\model\Config::process_tag_attr($v['download_file_tag']);
}
$processList[$k]=$v;
}

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

@ -40,22 +40,28 @@ class CpatternColl extends CpatternBase{
public $show_opened_tools=false;
protected $cache_page_htmls=array();
protected $cache_page_urls=array();
protected $field_url_complete=true;
protected $field_down_img=true;
/*对象销毁时处理*/
public function __destruct(){
$usedContUrls=array();
if(!empty($this->used_cont_urls)){
$usedContUrls=array_keys($this->used_cont_urls);
if(!empty($usedContUrls)&&is_array($usedContUrls)){
$total=count($usedContUrls);
$limit=100;
$batch=ceil($total/$limit);
for($i=1;$i<=$batch;$i++){
$list=array_slice($usedContUrls,($i-1)*$limit,$limit);
if(!empty($list)){
CacheModel::getInstance('cont_url')->deleteCache($list);
}
init_array($usedContUrls);
}
if($this->cur_cont_url){
$usedContUrls[]=md5($this->cur_cont_url);
}
if(!empty($usedContUrls)){
$total=count($usedContUrls);
$limit=100;
$batch=ceil($total/$limit);
for($i=1;$i<=$batch;$i++){
$list=array_slice($usedContUrls,($i-1)*$limit,$limit);
if(!empty($list)){
CacheModel::getInstance('cont_url')->deleteCache($list);
}
}
}
@ -246,6 +252,16 @@ class CpatternColl extends CpatternBase{
$doBan=true;
}
$urlCharset='';
if(!empty($this->config['url_encode'])){
$urlWebConfig=$this->get_page_config($pageType,$pageName,'url_web');
$urlCharset=$this->page_url_web_charset($urlWebConfig);
if(empty($urlCharset)||in_array($urlCharset,array('auto','utf-8','utf8'))){
$urlCharset='';
}
}
$urlMatchesMd5s=array();
@ -291,6 +307,22 @@ class CpatternColl extends CpatternBase{
$doDelete=true;
}
if(!$doDelete&&!empty($this->config['url_encode'])){
$contUrl=preg_replace_callback('/[^\x21-\x7E]+/',function($mstr)use($urlCharset){
$mstr=$mstr[0];
if(!empty($urlCharset)){
$mstr=\util\Funcs::convert_charset($mstr,'utf-8',$urlCharset);
}
$mstr=rawurlencode($mstr);
return $mstr;
},$contUrl);
$cont_urls[$k]=$contUrl;
}
if(!$doDelete&&strpos($contUrl,' ')!==false){
$doDelete=true;
@ -1170,7 +1202,6 @@ class CpatternColl extends CpatternBase{
}
/*获取页面代码*/
public function get_page_html($url,$pageType,$pageName,$isPagination=false,$returnInfo=false){
$pageName=$pageName?$pageName:'';
@ -1184,7 +1215,7 @@ class CpatternColl extends CpatternBase{
if(!empty($pageSource)){
$useCookie=\util\Param::get_gsc_use_cookie(false,true);
$useCookie=\util\Param::get_gsc_use_cookie('',true);
if($openUrlWeb){
$headers=$this->arrays_to_key_val($urlWebConfig['header_names'], $urlWebConfig['header_vals']);
@ -1522,14 +1553,9 @@ class CpatternColl extends CpatternBase{
}
}else{
$options['curlopts']=$otherConfig['curlopts'];
init_array($options['curlopts']);
$confMaxRedirs=g_sc_c('caiji','max_redirs');
$confMaxRedirs=intval($confMaxRedirs);
if($confMaxRedirs>0){
$options['curlopts'][CURLOPT_MAXREDIRS]=$confMaxRedirs;
}
$options['max_redirs']=g_sc_c('caiji','max_redirs');
$htmlInfo=get_html($url,$headers,$options,$charset,$postData,true);
}
init_array($htmlInfo);

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

@ -378,6 +378,7 @@ class CpatternEvent extends CpatternColl{
return $fieldVal;
}
public function process_f_replace($fieldVal,$params){
return preg_replace('/'.$params['replace_from'].'/ui',$params['replace_to'], $fieldVal);
}
public function process_f_tool($fieldVal,$params){
@ -391,11 +392,107 @@ class CpatternEvent extends CpatternColl{
$fieldVal=trim($fieldVal);
}
if(in_array('is_img', $params['tool_list'])){
if(in_array('url_not_complete', $params['tool_list'])){
$this->field_url_complete=false;
}
return $fieldVal;
}
public function process_f_download($fieldVal,$params,$curUrlMd5,$loopIndex,$contUrlMd5,$fieldName=''){
if($params['download_op']=='is_img'){
if(!is_empty(g_sc_c('download_img','download_img'))&&!empty($fieldVal)){
$valImgs=array();
if(preg_match_all('/(?<![\'\"])(\bhttp[s]{0,1}\:\/\/[^\s\'\"\<\>]+)(?![\'\"])/i',$fieldVal,$murls)){
$valImgs=$murls[1];
}
if(!empty($valImgs)){
$fieldImgs=array();
if(empty($this->first_loop_field)){
$fieldImgs=$this->field_val_list[$fieldName]['imgs'][$curUrlMd5];
}else{
$fieldImgs=$this->field_val_list[$fieldName]['imgs'][$curUrlMd5][$loopIndex];
}
init_array($fieldImgs);
$fieldImgs=array_merge($fieldImgs,$valImgs);
$fieldImgs=array_unique($fieldImgs);
$fieldImgs=array_values($fieldImgs);
if(empty($this->first_loop_field)){
$this->field_val_list[$fieldName]['imgs'][$curUrlMd5]=$fieldImgs;
}else{
$this->field_val_list[$fieldName]['imgs'][$curUrlMd5][$loopIndex]=$fieldImgs;
}
}
}
}elseif($params['download_op']=='no_img'){
$this->field_down_img=false;
if(!is_empty(g_sc_c('download_img','download_img'))){
if(empty($this->first_loop_field)){
$this->field_val_list[$fieldName]['imgs'][$curUrlMd5]=array();
}else{
$this->field_val_list[$fieldName]['imgs'][$curUrlMd5][$loopIndex]=array();
}
}elseif($params['download_op']=='is_file'||$params['download_op']=='file'){
if(!is_empty(g_sc_c('download_file','download_file'))&&!empty($fieldVal)){
$fieldVal=preg_replace('/(?<![\'\"])(\bhttp[s]{0,1}\:\/\/[^\s\'\"\<\>]+)(?![\'\"])/i','{[img]}'."$1".'{[/img]}',$fieldVal);
$valFiles=array();
if($params['download_op']=='is_file'){
if(preg_match_all('/(?<![\'\"])(\bhttp[s]{0,1}\:\/\/[^\s\'\"\<\>]+)(?![\'\"])/i',$fieldVal,$murls)){
$valFiles=$murls[1];
}
}else{
$tags=\skycaiji\admin\model\Config::process_tag_attr($params['download_file_tag'],true);
if(is_array($tags)&&!empty($tags[0])){
for($i=0;$i<count($tags[0]);$i++){
$reg='/<'.$tags[1][$i].'\b[^<>]*\b'.$tags[2][$i].'\s*=\s*[\'\"](http[s]{0,1}\:[^\'\"]+?)[\'\"]/i';
if(preg_match_all($reg,$fieldVal,$fileUrls)){
$fileUrls=is_array($fileUrls[1])?$fileUrls[1]:array();
if(!empty($params['download_file_must'])){
foreach ($fileUrls as $k=>$v){
if(!preg_match('/'.$params['download_file_must'].'/ui', $v)){
unset($fileUrls[$k]);
}
}
}
if(!empty($params['download_file_ban'])){
foreach ($fileUrls as $k=>$v){
if(preg_match('/'.$params['download_file_ban'].'/ui', $v)){
unset($fileUrls[$k]);
}
}
}
$valFiles=array_merge($valFiles,$fileUrls);
}
}
}
}
if(!empty($valFiles)){
$fieldFiles=array();
if(empty($this->first_loop_field)){
$fieldFiles=$this->field_val_list[$fieldName]['files'][$curUrlMd5];
}else{
$fieldFiles=$this->field_val_list[$fieldName]['files'][$curUrlMd5][$loopIndex];
}
init_array($fieldFiles);
$fieldFiles=array_merge($fieldFiles,$valFiles);
$fieldFiles=array_unique($fieldFiles);
$fieldFiles=array_values($fieldFiles);
if(empty($this->first_loop_field)){
$this->field_val_list[$fieldName]['files'][$curUrlMd5]=$fieldFiles;
}else{
$this->field_val_list[$fieldName]['files'][$curUrlMd5][$loopIndex]=$fieldFiles;
}
}
}
}
return $fieldVal;
@ -839,7 +936,32 @@ class CpatternEvent extends CpatternColl{
if(!empty($htmlInfo['ok'])){
$retryCur=0;
$fieldVal=$this->rule_module_json_data(array('json'=>$params['api_json'],'json_arr'=>$params['api_json_arr'],'json_arr_implode'=>$params['api_json_implode']),$htmlInfo['html']);
if(empty($params['api_rule_module'])){
$fieldVal=$this->rule_module_json_data(array(
'json' => $params['api_json'],
'json_arr' => $params['api_json_arr'],
'json_arr_implode' => $params['api_json_arr_implode']
),$htmlInfo['html']);
}elseif('xpath'==$params['api_rule_module']){
$fieldVal=$this->rule_module_xpath_data(array(
'xpath' => $params['api_xpath'],
'xpath_attr' => $params['api_xpath_attr'],
'xpath_multi' => $params['api_xpath_multi'],
'xpath_multi_str' => $params['api_xpath_multi_str'],
),$htmlInfo['html']);
}elseif('rule'==$params['api_rule_module']){
$fieldVal=$this->rule_module_rule_data_get(array(
'rule' => $params['api_rule'],
'rule_merge' => $params['api_rule_merge'],
'rule_multi' => $params['api_rule_multi'],
'rule_multi_str' => $params['api_rule_multi_str'],
'rule_flags'=>'iu',
),$htmlInfo['html'],array(),true);
}
}else{
$this->retry_first_echo($retryCur,'数据处理»调用接口失败',$url,$htmlInfo);
@ -858,7 +980,7 @@ class CpatternEvent extends CpatternColl{
if(empty($process)){
return $fieldVal;
}
static $conds=array('filter','if','func','api');
static $conds=array('filter','if','func','api','download');
foreach ($process as $params){
if(empty($this->first_loop_field)){
@ -989,6 +1111,7 @@ class CpatternEvent extends CpatternColl{
}
}
private function _get_insert_fields($paramsStr,$curUrlMd5,$loopIndex){
$fieldRule='/\[\x{5b57}\x{6bb5}\:(.+?)\]/u';
$fields=array();

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

@ -71,7 +71,7 @@ class Rcms extends Release{
$addedNum=0;
foreach ($collFieldsList as $collFieldsKey=>$collFields){
$this->init_download_img($this->task,$collFields['fields']);
$this->init_download_config($this->task,$collFields['fields']);
$return=$releCms->runExport($collFields['fields']);
if($return['id']>0){
$addedNum++;

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

@ -111,7 +111,7 @@ class Rdb extends Release{
$contTitle=$collFields['title'];
$contUrl=$collFields['url'];
$collFields=$collFields['fields'];
$this->init_download_img($this->task,$collFields);
$this->init_download_config($this->task,$collFields);
$dbTables=$this->config['db_tables'];
$errorMsg=false;

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

@ -81,7 +81,7 @@ class Rdiy extends Release{
$releDiy->db()->startTrans();
$errorMsg=false;
$contUrl=$collFields['url'];
$this->init_download_img($this->task,$collFields['fields']);
$this->init_download_config($this->task,$collFields['fields']);
try {
$return=$releDiy->runExport($contUrl,$collFields['fields']);
if(empty($return)){

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

@ -55,12 +55,12 @@ class ReleaseBase extends CollectBase{
'target' => '',
'desc'=>'',
'error' => $returnData['error'],
'task_id' => $release ['task_id'],
'task_id' => $release['task_id'],
'release' => $release['module'],
'addtime'=>time()
));
}
$this->echo_msg(array('%s',$returnData['error']),'red',$echo);
$this->echo_msg(array('发布失败:%s',$returnData['error']),'red',$echo);
}
}
@ -106,8 +106,37 @@ class ReleaseBase extends CollectBase{
}
}
}
if(!is_empty(g_sc_c('download_file','download_file'))){
if(!empty($collFieldVal['file'])){
if(!is_array($collFieldVal['file'])){
$collFieldVal['file']=array($collFieldVal['file']);
}
$total=count($collFieldVal['file']);
if($total>0){
$this->echo_msg(array('正在下载:%s » %s个文件',$collFieldVal['name'],$total),'black');
}
$curI=0;
foreach ($collFieldVal['file'] as $fileUrl){
$this->collect_stopped(g_sc('collect_task_id'));
$newFileUrl=$this->download_file($fileUrl);
if($newFileUrl!=$fileUrl){
$val=str_replace($fileUrl, $newFileUrl, $val);
}
$curI++;
if($curI<$total){
$this->collect_sleep(g_sc_c('download_file','file_interval'),true);
}
}
}
}
return $val;
}
/*下载图片*/
private $cache_img_list=array();
public function download_img($url){
@ -115,12 +144,9 @@ class ReleaseBase extends CollectBase{
static $imgPaths=array();
static $imgUrls=array();
$originalUrl=$url;
$retryMax=intval(g_sc_c('download_img','retry'));
$retryParams=null;
if($retryMax>0){
$retryParams=array(0=>$url);
}
$img_path=g_sc_c('download_img','img_path');
$img_url=g_sc_c('download_img','img_url');
@ -193,7 +219,7 @@ class ReleaseBase extends CollectBase{
static $imgSuffixes=null;
if(!isset($imgSuffixes)){
$imgSuffixes=array('jpg','jpeg','gif','png','bmp');
$imgSuffixes=array('jpg','jpeg','gif','png','bmp','webp','wbmp');
$moreSuffix=g_sc_c('download_img','more_suffix');
if(!empty($moreSuffix)){
$moreSuffix=explode(',', $moreSuffix);
@ -217,11 +243,7 @@ class ReleaseBase extends CollectBase{
}
}else{
if(preg_match('/\.([a-zA-Z][\w\-]+)([\?\#]|$)/',$url,$prop)){
$prop=strtolower($prop[1]);
}else{
$prop='';
}
$prop=\util\Funcs::get_url_suffix($url);
}
if(!in_array($prop, $imgSuffixes)){
@ -243,7 +265,7 @@ class ReleaseBase extends CollectBase{
$imgname=substr($key,0,2).'/'.substr($key,-2,2).'/'.$key.'.'.$prop;
$filename=$img_path.$imgname;
$filename=$this->_convert_img_charset($filename);
$filename=$this->_convert_file_charset($filename,true);
$isExists=file_exists($filename);
if(!$isExists){
@ -251,7 +273,7 @@ class ReleaseBase extends CollectBase{
$imgname=substr($key,0,2).'/'.substr($key,2).'.'.$prop;
$filename=$img_path.$imgname;
$filename=$this->_convert_img_charset($filename);
$filename=$this->_convert_file_charset($filename,true);
$isExists=file_exists($filename);
}
}elseif('custom'==$imgname){
@ -268,13 +290,13 @@ class ReleaseBase extends CollectBase{
$customName=model('Config')->convert_img_name_name($customName,$url);
$imgname=$customPath.'/'.$customName.'.'.$prop;
$filename=$img_path.$imgname;
$filename=$this->_convert_img_charset($filename);
$filename=$this->_convert_file_charset($filename,true);
$isExists=file_exists($filename);
}else{
$imgname=date('Y-m-d',time()).'/'.$key.'.'.$prop;
$filename=$img_path.$imgname;
$filename=$this->_convert_img_charset($filename);
$filename=$this->_convert_file_charset($filename,true);
$isExists=file_exists($filename);
}
$imgurl=$img_url.$imgname;
@ -292,7 +314,7 @@ class ReleaseBase extends CollectBase{
try {
$headers=array();
$useCookieImg=\util\Param::get_gsc_use_cookie(true,true);
$useCookieImg=\util\Param::get_gsc_use_cookie('img',true);
if(!is_empty(g_sc('task_img_headers'))){
$headers=g_sc('task_img_headers');
@ -309,6 +331,8 @@ class ReleaseBase extends CollectBase{
if(!is_empty(g_sc_c('download_img','img_timeout'))){
$options['timeout']=g_sc_c('download_img','img_timeout');
}else{
$options['timeout']=300;
}
if(!is_empty(g_sc_c('download_img','img_max'))){
@ -334,7 +358,6 @@ class ReleaseBase extends CollectBase{
$imgname.='.'.$mImgProp;
$imgurl.='.'.$mImgProp;
$filename.='.'.$mImgProp;
if(file_exists($filename)){
$isExists=true;
@ -347,6 +370,59 @@ class ReleaseBase extends CollectBase{
if(!$isExists){
if(write_dir_file($filename,$imgCodeInfo['html'])){
$this->cache_img_list[$key]=$imgurl;
$imgCodeInfo=null;
if(!is_empty(g_sc_c('download_img','img_watermark'))){
$imgWmLogo=g_sc_c('download_img','img_wm_logo');
if($imgWmLogo){
$imgWmLogo=config('root_path').$imgWmLogo;
if(file_exists($imgWmLogo)){
$imgInfoWm=getimagesize($imgWmLogo);
$imgInfoImg=getimagesize($filename);
$imgPropWm=str_replace('image/','',strtolower($imgInfoWm['mime']?:''));
$imgPropImg=str_replace('image/','',strtolower($imgInfoImg['mime']?:''));
$imgPropWm=$imgPropWm=='jpg'?'jpeg':$imgPropWm;
$imgPropImg=$imgPropImg=='jpg'?'jpeg':$imgPropImg;
if($imgPropWm&&$imgPropImg){
$funcImage='image'.$imgPropImg;
if(function_exists('imagecreatefromstring')){
if(function_exists($funcImage)){
$icfWm=imagecreatefromstring(file_get_contents($imgWmLogo));
$icfImg=imagecreatefromstring(file_get_contents($filename));
$cWmRight=intval(g_sc_c('download_img','img_wm_right'));
$cWmBottom=intval(g_sc_c('download_img','img_wm_bottom'));
$cWmOpacity=intval(g_sc_c('download_img','img_wm_opacity'));
$cWmOpacity=min(100,max(0,$cWmOpacity));
$cWmRight=$imgInfoImg[0]-$imgInfoWm[0]-$cWmRight;
$cWmBottom=$imgInfoImg[1]-$imgInfoWm[1]-$cWmBottom;
if($cWmOpacity>0){
imagecopymerge($icfImg,$icfWm,$cWmRight,$cWmBottom,0,0,$imgInfoWm[0],$imgInfoWm[1],100-$cWmOpacity);
}else{
imagecopy($icfImg,$icfWm,$cWmRight,$cWmBottom,0,0,$imgInfoWm[0],$imgInfoWm[1]);
}
call_user_func($funcImage,$icfImg,$filename);
imagedestroy($icfWm);
imagedestroy($icfImg);
}else{
$this->echo_msg('添加水印失败,不存在函数:'.$funcImage);
}
}else{
$this->echo_msg('添加水印失败,不存在函数:imagecreatefromstring');
}
}
}else{
$this->echo_msg('不存在水印logo:'.$imgWmLogo);
}
}
}
$funcName=g_sc_c('download_img','img_func');
if(!empty($funcName)){
@ -375,25 +451,7 @@ class ReleaseBase extends CollectBase{
}
}else{
if(!empty($proxyDbIp)){
$this->echo_msg(array('代理IP:%s',$proxyDbIp['ip']),'black',true,'','display:inline;margin-right:5px;');
}
$this->retry_first_echo($retryCur,'图片下载失败',$url,$imgCodeInfo);
if(!empty($proxyDbIp)){
if($imgCodeInfo['code']!=404){
$mproxy->set_ip_failed($proxyDbIp);
}
}
$this->collect_sleep(g_sc_c('download_img','wait'));
if($this->retry_do_func($retryCur,$retryMax,'图片无效')){
return $this->download_img($retryParams[0]);
}
return $this->_down_retry($proxyDbIp, $originalUrl, $retryCur, $retryMax, $imgCodeInfo, true);
}
}catch (\Exception $ex){
@ -406,15 +464,244 @@ class ReleaseBase extends CollectBase{
}
return empty($this->cache_img_list[$key])?$url:$this->cache_img_list[$key];
}
/*下载文件*/
private $cache_file_list=array();
public function download_file($url){
static $retryCur=0;
static $filePaths=array();
static $fileUrls=array();
$originalUrl=$url;
$retryMax=intval(g_sc_c('download_file','retry'));
$file_path=g_sc_c('download_file','file_path');
$file_url=g_sc_c('download_file','file_url');
if(!isset($filePaths[$file_path])){
if(empty($file_path)){
$filePaths[$file_path]=config('root_path').'/data/files/';
}else{
$filePaths[$file_path]=rtrim($file_path,'\/\\').'/';
}
}
$file_path=$filePaths[$file_path];
if(!isset($fileUrls[$file_url])){
if(empty($file_url)){
$fileUrls[$file_url]=config('root_website').'/data/files/';
}else{
$fileUrls[$file_url]=rtrim($file_url,'\/\\').'/';
}
}
$file_url=$fileUrls[$file_url];
if(empty($url)){
return '';
}
$mproxy=model('ProxyIp');
$options=array();
$proxyDbIp=null;
if(!is_empty(g_sc_c('proxy','open'))){
$proxyDbIp=$mproxy->get_usable_ip();
$proxyIp=$mproxy->to_proxy_ip($proxyDbIp);
if(empty($proxyIp)){
$this->echo_msg(array('没有可用的代理IP,跳过下载<a href="%s" target="_blank">文件</a>',$url));
return $url;
}else{
$options['proxy']=$proxyIp;
}
}
if(!is_empty(g_sc_c('caiji','robots'))){
if(!$this->abide_by_robots($url,$options)){
$this->echo_msg(array('robots拒绝访问的网址:%s',$url));
return $url;
}
}
$key=md5($url);
if(!isset($this->cache_file_list[$key])){
$headers=array();
$useCookieFile=\util\Param::get_gsc_use_cookie('file',true);
if(!is_empty(g_sc('task_file_headers'))){
$headers=g_sc('task_file_headers');
if(!is_array($headers)){
$headers=array();
}
}
if(!empty($useCookieFile)){
unset($headers['cookie']);
$headers['cookie']=$useCookieFile;
}
if(!is_empty(g_sc_c('download_file','file_timeout'))){
$options['timeout']=g_sc_c('download_file','file_timeout');
}else{
$options['timeout']=1800;
}
if(!is_empty(g_sc_c('download_file','file_max'))){
$options['max_bytes']=intval(g_sc_c('download_file','file_max'))*1024*1024;
}
$prop=\util\Funcs::get_url_suffix($url);
static $urlProps=array('htm','html','php','asp','jsp');
if(in_array($prop, $urlProps)||empty($prop)){
$options['return_info']=true;
$options['return_head']=true;
$fileCodeInfo=get_html($url,$headers,$options,'utf-8',null,true);
if(!empty($fileCodeInfo['ok'])){
unset($options['max_bytes']);
if($fileCodeInfo['info']['url']){
$url=$fileCodeInfo['info']['url'];
$prop=\util\Funcs::get_url_suffix($url);
}
}else{
return $this->_down_retry($proxyDbIp, $originalUrl, $retryCur, $retryMax, $fileCodeInfo, false);
}
}
if($prop){
$prop='.'.$prop;
}
$filefull='';
$fileurl='';
$isExists=false;
$filename=g_sc_c('download_file','file_name');
if('url'==$filename){
$filename=substr($key,0,2).'/'.substr($key,2).$prop;
$filefull=$file_path.$filename;
$filefull=$this->_convert_file_charset($filefull);
$isExists=file_exists($filefull);
}elseif('custom'==$filename){
$customPath=g_sc_c('download_file','name_custom_path');
if(!is_null(g_sc_c('download_file','_name_custom_path'))){
$customPath=g_sc_c('download_file','_name_custom_path');
}
$customName=g_sc_c('download_file','name_custom_name');
if(!is_null(g_sc_c('download_file','_name_custom_name'))){
$customName=g_sc_c('download_file','_name_custom_name');
}
$customPath=model('Config')->convert_file_name_path($customPath,$url);
$customName=model('Config')->convert_file_name_name($customName,$url);
$filename=$customPath.'/'.$customName.$prop;
$filefull=$file_path.$filename;
$filefull=$this->_convert_file_charset($filefull);
$isExists=file_exists($filefull);
}else{
$filename=date('Y-m-d',time()).'/'.$key.$prop;
$filefull=$file_path.$filename;
$filefull=$this->_convert_file_charset($filefull);
$isExists=file_exists($filefull);
}
$fileurl=$file_url.$filename;
if(!$isExists){
try {
unset($options['return_head']);
$options['return_info']=true;
$fileCodeInfo=get_html($url,$headers,$options,'utf-8',null,true);
if(!empty($fileCodeInfo['ok'])){
$retryCur=0;
if(!empty($fileCodeInfo['html'])){
$mFileProp=\util\Funcs::get_url_suffix($fileCodeInfo['info']['url']);
if($mFileProp){
$mFileProp='.'.$mFileProp;
if($prop!=$mFileProp){
$filename.=$mFileProp;
$fileurl.=$mFileProp;
$filefull.=$mFileProp;
if(file_exists($filefull)){
$isExists=true;
$this->cache_file_list[$key]=$fileurl;
}
}
}
if(!$isExists){
if(write_dir_file($filefull,$fileCodeInfo['html'])){
$this->cache_file_list[$key]=$fileurl;
$funcName=g_sc_c('download_file','file_func');
if(!empty($funcName)){
$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'])){
$this->cache_file_list[$key]=$return['data'];
}
}elseif($return['msg']){
$this->echo_msg(array('%s',$return['msg']));
}
}
}
}
}
}else{
return $this->_down_retry($proxyDbIp, $originalUrl, $retryCur, $retryMax, $fileCodeInfo, false);
}
}catch (\Exception $ex){
}
}else{
$this->cache_file_list[$key]=$fileurl;
}
}
return empty($this->cache_file_list[$key])?$url:$this->cache_file_list[$key];
}
private function _convert_img_charset($filename){
private function _convert_file_charset($filename,$isImg=false){
static $charset=null;
$type=$isImg?'download_img':'download_file';
if(!isset($charset)){
$charset=g_sc_c('download_img','charset');
$charset=g_sc_c($type,'charset');
$charset=empty($charset)?'':strtolower($charset);
if($charset=='custom'){
$charset=g_sc_c('download_img','charset_custom');
$charset=g_sc_c($type,'charset_custom');
$charset=empty($charset)?'':strtolower($charset);
}
if($charset=='utf-8'){
@ -427,6 +714,43 @@ class ReleaseBase extends CollectBase{
}
return $filename;
}
private function _down_retry($proxyDbIp,$url,&$retryCur,$retryMax,$htmlInfo,$isImg){
$type=$isImg?'图片':'文件';
if(empty($htmlInfo['code'])&&!empty($htmlInfo['msg'])){
$this->echo_msg($htmlInfo['msg'].':'.$url,'black');
return $url;
}
if(!empty($proxyDbIp)){
$this->echo_msg(array('代理IP:%s',$proxyDbIp['ip']),'black',true,'','display:inline;margin-right:5px;');
}
$this->retry_first_echo($retryCur,$type.'下载失败',$url,$htmlInfo);
if(!empty($proxyDbIp)){
if($htmlInfo['code']!=404){
model('ProxyIp')->set_ip_failed($proxyDbIp);
}
}
$this->collect_sleep(g_sc_c(($isImg?'download_img':'download_file'),'wait'));
if($this->retry_do_func($retryCur,$retryMax,$type.'无效')){
if($isImg){
return $this->download_img($url);
}else{
return $this->download_file($url);
}
}
}
/*获取采集器字段*/
public function get_coll_fields($taskId,$taskModule){
static $fieldsList=array();
@ -487,21 +811,17 @@ class ReleaseBase extends CollectBase{
return write_dir_file($filename,$data);
}
/*初始化下载图片*/
public function init_download_img($taskData,$collFields){
/*初始化下载配置*/
public function init_download_config($taskData,$collFields){
init_array($taskData);
init_array($collFields);
if(!is_empty(g_sc_c('download_img','download_img'))&&g_sc_c('download_img','img_name')=='custom'){
if(empty($taskData)){
$taskData=array();
}
if(empty($collFields)){
$collFields=array();
}
$name_custom_path=g_sc_c('download_img','name_custom_path');
$check=model('Config')->check_img_name_path($name_custom_path);
if($check['success']){
$name_custom_path=$this->_convert_img_params($name_custom_path, $taskData, $collFields);
$name_custom_path=$this->_convert_download_params($name_custom_path, $taskData, $collFields);
}else{
$name_custom_path='temp';
}
@ -512,7 +832,7 @@ class ReleaseBase extends CollectBase{
$name_custom_name=g_sc_c('download_img','name_custom_name');
$check=model('Config')->check_img_name_name($name_custom_name);
if($check['success']){
$name_custom_name=$this->_convert_img_params($name_custom_name, $taskData, $collFields);
$name_custom_name=$this->_convert_download_params($name_custom_name, $taskData, $collFields);
}else{
$name_custom_name='';
}
@ -523,9 +843,38 @@ class ReleaseBase extends CollectBase{
set_g_sc(['c','download_img','_name_custom_path'],null);
set_g_sc(['c','download_img','_name_custom_name'],null);
}
if(!is_empty(g_sc_c('download_file','download_file'))&&g_sc_c('download_file','file_name')=='custom'){
$name_custom_path=g_sc_c('download_file','name_custom_path');
$check=model('Config')->check_file_name_path($name_custom_path);
if($check['success']){
$name_custom_path=$this->_convert_download_params($name_custom_path, $taskData, $collFields);
}else{
$name_custom_path='temp';
}
set_g_sc(['c','download_file','_name_custom_path'],$name_custom_path);
$name_custom_name=g_sc_c('download_file','name_custom_name');
$check=model('Config')->check_file_name_name($name_custom_name);
if($check['success']){
$name_custom_name=$this->_convert_download_params($name_custom_name, $taskData, $collFields);
}else{
$name_custom_name='';
}
set_g_sc(['c','download_file','_name_custom_name'],$name_custom_name);
}else{
set_g_sc(['c','download_file','_name_custom_path'],null);
set_g_sc(['c','download_file','_name_custom_name'],null);
}
}
private function _convert_img_params($str,$taskData,$collFields){
private function _convert_download_params($str,$taskData,$collFields){
if(empty($taskData)){
$taskData=array();
}

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

@ -83,7 +83,7 @@ class Rfile extends Release {
foreach ($collFieldsList as $collFieldsKey=>$collFields){
$this->init_download_img($this->task,$collFields['fields']);
$this->init_download_config($this->task,$collFields['fields']);
$this->hide_coll_fields($hideFields, $collFields);
$addedNum++;
$curRow=$rowNum+$addedNum;
@ -121,7 +121,7 @@ class Rfile extends Release {
foreach ($collFieldsList as $collFieldsKey=>$collFields){
$this->init_download_img($this->task,$collFields['fields']);
$this->init_download_config($this->task,$collFields['fields']);
$this->hide_coll_fields($hideFields, $collFields);
$addedNum++;
$fieldVals=array();

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

@ -128,6 +128,8 @@ class Rtoapi extends Release{
$headerVals[$v]=$this->config['toapi']['header_val'][$k];
}
}
$apiConfig['response']=$this->config['toapi']['response'];
}
return $this->_export($collFieldsList,$options,$apiUrl,$apiConfig,$paramVals,$headerVals);
}
@ -155,12 +157,15 @@ class Rtoapi extends Release{
}else{
$apiUrl=$this->url_list[$apiUrlMd5];
}
$apiResponse=is_array($apiConfig['response'])?$apiConfig['response']:array();
$apiResponse['id']=$apiResponse['id']?:'id';
$apiResponse['target']=$apiResponse['target']?:'target';
$apiResponse['desc']=$apiResponse['desc']?:'desc';
$apiResponse['error']=$apiResponse['error']?:'error';
if(empty($apiResponse['module'])){
$apiResponse['id']=$apiResponse['id']?:'id';
$apiResponse['target']=$apiResponse['target']?:'target';
$apiResponse['desc']=$apiResponse['desc']?:'desc';
$apiResponse['error']=$apiResponse['error']?:'error';
}
$apiCharset=$apiConfig['charset'];
if(empty($apiCharset)){
@ -175,12 +180,16 @@ class Rtoapi extends Release{
$retryWait=intval($this->config['toapi']['wait']);
$retryMax=intval($this->config['toapi']['retry']);
static $cpatternBase=null;
if(!isset($cpatternBase)){
$cpatternBase=controller('CpatternBase','event');
}
foreach ($collFieldsList as $collFieldsKey=>$collFields){
$contTitle=$collFields['title'];
$contUrl=$collFields['url'];
$collFields=$collFields['fields'];
$this->init_download_img($this->task,$collFields);
$this->init_download_config($this->task,$collFields);
$postData=$this->_replace_fields($paramVals,$collFields);
$url=$this->_replace_fields($apiUrl,$collFields);
@ -203,18 +212,48 @@ class Rtoapi extends Release{
init_array($htmlInfo);
$html=$htmlInfo['html']?:'';
$this->collect_sleep($this->config['toapi']['interval'],true);
$json=json_decode($html,true);
$returnData=array('id'=>'','target'=>'','desc'=>'','error'=>'');
if(!empty($apiResponse['id'])&&is_array($json)&&isset($json[$apiResponse['id']])){
if(empty($apiResponse['module'])){
$json=json_decode($html,true);
foreach ($returnData as $k=>$v){
if(isset($apiResponse[$k])){
$returnData[$k]=$json[$apiResponse[$k]]?$json[$apiResponse[$k]]:'';
}else{
$returnData[$k]='';
$returnData[$k]=$cpatternBase->rule_module_json_data(array(
'json' => $apiResponse[$k],
'json_arr' => '',
'json_arr_implode' => '',
), $json);
}
}
}elseif($apiResponse['module']=='xpath'){
foreach ($returnData as $k=>$v){
if(isset($apiResponse[$k])){
$returnData[$k]=$cpatternBase->rule_module_xpath_data(array(
'xpath' => $apiResponse[$k],
'xpath_attr' => 'innerHtml',
'xpath_multi' => '',
'xpath_multi_str' => '',
), $html);
}
}
}elseif($apiResponse['module']=='rule'){
foreach ($returnData as $k=>$v){
if(isset($apiResponse[$k])){
$returnData[$k]=$cpatternBase->rule_module_rule_data_get(array(
'rule' => $apiResponse[$k],
'rule_merge' => '',
'rule_multi' => '',
'rule_multi_str' => '',
'rule_flags'=>'iu',
), $html,array(),true);
}
}
}
if(!is_empty($apiResponse['id'],true)&&$html&&!is_empty($returnData['id'],true)){
if($returnData['id']>0){
$addedNum++;
if($returnData['id']>1&&empty($returnData['target'])){
@ -224,23 +263,23 @@ class Rtoapi extends Release{
}
}else{
$this->retry_first_echo($retryCur,'发布设置»调用接口失败',null,$htmlInfo);
$this->retry_first_echo($retryCur,'发布接口调用失败',null,$htmlInfo);
$this->collect_sleep($retryWait);
if($this->retry_do_func($retryCur,$retryMax,'接口无效')){
if($this->retry_do_func($retryCur,$retryMax,'发布接口无效')){
$doWhile=true;
}
$returnData['id']=0;
$returnData['error']='发布接口无响应状态';
$returnData['error']='未获取到响应状态';
}
}while($doWhile);
$this->record_collected($contUrl,$returnData,$this->release,$contTitle);
if($testToapi){
$this->echo_msg('<p>发布接口响应数据</p><textarea name="data" style="width:100%;margin:5px 0;" rows="5">'.htmlspecialchars($html).'</textarea>','black');
$this->echo_msg('<p>发布接口响应内容</p><textarea name="data" style="width:100%;margin:5px 0;" rows="5">'.htmlspecialchars($html).'</textarea>','black');
}

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

@ -48,19 +48,14 @@ return array(
'setting_store'=>'云端设置',
'store_authkey_error'=>'通信密钥只能由字母和数字组成且长度在6-100位之间',
'down_file_name_'=>'按时间生成(方便日期归类)',
'down_file_name_time'=>'按时间生成(方便日期归类)',
'down_file_name_url'=>'按网址生成(防止重复下载)',
'down_file_name_custom'=>'自定义',
'down_img_m_'=>'本地存储',
'down_img_m_loc'=>'本地存储',
'down_img_m_func'=>'使用函数',
'down_img_name_'=>'按时间生成(方便日期归类)',
'down_img_name_time'=>'按时间生成(方便日期归类)',
'down_img_name_url'=>'按网址生成(防止重复下载)',
'down_img_name_custom'=>'自定义',
'down_file_name_custom_name_'=>'文件网址MD5码',
'down_img_name_custom_name_'=>'图片网址MD5码',
'config_error_none_email'=>'没有邮箱服务器配置,请在后台设置!',
@ -180,7 +175,8 @@ return array(
'process_module_insert'=>'插入内容',
'process_module_replace'=>'内容替换',
'process_module_filter'=>'关键词过滤',
'process_module_if'=>'条件判断',
'process_module_if'=>'条件判断',
'process_module_download'=>'本地化',
'process_module_translate'=>'翻译',
'process_module_tool'=>'工具箱',
'process_module_batch'=>'批量替换',

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

@ -73,31 +73,62 @@ class Collector extends \skycaiji\common\model\BaseModel{
if(is_array($config['field_process'])){
foreach($config['field_process'] as $k=>$v){
$config['field_process'][$k]=$this->_compatible_process_api($v);
$config['field_process'][$k]=$this->_compatible_processes($v);
}
}
if(is_array($config['common_process'])){
$config['common_process']=$this->_compatible_process_api($config['common_process']);
$config['common_process']=$this->_compatible_processes($config['common_process']);
}
return $config;
}
private function _compatible_process_api($processes){
private function _compatible_processes($processes){
if(is_array($processes)){
$processes=array_values($processes);
$toolIsImg=array();
foreach ($processes as $pk=>$pv){
if(is_array($pv)&&$pv['module']=='api'){
if(is_array($pv['api_headers'])&&!isset($pv['api_headers']['addon'])){
if(is_array($pv)){
if($pv['module']=='api'){
if(is_array($pv['api_headers'])&&!isset($pv['api_headers']['addon'])){
$pv['api_headers']['addon']=$pv['api_headers']['val'];
foreach ($pv['api_headers']['val'] as $vk=>$vv){
if($vv){
$pv['api_headers']['val'][$vk]='custom';
}
}
$processes[$pk]=$pv;
}
if(isset($pv['api_json_implode'])){
$pv['api_json_arr_implode']=$pv['api_json_implode'];
unset($pv['api_json_implode']);
$processes[$pk]=$pv;
}
}elseif($pv['module']=='tool'){
$pv['api_headers']['addon']=$pv['api_headers']['val'];
foreach ($pv['api_headers']['val'] as $vk=>$vv){
if($vv){
$pv['api_headers']['val'][$vk]='custom';
if(is_array($pv['tool_list'])){
foreach ($pv['tool_list'] as $k=>$v){
if($v=='is_img'){
$toolIsImg[]=$pk;
unset($pv['tool_list'][$k]);
}
}
$pv['tool_list']=array_values($pv['tool_list']);
$processes[$pk]=$pv;
}
$processes[$pk]=$pv;
}
}
}
if(!empty($toolIsImg)){
$count=0;
foreach ($toolIsImg as $k){
array_splice($processes,$k+1+$count,0,array(array('title'=>'','module'=>'download','download_op'=>'is_img')));
$count++;
}
}
}
return $processes;
}
@ -259,7 +290,7 @@ class Collector extends \skycaiji\common\model\BaseModel{
return $lockList;
}
/*触发运行自动采集*/
public static function collect_run_auto($rootUrl=''){
public static function collect_run_auto($rootUrl='',$taskIds=null){
try{
$url='';
@ -269,6 +300,11 @@ class Collector extends \skycaiji\common\model\BaseModel{
$url=url('admin/index/auto_collect',null,false,true);
}
$url.=(strpos($url, '?')===false?'?':'&').'backstage_run=1&key='.\util\Param::set_cache_key('auto_collect');
if($taskIds&&is_array($taskIds)){
$taskIds=implode(',', $taskIds);
$url.='&task_ids='.rawurlencode($taskIds);
}
get_html($url,null,array('timeout'=>3));
}catch(\Exception $ex){}
}

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

@ -53,160 +53,27 @@ class Config extends \skycaiji\common\model\Config {
/*检查图片路径*/
public function check_img_path($imgPath){
$result=return_result('',false);
if(!empty($imgPath)){
if(!preg_match('/(^\w+\:)|(^[\/\\\])/i', $imgPath)){
$result['msg']='图片目录必须为绝对路径!';
}else{
if(!is_dir($imgPath)){
$result['msg']='图片目录不存在!'.(self::check_basedir_limited($imgPath)?lang('error_open_basedir'):'');
}else{
$imgPath=realpath($imgPath);
$root_path=rtrim(realpath(config('root_path')),'\\\/');
if(preg_match('/^'.addslashes($root_path).'\b/i',$imgPath)){
if(!preg_match('/^'.addslashes($root_path).'[\/\\\]data[\/\\\].+/i', $imgPath)){
$result['msg']='图片保存到本程序中,目录必须在data文件夹里';
}else{
$result['success']=true;
}
}else{
$result['success']=true;
}
}
}
}
return $result;
return $this->_check_file_path(true,$imgPath);
}
/*检查图片网址*/
public function check_img_url($imgUrl){
$result=return_result('',false);
if(!empty($imgUrl)){
if(!preg_match('/^\w+\:\/\//i',$imgUrl)){
$result['msg']='图片链接地址必须以http://或者https://开头';
}else{
$result['success']=true;
}
}
return $result;
return $this->_check_file_url(true,$imgUrl);
}
/*检查自定义图片名的路径设置*/
public function check_img_name_path($path){
static $check_list=array();
$pathMd5=md5($path);
if(!isset($check_list[$pathMd5])){
$result=return_result('',false);
if(!empty($path)){
if(!preg_match('/^(\w+|\-|\/|(\[(年|月|日|时|分|秒|前两位|后两位|任务名|任务ID)\])|(\[字段\:[^\/\[\]]+?\]))+$/u',$path)){
$result['msg']='图片名称自定义路径只能输入字母、数字、下划线、/ 或 使用标签';
}else{
if(preg_match('/^\/+$/', $path)){
$result['msg']='图片名称自定义路径不能只由/组成';
}else{
$result['success']=true;
}
}
}
$check_list[$pathMd5]=$result;
}else{
$result=$check_list[$pathMd5];
}
return $result;
return $this->_check_file_name_path(true,$path);
}
/*转换自定义图片名的路径*/
public function convert_img_name_path($path,$url){
if(!empty($path)){
$md5=md5($url);
static $tags=array('[年]','[月]','[日]','[时]','[分]','[秒]','[前两位]','[后两位]');
$nowTime=time();
$tagsRe=array(
date('Y',$nowTime),
date('m',$nowTime),
date('d',$nowTime),
date('H',$nowTime),
date('i',$nowTime),
date('s',$nowTime),
substr($md5,0,2),
substr($md5,-2,2),
);
$path=str_replace($tags, $tagsRe, $path);
$path=preg_replace('/[\s\r\n\~\`\!\@\#\$\%\^\&\*\(\)\+\=\{\}\[\]\|\\\\:\;\"\'\<\>\,\?]+/', '_', $path);
$path=preg_replace('/\_{2,}/', '_', $path);
$path=preg_replace('/\/{2,}/', '/', $path);
$path=trim($path,'_');
$path=trim($path,'/');
}
if(empty($path)){
$path='temp';
}
return $path;
return $this->_convert_file_name_path(true,$path,$url);
}
/*检查自定义图片名的名称设置*/
public function check_img_name_name($name){
static $check_list=array();
$nameMd5=md5($name);
if(!isset($check_list[$nameMd5])){
$result=return_result('',false);
if(!empty($name)){
if(!preg_match('/^(\w+|\-|(\[(年|月|日|时|分|秒|前两位|后两位|任务名|任务ID|图片网址MD5码|图片原名)\])|(\[字段\:[^\/\[\]]+?\]))+$/u',$name)){
$result['msg']='图片名称自定义名称只能输入字母、数字、下划线 或 使用标签';
}else{
$result['success']=true;
}
}
$check_list[$nameMd5]=$result;
}else{
$result=$check_list[$nameMd5];
}
return $result;
return $this->_check_file_name_name(true,$name);
}
/*转换自定义图片名的名称*/
public function convert_img_name_name($name,$url){
$md5=md5($url);
if(!empty($name)){
$urlname='';
if(preg_match('/([^\/]+?)(\.[a-zA-Z][\w\-]+){0,1}([\?\#]|$)/', $url,$urlname)){
$urlname=$urlname[1];
if(mb_strlen($urlname,'utf-8')>100){
$urlname=mb_substr($urlname,0,100,'utf-8');
}
}else{
$urlname='';
}
if(empty($urlname)){
$urlname=$md5;
}
static $tags=array('[年]','[月]','[日]','[时]','[分]','[秒]','[前两位]','[后两位]','[图片网址MD5码]','[图片原名]');
$nowTime=time();
$tagsRe=array(
date('Y',$nowTime),
date('m',$nowTime),
date('d',$nowTime),
date('H',$nowTime),
date('i',$nowTime),
date('s',$nowTime),
substr($md5,0,2),
substr($md5,-2,2),
$md5,
$urlname
);
$name=str_replace($tags, $tagsRe, $name);
$name=preg_replace('/[\/\s\r\n\~\`\!\@\#\$\%\^\&\*\(\)\+\=\{\}\[\]\|\\\\:\;\"\'\<\>\,\?]+/', '_', $name);
$name=preg_replace('/\_{2,}/', '_', $name);
$name=trim($name,'_');
}
if(empty($name)){
$name=$md5;
}
return $name;
return $this->_convert_file_name_name(true,$name,$url);
}
/*从采集设置中提取出图片本地化设置*/
@ -224,6 +91,70 @@ class Config extends \skycaiji\common\model\Config {
return $config;
}
/*检查文件路径*/
public function check_file_path($filePath){
return $this->_check_file_path(false,$filePath);
}
/*检查文件网址*/
public function check_file_url($fileUrl){
return $this->_check_file_url(false,$fileUrl);
}
/*检查自定义文件名的路径设置*/
public function check_file_name_path($path){
return $this->_check_file_name_path(false,$path);
}
/*转换自定义文件名的路径*/
public function convert_file_name_path($path,$url){
return $this->_convert_file_name_path(false,$path,$url);
}
/*检查自定义文件名的名称设置*/
public function check_file_name_name($name){
return $this->_check_file_name_name(false,$name);
}
/*转换自定义文件名的名称*/
public function convert_file_name_name($name,$url){
return $this->_convert_file_name_name(false,$name,$url);
}
/*上传图片水印logo*/
public function check_img_watermark_logo($formName,$fileName=''){
$result=return_result('',false,array('file_prop'=>'','file_data'));
$imgWmLogo=$_FILES[$formName];
if(!empty($imgWmLogo)&&!empty($imgWmLogo['tmp_name'])){
if(preg_match('/^image\/(jpg|jpeg|gif|png)$/i',$imgWmLogo['type'],$mprop)){
$mprop=strtolower($mprop[1]);
$imgWmLogo=file_get_contents($imgWmLogo['tmp_name']);
if(empty($imgWmLogo)){
$result['msg']='请上传有效的水印logo';
}else{
$result['success']=true;
$result['file_prop']=$mprop;
$result['file_data']=$imgWmLogo;
}
}else{
$result['msg']='仅支持上传 jpg、jpeg、gif、png 格式的水印logo';
}
}else{
$result['success']=true;
}
return $result;
}
public function upload_img_watermark_logo($formName,$fileName=''){
$result=$this->check_img_watermark_logo($formName,$fileName);
if($result['success']){
if($result['file_data']){
$fileName=$fileName?$fileName:'logo';
$result['file_name']='/data/images/watermark/'.$fileName.'.'.$result['file_prop'];
write_dir_file(config('root_path').$result['file_name'], $result['file_data']);
}
}else{
$result['msg']=$result['msg']?:'上传水印logo失败';
}
return $result;
}
/*检测出php可执行文件路径*/
public static function detect_php_exe(){
static $php_filename=null;
@ -361,5 +292,219 @@ class Config extends \skycaiji\common\model\Config {
}
return $seconds;
}
public static function process_suffix($suffix,$returnArr=false){
static $list=array();
$key=md5($suffix);
$data=array();
if(!isset($list[$key])){
if($suffix){
if(preg_match_all('/\b[a-zA-Z]\w*\b/i',$suffix,$msuffix)){
$data=array_unique($msuffix[0]);
$data=array_values($data);
$data=array_map('strtolower', $data);
}
}
$list[$key]=$data;
}
$data=$list[$key];
return $returnArr?$data:implode(',',$data);
}
public static function process_tag_attr($tagAttr,$returnArr=false){
static $list=array();
$key=md5($tagAttr);
$data=array();
if(!isset($list[$key])){
if($tagAttr){
if(preg_match_all('/\b([a-zA-Z]\w*)\:([a-zA-Z]\w*)\b/i',$tagAttr,$mtag)){
$data=array(0=>array(),1=>array(),2=>array());
for($i=0;$i<count($mtag[0]);$i++){
$mtag[0][$i]=strtolower($mtag[0][$i]);
if(!in_array($mtag[0][$i], $data[0])){
$data[0][]=$mtag[0][$i];
$data[1][]=strtolower($mtag[1][$i]);
$data[2][]=strtolower($mtag[2][$i]);
}
}
}
}
$list[$key]=$data;
}
$data=$list[$key];
return $returnArr?$data:implode(',',is_array($data[0])?$data[0]:array());
}
private function _check_file_path($isImg,$filePath){
$title=$isImg?'图片':'文件';
$result=return_result('',false);
if(!empty($filePath)){
if(!preg_match('/(^\w+\:)|(^[\/\\\])/i', $filePath)){
$result['msg']=$title.'目录必须为绝对路径!';
}else{
if(!is_dir($filePath)){
$result['msg']=$title.'目录不存在!'.(self::check_basedir_limited($filePath)?lang('error_open_basedir'):'');
}else{
$filePath=realpath($filePath);
$root_path=rtrim(realpath(config('root_path')),'\\\/');
if(preg_match('/^'.addslashes($root_path).'\b/i',$filePath)){
if(!preg_match('/^'.addslashes($root_path).'[\/\\\]data[\/\\\].+/i', $filePath)){
$result['msg']=$title.'保存到本程序中,目录必须在data文件夹里';
}else{
$result['success']=true;
}
}else{
$result['success']=true;
}
}
}
}
return $result;
}
private function _check_file_url($isImg,$fileUrl){
$title=$isImg?'图片':'文件';
$result=return_result('',false);
if(!empty($fileUrl)){
if(!preg_match('/^\w+\:\/\//i',$fileUrl)){
$result['msg']=$title.'链接地址必须以http://或者https://开头';
}else{
$result['success']=true;
}
}
return $result;
}
private function _check_file_name_path($isImg,$path){
$title=$isImg?'图片':'文件';
static $check_list=array();
$pathMd5=md5($path);
if(!isset($check_list[$pathMd5])){
$result=return_result('',false);
if(!empty($path)){
if(!preg_match('/^(\w+|\-|\/|(\[(年|月|日|时|分|秒|前两位|后两位|任务名|任务ID)\])|(\[字段\:[^\/\[\]]+?\]))+$/u',$path)){
$result['msg']=$title.'名称自定义路径只能输入字母、数字、下划线、/ 或 使用标签';
}else{
if(preg_match('/^\/+$/', $path)){
$result['msg']=$title.'名称自定义路径不能只由/组成';
}else{
$result['success']=true;
}
}
}
$check_list[$pathMd5]=$result;
}else{
$result=$check_list[$pathMd5];
}
return $result;
}
private function _convert_file_name_path($isImg,$path,$url){
if(!empty($path)){
$md5=md5($url);
static $tags=array('[年]','[月]','[日]','[时]','[分]','[秒]','[前两位]','[后两位]');
$nowTime=time();
$tagsRe=array(
date('Y',$nowTime),
date('m',$nowTime),
date('d',$nowTime),
date('H',$nowTime),
date('i',$nowTime),
date('s',$nowTime),
substr($md5,0,2),
substr($md5,-2,2),
);
$path=str_replace($tags, $tagsRe, $path);
$path=preg_replace('/[\s\r\n\~\`\!\@\#\$\%\^\&\*\(\)\+\=\{\}\[\]\|\\\\:\;\"\'\<\>\,\?]+/', '_', $path);
$path=preg_replace('/\_{2,}/', '_', $path);
$path=preg_replace('/\/{2,}/', '/', $path);
$path=trim($path,'_');
$path=trim($path,'/');
}
if(empty($path)){
$path='temp';
}
return $path;
}
private function _check_file_name_name($isImg,$name){
$title=$isImg?'图片':'文件';
static $check_list=array();
$nameMd5=md5($name);
if(!isset($check_list[$nameMd5])){
$result=return_result('',false);
if(!empty($name)){
$pattern='/^(\w+|\-|(\[(年|月|日|时|分|秒|前两位|后两位|任务名|任务ID|'.$title.'网址MD5码|'.$title.'原名)\])|(\[字段\:[^\/\[\]]+?\]))+$/u';
if(!preg_match($pattern,$name)){
$result['msg']=$title.'名称自定义名称只能输入字母、数字、下划线 或 使用标签';
}else{
$result['success']=true;
}
}
$check_list[$nameMd5]=$result;
}else{
$result=$check_list[$nameMd5];
}
return $result;
}
private function _convert_file_name_name($isImg,$name,$url){
$title=$isImg?'图片':'文件';
$md5=md5($url);
if(!empty($name)){
$urlname='';
if(preg_match('/([^\/]+?)(\.[a-zA-Z][\w\-]+){0,1}([\?\#]|$)/', $url,$urlname)){
$urlname=$urlname[1];
if(mb_strlen($urlname,'utf-8')>100){
$urlname=mb_substr($urlname,0,100,'utf-8');
}
}else{
$urlname='';
}
if(empty($urlname)){
$urlname=$md5;
}
static $sameTags=array('[年]','[月]','[日]','[时]','[分]','[秒]','[前两位]','[后两位]');
$tags=$sameTags;
$tags[]='['.$title.'网址MD5码]';
$tags[]='['.$title.'原名]';
$nowTime=time();
$tagsRe=array(
date('Y',$nowTime),
date('m',$nowTime),
date('d',$nowTime),
date('H',$nowTime),
date('i',$nowTime),
date('s',$nowTime),
substr($md5,0,2),
substr($md5,-2,2),
$md5,
$urlname
);
$name=str_replace($tags, $tagsRe, $name);
$name=preg_replace('/[\/\s\r\n\~\`\!\@\#\$\%\^\&\*\(\)\+\=\{\}\[\]\|\\\\:\;\"\'\<\>\,\?]+/', '_', $name);
$name=preg_replace('/\_{2,}/', '_', $name);
$name=trim($name,'_');
}
if(empty($name)){
$name=$md5;
}
return $name;
}
}
?>

11
vendor/skycaiji/app/admin/model/FuncApp.php vendored

@ -29,6 +29,10 @@ class FuncApp extends \skycaiji\common\model\BaseModel{
'name'=>'下载图片',
'loc'=>'设置»采集设置»图片本地化»使用函数',
),
'downloadFile'=>array(
'name'=>'下载文件',
'loc'=>'设置»采集设置»文件本地化»使用函数',
),
'contentSign'=>array(
'name'=>'内容标签',
'loc'=>'任务»采集器设置»页面配置»提取内容标签»使用函数',
@ -326,13 +330,14 @@ class FuncApp extends \skycaiji\common\model\BaseModel{
*/
public function execute_func($module,$funcName,$defaultVal,$paramsStr,$paramValList=null){
static $func_class_list=array('process'=>array(),'processIf'=>array(),'contentSign'=>array(),'downloadImg'=>array());
static $func_param_num_list=array('process'=>array(),'processIf'=>array(),'contentSign'=>array(),'downloadImg'=>array());
static $func_class_list=array('process'=>array(),'processIf'=>array(),'contentSign'=>array(),'downloadImg'=>array(),'downloadFile'=>array());
static $func_param_num_list=array('process'=>array(),'processIf'=>array(),'contentSign'=>array(),'downloadImg'=>array(),'downloadFile'=>array());
static $func_param_rules=array(
'process'=>'/\[\x{5b57}\x{6bb5}\:.+?\]/u',
'processIf'=>'/\[\x{5b57}\x{6bb5}\:.+?\]/u',
'contentSign'=>null,
'downloadImg'=>'/\[\x{56fe}\x{7247}\:.+?\]/u',
'downloadFile'=>'/\[\x{6587}\x{4ef6}\:.+?\]/u',
);
$class_list=&$func_class_list[$module];
$param_num_list=&$func_param_num_list[$module];
@ -378,7 +383,7 @@ class FuncApp extends \skycaiji\common\model\BaseModel{
if(is_object($class_list[$className])){
if(!method_exists($class_list[$className], $methodName)){
$result['msg']=$options['loc'].'»不存在方法:'.$className.'-&gt;'.$methodName;
$result['msg']=$options['loc'].'»不存在方法:'.$className.'->'.$methodName;
}else{
$result['success']=true;
}

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

@ -11,6 +11,21 @@
namespace skycaiji\admin\model;
class Task extends \skycaiji\common\model\BaseModel{
public function getById($id){
$data=$this->where('id',$id)->find();
if($data){
$data=$data->toArray();
if(!empty($data['config'])){
$data['config']=unserialize($data['config']);
}
if(empty($data['config'])){
$data['config']=array();
}
}else{
$data=array();
}
return $data;
}
public function loadConfig($taskData){
$config=$taskData['config'];
if(empty($config)){
@ -24,12 +39,12 @@ class Task extends \skycaiji\common\model\BaseModel{
$config=array();
}
$config=$this->compatible_config($config);
$original_config=g_sc('c_original');
set_g_sc(['c','caiji','interval'],empty($config['interval'])?$original_config['caiji']['interval']:$config['interval']);
set_g_sc(['c','caiji','interval_html'],empty($config['interval_html'])?$original_config['caiji']['interval_html']:$config['interval_html']);
$this->set_c_num_names('caiji', array('interval'=>'num_interval','interval_html'=>'num_interval_html'), $config, $original_config);
if(empty($config['same_url'])){
@ -71,6 +86,30 @@ class Task extends \skycaiji\common\model\BaseModel{
}
if(empty($config['download_file'])){
set_g_sc(['c','download_file','download_file'],$original_config['download_file']['download_file']);
}else{
set_g_sc(['c','download_file','download_file'],$config['download_file']=='n'?0:1);
}
if(empty($config['file_func'])){
set_g_sc(['c','download_file','file_func'],$original_config['download_file']['file_func']);
}else{
set_g_sc(['c','download_file','file_func'],$config['file_func']=='n'?'':$config['file_func']);
}
if(empty($config['translate'])){
set_g_sc(['c','translate','open'],$original_config['translate']['open']);
}else{
set_g_sc(['c','translate','open'],$config['translate']=='n'?0:1);
}
if(empty($config['proxy'])){
set_g_sc(['c','proxy','open'],$original_config['proxy']['open']);
@ -86,7 +125,7 @@ class Task extends \skycaiji\common\model\BaseModel{
set_g_sc(['c','proxy','group_id'],$config['proxy_group_id']);
}
static $imgParams=array('img_path','img_url','img_name','name_custom_path','name_custom_name','interval_img','img_func_param');
static $imgParams=array('img_path','img_url','img_name','name_custom_path','name_custom_name','img_func_param','img_wm_logo');
foreach ($imgParams as $imgParam){
set_g_sc(['c','download_img',$imgParam],empty($config[$imgParam])?$original_config['download_img'][$imgParam]:$config[$imgParam]);
@ -96,22 +135,57 @@ class Task extends \skycaiji\common\model\BaseModel{
set_g_sc(['c','download_img','name_custom_path'],$original_config['download_img']['name_custom_path']);
set_g_sc(['c','download_img','name_custom_name'],$original_config['download_img']['name_custom_name']);
}
if(empty($config['img_watermark'])){
set_g_sc(['c','download_img','img_watermark'],$original_config['download_img']['img_watermark']);
}else{
set_g_sc(['c','download_img','img_watermark'],$config['img_watermark']=='n'?0:1);
}
$this->set_c_num_names('download_img', array('interval_img'=>'num_interval_img','img_wm_bottom'=>'img_wm_bottom','img_wm_right'=>'img_wm_right','img_wm_opacity'=>'img_wm_opacity'), $config, $original_config);
$htmlMillisecond=g_sc_c('caiji','interval_html');
if(empty($htmlMillisecond)&&$original_config['caiji']['html_interval']>0){
static $fileParams=array('file_path','file_url','file_name','file_func_param');
foreach ($fileParams as $fileParam){
$htmlMillisecond=$original_config['caiji']['html_interval']*1000;
set_g_sc(['c','caiji','interval_html'],$htmlMillisecond);
set_g_sc(['c','download_file',$fileParam],empty($config[$fileParam])?$original_config['download_file'][$fileParam]:$config[$fileParam]);
}
set_g_sc(['c','download_file','name_custom_path'],empty($config['file_custom_path'])?$original_config['download_file']['name_custom_path']:$config['file_custom_path']);
set_g_sc(['c','download_file','name_custom_name'],empty($config['file_custom_name'])?$original_config['download_file']['name_custom_name']:$config['file_custom_name']);
$imgMillisecond=g_sc_c('download_img','interval_img');
if(empty($imgMillisecond)&&$original_config['download_img']['img_interval']>0){
if(empty($config['file_name'])){
$imgMillisecond=$original_config['download_img']['img_interval']*1000;
set_g_sc(['c','download_img','interval_img'],$imgMillisecond);
set_g_sc(['c','download_file','name_custom_path'],$original_config['download_file']['name_custom_path']);
set_g_sc(['c','download_file','name_custom_name'],$original_config['download_file']['name_custom_name']);
}
}
$this->set_c_num_names('download_file', array('file_interval'=>'file_interval'), $config, $original_config);
}
private function set_c_num_names($cKey,$names,&$config,&$original_config){
foreach ($names as $k=>$v){
set_g_sc(['c',$cKey,$k],is_empty($config[$v],true)?$original_config[$cKey][$k]:$config[$v]);
}
}
public function compatible_config($config){
if(!empty($config)&&is_array($config)){
$oldNumNames=array('interval'=>'num_interval','interval_html'=>'num_interval_html','interval_img'=>'num_interval_img');
foreach($oldNumNames as $k=>$v){
if(isset($config[$k])){
if(empty($config[$k])){
$config[$v]='';
}elseif($config[$k]==='-1'||$config[$k]===-1){
$config[$v]=0;
}else{
$config[$v]=$config[$k];
}
}
}
}
return $config;
}
public function set_backstage($taskId){
if($taskId>0){

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

@ -6,6 +6,7 @@
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<title>{:g_sc('html_tag_title')?(g_sc('html_tag_title').' - '):''}蓝天采集器后台管理</title>
<meta name="generator" content="skycaiji" />
<meta http-equiv="x-dns-prefetch-control" content="on">
<link rel="icon" href="data:image/ico;base64,aWNv">
<!-- Bootstrap 3.3.7 -->
<link rel="stylesheet" href="__PUBLIC__/bootstrap/css/bootstrap.min.css?{$Think.config.html_v}">
@ -33,7 +34,7 @@
<script type="text/javascript" src="__PUBLIC__/static/js/base64.min.js?{$Think.config.html_v}"></script>
<link href="__PUBLIC__/static/css/toastr.css?{$Think.config.html_v}" rel="stylesheet" type="text/css">
<script src="__PUBLIC__/static/js/toastr.js?{$Think.config.html_v}"></script>
<!-- jQuery UI 1.11.4 -->
<!-- jQuery UI -->
<script src="__PUBLIC__/addon/adminlte/jquery-ui.min.js?{$Think.config.html_v}"></script>
<!-- Bootstrap 3.3.7 -->
<script src="__PUBLIC__/bootstrap/js/bootstrap.min.js?{$Think.config.html_v}"></script>

1
vendor/skycaiji/app/admin/view/cpattern/front_url.html vendored

@ -26,6 +26,7 @@
<div>
<label class="checkbox-inline"><input type="checkbox" name="front_url[use_cookie]" value="1"> 全局抓取页面时使用当前页COOKIE</label>
<label class="checkbox-inline"><input type="checkbox" name="front_url[use_cookie_img]" value="1"> 全局下载图片时使用当前页COOKIE</label>
<label class="checkbox-inline"><input type="checkbox" name="front_url[use_cookie_file]" value="1"> 全局下载文件时使用当前页COOKIE</label>
</div>
</div>
<div class="form-group form-group-sm">

1
vendor/skycaiji/app/admin/view/cpattern/process.html vendored

@ -10,6 +10,7 @@
<option value="replace">{$Think.lang.process_module_replace}</option>
<option value="batch">{$Think.lang.process_module_batch}</option>
<option value="tool">{$Think.lang.process_module_tool}</option>
<option value="download">{$Think.lang.process_module_download}</option>
<option value="translate">{$Think.lang.process_module_translate}</option>
<option value="filter">{$Think.lang.process_module_filter}</option>
<option value="if">{$Think.lang.process_module_if}</option>

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

@ -60,7 +60,7 @@
<div class="input-group">
<textarea data-process="replace:replace_from" rows="3" class="form-control"></textarea>
<div class="input-group-addon iga-rt">
<a href="javascript:;" title="{$Think.lang.tips_sign_wildcard}" class="blk sign-wildcard">{$Think.lang.sign_wildcard}</a>
<a href="javascript:;" title="{$Think.lang.tips_sign_wildcard}" class="blk c-p-process-sign-wildcard">{$Think.lang.sign_wildcard}</a>
<span title="{$Think.lang.tips_regular}" class="blk">正则</span>
</div>
</div>
@ -214,9 +214,10 @@
</section>
</div>
<div class="c-p-process-module" module="translate">
{if empty($transApiLangs)}
<a href="{:url('setting/translate')}" target="_blank">请先开启并配置翻译接口</a>
{else/}
{if !empty($transUrl)}
<a href="{$transUrl}" target="_blank">请先开启并配置翻译</a>
{/if}
<div{if !empty($transUrl)} style="display:none;"{/if}>
<div class="form-group">
<label>源语言</label>
<div class="input-group input-select-custom">
@ -248,15 +249,92 @@
<input type="text" data-process="translate:translate_to_custom" class="form-control" placeholder="请输入语言代码">
</div>
</div>
{/if}
</div>
</div>
<div class="c-p-process-module" module="tool">
<div class="checkbox">
<label><input type="checkbox" data-process="tool:tool_list" value="trim" />去除前后空格</label>
&nbsp; <label><input type="checkbox" data-process="tool:tool_list" value="format" />清除文本格式(去除html元素所有样式,如:id、class、style等)</label>
&nbsp; <label title="如果字段的值是完整的url链接,标记为图片链接后可将其图片本地化"><input type="checkbox" data-process="tool:tool_list" value="is_img" />将文本链接标记为图片链接</label>
&nbsp; <label><input type="checkbox" data-process="tool:tool_list" value="url_not_complete" />禁止补全网址</label>
</div>
</div>
<div class="c-p-process-module" module="download">
<section>
<div class="form-group">
<label>操作</label>
<select data-process="download:download_op" class="form-control">
<option value="">--选择操作--</option>
<option value="is_img">将文本链接标记为图片</option>
<option value="is_file">将文本链接标记为文件</option>
<option value="no_img">不下载图片</option>
<option value="file">下载文件</option>
</select>
<div class="p-m-download-op" data-op="is_img">
{if !empty($downImgUrl)}
<a href="{$downImgUrl}" target="_blank">请先开启并配置图片本地化</a>
{/if}
<p class="help-block">如果字段的值是完整的url链接,标记为图片后可将其本地化</p>
</div>
<div class="p-m-download-op" data-op="is_file">
{if !empty($downFileUrl)}
<a href="{$downFileUrl}" target="_blank">请先开启并配置文件本地化</a>
{/if}
<p class="help-block">如果字段的值是完整的url链接,标记为文件后可将其本地化</p>
</div>
<div class="p-m-download-op" data-op="no_img">
{if !empty($downImgUrl)}
<a href="{$downImgUrl}" target="_blank">请先开启并配置图片本地化</a>
{/if}
<p class="help-block">默认自动下载&lt;img&gt;标签中的图片,该选项可不下载图片</p>
</div>
<div class="p-m-download-op" data-op="file">
{if !empty($downFileUrl)}
<a href="{$downFileUrl}" target="_blank">请先开启并配置文件本地化</a>
{/if}
<div class="form-group p-m-download-file-tag"{if !empty($downFileUrl)} style="display:none;"{/if}>
<label>下载标签属性中的文件</label>
<input type="text" data-process="download:download_file_tag" class="form-control" placeholder="" autocomplete="off" />
<div class="help-block">
<div class="dropdown" style="display:inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
填入html标签及属性
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="javascript:;" data-val="object:data">object标签data属性</a></li>
<li><a href="javascript:;" data-val="embed:src">embed标签src属性</a></li>
<li><a href="javascript:;" data-val="source:src">source标签src属性</a></li>
<li><a href="javascript:;" data-val="link:href">link标签href属性</a></li>
<li><a href="javascript:;" data-val="script:src">script标签src属性</a></li>
<li><a href="javascript:;" data-val="a:href">a标签href属性</a></li>
</ul>
</div>
或直接输入<b>标签名:属性名</b>(多个用逗号分隔)可实现自动下载相应标签属性中的文件
</div>
<div class="form-group">
<label>文件网址过滤</label>
<div class="input-group" style="margin-bottom:7px;">
<span class="input-group-addon">必须包含</span>
<input type="text" data-process="download:download_file_must" class="form-control" placeholder="选填,可模糊匹配" autocomplete="off" />
<div class="input-group-addon iga-rt">
<a href="javascript:;" title="{$Think.lang.tips_sign_wildcard}" class="c-p-process-sign-wildcard">{$Think.lang.sign_wildcard}</a>
<span title="{$Think.lang.tips_regular}">正则</span>
</div>
</div>
<div class="input-group">
<span class="input-group-addon">不能包含</span>
<input type="text" data-process="download:download_file_ban" class="form-control" placeholder="选填,可模糊匹配" autocomplete="off" />
<div class="input-group-addon iga-rt">
<a href="javascript:;" title="{$Think.lang.tips_sign_wildcard}" class="c-p-process-sign-wildcard">{$Think.lang.sign_wildcard}</a>
<span title="{$Think.lang.tips_regular}">正则</span>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
<div class="c-p-process-module" module="batch">
<div class="form-group">
<label>批量替换</label>
@ -446,37 +524,39 @@
</div>
</div>
<div class="form-group">
<label>提取结果</label>
<input type="text" data-process="api:api_json" class="form-control" />
<p class="help-block">json规则: a.b.c 通配符 *</p>
</div>
<div class="form-group">
<label>结果是数组则转换为</label>
<select data-process="api:api_json_arr" class="form-control">
<option value="implode">字符串</option>
<option value="jsonencode">json编码</option>
<option value="serialize">序列化</option>
</select>
<div class="input-group p-m-api-json-implode" style="margin-top:5px;">
<textarea data-process="api:api_json_implode" class="form-control" rows="1" placeholder="输入分隔符"></textarea>
<div class="input-group-addon" style="padding-left:9px;padding-right:9px;"><span title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="cpDelimiterTips()"></span></div>
</div>
</div>
<div class="form-group">
<label>调用间隔(毫秒,1000毫秒=1秒)</label>
<input type="number" data-process="api:api_interval" class="form-control" />
<input type="number" data-process="api:api_interval" class="form-control" placeholder="默认0" />
<p class="help-block">如接口有频率限制,可设置间隔时间避免调用过快导致失败</p>
</div>
<div class="form-group">
<label>失败等待(秒)</label>
<input type="number" data-process="api:api_wait" class="form-control" />
<input type="number" data-process="api:api_wait" class="form-control" placeholder="默认0" />
<p class="help-block">一般情况下调用失败都是频繁请求接口导致被禁用,设置该值等待一段时间让接口恢复正常</p>
</div>
<div class="form-group">
<label>失败重试</label>
<input type="number" data-process="api:api_retry" class="form-control" />
<input type="number" data-process="api:api_retry" class="form-control" placeholder="默认0" />
<p class="help-block">调用失败重试次数,留空或0表示不重试</p>
</div>
<div class="form-group">
<label>获取结果方式</label>
<select class="form-control" data-process="api:api_rule_module">
<option value="" checked="checked">JSON提取</option>
<option value="rule">规则匹配</option>
<option value="xpath">XPath匹配</option>
</select>
</div>
<div class="form-group">
<div class="p-m-api-rule-module" data-rule-module="">
{include file="cpattern:rule_module" _type="json" _name="data-process" _name_pre="api:api_" _allow_loop="" /}
</div>
<div class="p-m-api-rule-module" data-rule-module="rule">
{include file="cpattern:rule_module" _type="rule" _name="data-process" _name_pre="api:api_" _allow_loop="" /}
</div>
<div class="p-m-api-rule-module" data-rule-module="xpath">
{include file="cpattern:rule_module" _type="xpath" _name="data-process" _name_pre="api:api_" _allow_loop="" /}
</div>
</div>
</section>
</div>
</div>

56
vendor/skycaiji/app/admin/view/cpattern/rule_module.html vendored

@ -2,19 +2,19 @@
{assign name="_tpl_name" value="[_name]" /}
{assign name="_tpl_name_pre" value="[_name_pre]" /}
{assign name="_tpl_allow_loop" value="[_allow_loop]" /}
{php}$_tpl_is_process=($_tpl_name=='data-process')?true:false;{/php}
{if $_tpl_type=='rule'}
<div class="form-group">
<label>规则</label>
<div class="input-group">
<textarea name="{$_tpl_name}[{$_tpl_name_pre}rule]" class="form-control" rows="3" placeholder="{$Think.lang.tips_match}"></textarea>
<textarea {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'rule')} class="form-control" rows="3" placeholder="{$Think.lang.tips_match}"></textarea>
<div class="input-group-addon iga-rt">
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_wildcard}" onclick="cpWildcard('[name=\'{$_tpl_name}[{$_tpl_name_pre}rule]\']')">{$Think.lang.sign_wildcard}</a></div>
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_match}" onclick="cpMatch('[name=\'{$_tpl_name}[{$_tpl_name_pre}rule]\']')">{:cp_sign('match')}</a></div>
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_group}" class="blk" onclick="cpMatch('[name=\'{$_tpl_name}[{$_tpl_name_pre}rule]\']',{group:1})">捕获组</a></div>
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_wildcard}" {if $_tpl_is_process}data-rule-sign="sign_wildcard"{else/}onclick="ruleInsertSign.wildcard('[name=\'{$_tpl_name}[{$_tpl_name_pre}rule]\']')"{/if}>{$Think.lang.sign_wildcard}</a></div>
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_match}" {if $_tpl_is_process}data-rule-sign="sign_match"{else/}onclick="ruleInsertSign.match('[name=\'{$_tpl_name}[{$_tpl_name_pre}rule]\']')"{/if}>{:cp_sign('match')}</a></div>
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_group}" class="blk" {if $_tpl_is_process}data-rule-sign="sign_group"{else/}onclick="ruleInsertSign.match('[name=\'{$_tpl_name}[{$_tpl_name_pre}rule]\']',{group:1})"{/if}>捕获组</a></div>
<div>
<span title="{$Think.lang.tips_regular}">正则</span>
<a href="javascript:;" title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="cpRuleTips()"></a>
<a href="javascript:;" title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="ruleInsertSign.tips()"></a>
</div>
</div>
</div>
@ -23,33 +23,33 @@
<div class="form-group">
<label>拼接成最终内容</label>
<div class="input-group">
<textarea name="{$_tpl_name}[{$_tpl_name_pre}rule_merge]" class="form-control" rows="2" placeholder="默认拼接规则中所有{:cp_sign('match')}标签,{$Think.lang.tips_matchn}"></textarea>
<textarea {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'rule_merge')} class="form-control" rows="2" placeholder="默认拼接规则中所有{:cp_sign('match')}标签,{$Think.lang.tips_matchn}"></textarea>
<div class="input-group-addon iga-rt">
<a href="javascript:;" title="调用当前规则中的内容标签" onclick="cpMatchN('[name=\'{$_tpl_name}[{$_tpl_name_pre}rule]\']','[name=\'{$_tpl_name}[{$_tpl_name_pre}rule_merge]\']',{def:1})">{:cp_sign('match','N')}</a>
<a href="javascript:;" title="调用当前规则中的内容标签" {if $_tpl_is_process}data-rule-sign="sign_match_n"{else/}onclick="ruleInsertSign.matchN('[name=\'{$_tpl_name}[{$_tpl_name_pre}rule]\']','[name=\'{$_tpl_name}[{$_tpl_name_pre}rule_merge]\']',{def:1})"{/if}>{:cp_sign('match','N')}</a>
</div>
</div>
</div>
<div class="checkbox"><label><input type="checkbox" name="{$_tpl_name}[{$_tpl_name_pre}rule_multi]" value="1"> 允许匹配多个结果</label></div>
<div class="input-group" style="display:none;" id="c_p_{$_tpl_name}_{$_tpl_name_pre}rule_multi_str">
<div class="checkbox"><label><input type="checkbox" {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'rule_multi')} value="1"> 允许匹配多个结果</label></div>
<div class="input-group{if $_tpl_is_process} p-m-api-rule-multi-str{/if}" style="display:none;" {if !$_tpl_is_process}id="c_p_{$_tpl_name}_{$_tpl_name_pre}rule_multi_str"{/if}>
{if $_tpl_allow_loop}
<div class="input-group-addon" style="border-right:0;"><label class="radio-inline"><input type="radio" name="{$_tpl_name}[{$_tpl_name_pre}rule_multi_type]" value="">拼接为文本 <span title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="cpDelimiterTips()"></span></label></div>
<input type="text" name="{$_tpl_name}[{$_tpl_name_pre}rule_multi_str]" class="form-control" placeholder="多个结果之间分隔符">
<div class="input-group-addon"><label class="radio-inline"><input type="radio" name="{$_tpl_name}[{$_tpl_name_pre}rule_multi_type]" value="loop">循环入库</label></div>
<div class="input-group-addon" style="border-right:0;"><label class="radio-inline"><input type="radio" {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'rule_multi_type')} value="">拼接为文本 <span title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="cpDelimiterTips()"></span></label></div>
<input type="text" {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'rule_multi_str')} class="form-control" placeholder="多个结果之间分隔符">
<div class="input-group-addon"><label class="radio-inline"><input type="radio" {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'rule_multi_type')} value="loop">循环入库</label></div>
{else /}
<input type="text" name="{$_tpl_name}[{$_tpl_name_pre}rule_multi_str]" class="form-control" placeholder="多个结果之间分隔符" />
<input type="text" {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'rule_multi_str')} class="form-control" placeholder="多个结果之间分隔符" />
<div class="input-group-addon" style="padding-left:9px;padding-right:9px;"><span title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="cpDelimiterTips()"></span></div>
{/if}
</div>
{elseif $_tpl_type=='xpath' /}
<div class="form-group">
<label>规则</label>
<textarea name="{$_tpl_name}[{$_tpl_name_pre}xpath]" class="form-control" rows="3" placeholder="xpath规则"></textarea>
<textarea {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'xpath')} class="form-control" rows="3" placeholder="xpath规则"></textarea>
</div>
<div class="form-group">
<label>属性</label>
<div class="input-group input-select-custom">
<div class="input-group-btn">
<select name="{$_tpl_name}[{$_tpl_name_pre}xpath_attr]" class="form-control">
<select {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'xpath_attr')} class="form-control">
<option value=""></option>
<option value="innerHtml">innerHtml</option>
<option value="outerHtml">outerHtml</option>
@ -67,40 +67,40 @@
<option value="custom">自定义</option>
</select>
</div>
<input type="text" class="form-control" name="{$_tpl_name}[{$_tpl_name_pre}xpath_attr_custom]" />
<input type="text" class="form-control" {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'xpath_attr_custom')} />
</div>
</div>
<div class="checkbox"><label><input type="checkbox" name="{$_tpl_name}[{$_tpl_name_pre}xpath_multi]" value="1"> 允许匹配多个结果</label></div>
<div class="input-group" style="display:none;" id="c_p_{$_tpl_name}_{$_tpl_name_pre}xpath_multi_str">
<div class="checkbox"><label><input type="checkbox" {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'xpath_multi')} value="1"> 允许匹配多个结果</label></div>
<div class="input-group{if $_tpl_is_process} p-m-api-xpath-multi-str{/if}" style="display:none;" {if !$_tpl_is_process}id="c_p_{$_tpl_name}_{$_tpl_name_pre}xpath_multi_str"{/if}>
{if $_tpl_allow_loop}
<div class="input-group-addon" style="border-right:0;"><label class="radio-inline"><input type="radio" name="{$_tpl_name}[{$_tpl_name_pre}xpath_multi_type]" value="">拼接为文本 <span title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="cpDelimiterTips()"></span></label></div>
<input type="text" name="{$_tpl_name}[{$_tpl_name_pre}xpath_multi_str]" class="form-control" placeholder="多个结果之间分隔符">
<div class="input-group-addon"><label class="radio-inline"><input type="radio" name="{$_tpl_name}[{$_tpl_name_pre}xpath_multi_type]" value="loop">循环入库</label></div>
<div class="input-group-addon" style="border-right:0;"><label class="radio-inline"><input type="radio" {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'xpath_multi_type')} value="">拼接为文本 <span title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="cpDelimiterTips()"></span></label></div>
<input type="text" {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'xpath_multi_str')} class="form-control" placeholder="多个结果之间分隔符">
<div class="input-group-addon"><label class="radio-inline"><input type="radio" {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'xpath_multi_type')} value="loop">循环入库</label></div>
{else /}
<input type="text" name="{$_tpl_name}[{$_tpl_name_pre}xpath_multi_str]" class="form-control" placeholder="多个结果之间分隔符" />
<input type="text" {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'xpath_multi_str')} class="form-control" placeholder="多个结果之间分隔符" />
<div class="input-group-addon" style="padding-left:9px;padding-right:9px;"><span title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="cpDelimiterTips()"></span></div>
{/if}
</div>
{elseif $_tpl_type=='json' /}
<div class="form-group">
<label>提取规则</label>
<input type="text" name="{$_tpl_name}[{$_tpl_name_pre}json]" class="form-control" />
<input type="text" {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'json')} class="form-control" />
<p class="help-block">直接输入键名,子节点用:a.b.c,通配符*</p>
</div>
{if $_tpl_allow_loop}
<div class="form-group">
<div class="checkbox"><label><input type="checkbox" name="{$_tpl_name}[{$_tpl_name_pre}json_loop]" value="1"> 匹配到多个结果允许循环入库</label></div>
<div class="checkbox"><label><input type="checkbox" {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'json_loop')} value="1"> 匹配到多个结果允许循环入库</label></div>
</div>
{/if}
<div class="form-group">
<label>结果是数组则转换为</label>
<select name="{$_tpl_name}[{$_tpl_name_pre}json_arr]" class="form-control">
<select {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'json_arr')} class="form-control">
<option value="implode">字符串</option>
<option value="jsonencode">json编码</option>
<option value="serialize">序列化</option>
</select>
<div class="input-group" id="c_p_{$_tpl_name}_{$_tpl_name_pre}json_arr_implode" style="margin-top:5px;">
<textarea name="{$_tpl_name}[{$_tpl_name_pre}json_arr_implode]" class="form-control" rows="1" placeholder="输入分隔符"></textarea>
<div class="input-group{if $_tpl_is_process} p-m-api-json-arr-implode{/if}" {if !$_tpl_is_process}id="c_p_{$_tpl_name}_{$_tpl_name_pre}json_arr_implode"{/if} style="margin-top:5px;">
<textarea {:\\util\\Tools::cp_rule_module_name($_tpl_name,$_tpl_name_pre,'json_arr_implode')} class="form-control" rows="1" placeholder="输入分隔符"></textarea>
<div class="input-group-addon" style="padding-left:9px;padding-right:9px;"><span title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="cpDelimiterTips()"></span></div>
</div>
</div>

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

@ -68,6 +68,22 @@
</div>
<p class="help-block">默认将已采集网址排重过滤,选择“是”允许重复采集</p>
</div>
<div class="form-group">
<label class="control-label">网址中文转码</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="config[url_encode]" value="1"> </label>
<label class="radio-inline"><input type="radio" name="config[url_encode]" value="0" checked="checked"> </label>
</div>
<p class="help-block">网址中如果存在中文、特殊字符和空格会导致抓取失败,需要对中文、特殊字符和空格进行转码才能正常解析</p>
</div>
<div class="form-group">
<label class="control-label">网址去除锚点</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="config[url_no_name]" value="1"> </label>
<label class="radio-inline"><input type="radio" name="config[url_no_name]" value="0" checked="checked"> </label>
</div>
<p class="help-block">通常情况下网址中有锚点(#)和无锚点解析出的内容是相同的,为避免采集到重复内容可去除网址锚点</p>
</div>
<div class="form-group">
<label class="control-label">倒序采集</label>
<div class="input-group">
@ -84,14 +100,6 @@
</div>
<p class="help-block">需先配置<a href="{:url('setting/page_render')}" target="_blank">页面渲染</a>,可自动加载ajax内容,注意:渲染后的html源码与未渲染时的不相同,html的变动可能会导致原来的规则失效!</p>
</div>
<div class="form-group">
<label class="control-label">网址去除锚点</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="config[url_no_name]" value="1"> </label>
<label class="radio-inline"><input type="radio" name="config[url_no_name]" value="0" checked="checked"> </label>
</div>
<p class="help-block">通常情况下网址中有锚点(#)和无锚点解析出的内容是相同的,为避免采集到重复内容可去除网址锚点</p>
</div>
<div class="form-group">
<label class="control-label">正则匹配模式</label>
<div>
@ -179,7 +187,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_img" aria-expanded="false">下载图片</a>
@ -224,6 +232,52 @@
</div>
</div>
</div>
<div class="panel panel-default" style="margin-bottom:0;">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#c_p_request_headers_file" aria-expanded="false">下载文件</a>
</h4>
</div>
<div id="c_p_request_headers_file" class="panel-collapse collapse">
<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="config[request_headers][file]" value="1"> </label>
<label class="radio-inline"><input type="radio" name="config[request_headers][file]" value="0" checked="checked"> </label>
</div>
<p class="help-block">下载文件时使用请求头</p>
</div>
<div class="form-group">
<label class="control-label">使用全局请求头</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="config[request_headers][file_use_page]" value="" checked="checked"> 默认:<span class="def-config-request-headers-open"></span></label>
<label class="radio-inline"><input type="radio" name="config[request_headers][file_use_page]" value="y"> </label>
<label class="radio-inline"><input type="radio" name="config[request_headers][file_use_page]" 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-request-header-file" title="添加"></a></label>
<div class="table-responsive c-p-request-headers-file">
<table class="table table-bordered">
<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>
</div>

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

@ -37,11 +37,11 @@
</select>
<ul class="op">
<li data-module="" style="display:block;">
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_wildcard}" onclick="cpWildcard('[name=\'{$_tpl_name}[area]\']')">{$Think.lang.sign_wildcard}</a></div>
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_match_global}" onclick="cpMatch('[name=\'{$_tpl_name}[area]\']',{zimu:{$_tpl_match_global?1:0}})">{:cp_sign('match')}</a></div>
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_wildcard}" onclick="ruleInsertSign.wildcard('[name=\'{$_tpl_name}[area]\']')">{$Think.lang.sign_wildcard}</a></div>
<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="cpMatch('[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="cpRuleTips({$_tpl_match_global?1:''})"></a></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>
</li>
<li data-module="xpath">xpath语法</li>
@ -69,7 +69,7 @@
</div>
{else/}
<div class="input-group-addon iga-rt">
<a href="javascript:;" title="调用当前规则中的内容标签" onclick="cpMatchN('[name=\'{$_tpl_name}[area]\']','[name=\'{$_tpl_name}[area_merge]\']',{def:1})">{:cp_sign('match','N')}</a>
<a href="javascript:;" title="调用当前规则中的内容标签" onclick="ruleInsertSign.matchN('[name=\'{$_tpl_name}[area]\']','[name=\'{$_tpl_name}[area_merge]\']',{def:1})">{:cp_sign('match','N')}</a>
</div>
{/if}
</div>
@ -98,11 +98,11 @@
</select>
<ul class="op">
<li data-module="" style="display:block;">
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_wildcard}" onclick="cpWildcard('[name=\'{$_tpl_name}[url_rule]\']')">{$Think.lang.sign_wildcard}</a></div>
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_match_global}" onclick="cpMatch('[name=\'{$_tpl_name}[url_rule]\']',{zimu:{$_tpl_match_global?1:0}})">{:cp_sign('match')}</a></div>
<div style="display:inline;"><a href="javascript:;" title="{$Think.lang.tips_sign_wildcard}" onclick="ruleInsertSign.wildcard('[name=\'{$_tpl_name}[url_rule]\']')">{$Think.lang.sign_wildcard}</a></div>
<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="cpMatch('[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="cpRuleTips({$_tpl_match_global?1:''})"></a></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>
</li>
<li data-module="xpath">xpath语法</li>
@ -130,7 +130,7 @@
</div>
{else/}
<div class="input-group-addon iga-rt">
<a href="javascript:;" title="调用当前规则中的内容标签" onclick="cpMatchN('[name=\'{$_tpl_name}[url_rule]\']','[name=\'{$_tpl_name}[url_merge]\']',{def:1})">{:cp_sign('match','N')}</a>
<a href="javascript:;" title="调用当前规则中的内容标签" onclick="ruleInsertSign.matchN('[name=\'{$_tpl_name}[url_rule]\']','[name=\'{$_tpl_name}[url_merge]\']',{def:1})">{:cp_sign('match','N')}</a>
</div>
{/if}
</div>
@ -152,7 +152,7 @@
<span class="input-group-addon">必须包含</span>
<input type="text" name="{$_tpl_name}[url_must]" class="form-control" placeholder="选填,可模糊匹配" autocomplete="off" />
<div class="input-group-addon iga-rt">
<a href="javascript:;" title="{$Think.lang.tips_sign_wildcard}" class="mgr" onclick="cpWildcard('[name=\'{$_tpl_name}[url_must]\']')">{$Think.lang.sign_wildcard}</a>
<a href="javascript:;" title="{$Think.lang.tips_sign_wildcard}" class="mgr" onclick="ruleInsertSign.wildcard('[name=\'{$_tpl_name}[url_must]\']')">{$Think.lang.sign_wildcard}</a>
<span title="{$Think.lang.tips_regular}">正则</span>
</div>
</div>
@ -160,7 +160,7 @@
<span class="input-group-addon">不能包含</span>
<input type="text" name="{$_tpl_name}[url_ban]" class="form-control" placeholder="选填,可模糊匹配" autocomplete="off" />
<div class="input-group-addon iga-rt">
<a href="javascript:;" title="{$Think.lang.tips_sign_wildcard}" class="mgr" onclick="cpWildcard('[name=\'{$_tpl_name}[url_ban]\']')">{$Think.lang.sign_wildcard}</a>
<a href="javascript:;" title="{$Think.lang.tips_sign_wildcard}" class="mgr" onclick="ruleInsertSign.wildcard('[name=\'{$_tpl_name}[url_ban]\']')">{$Think.lang.sign_wildcard}</a>
<span title="{$Think.lang.tips_regular}">正则</span>
</div>
</div>

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

@ -10,6 +10,11 @@
<td><input type="text" data-name="config[request_headers][img_vals][]" class="form-control" autocomplete="off" /></td>
<td><a href="javascript:;" class="glyphicon glyphicon-remove delete-request-header-img"></a></td>
</tr>
<tr id="coll_tpl_request_headers_file">
<td><input type="text" data-name="config[request_headers][file_names][]" class="form-control" autocomplete="off" /></td>
<td><input type="text" data-name="config[request_headers][file_vals][]" class="form-control" autocomplete="off" /></td>
<td><a href="javascript:;" class="glyphicon glyphicon-remove delete-request-header-file"></a></td>
</tr>
<tr id="coll_tpl_url_web_form">
<td><input type="text" data-name="[url_web][form_names][]" class="form-control" autocomplete="off" /></td>
<td>

10
vendor/skycaiji/app/admin/view/develop/editor.html vendored

@ -35,7 +35,7 @@
<div class="col-sm-8 col-md-9 deve-editor-left">
<textarea id="code_editor_txt" style="display:none;">{$appcode?htmlspecialchars($appcode):''}</textarea>
<div id="code_editor_box"><iframe id="code_editor_ifr" style="width:100%;height:100%;border:0;"></iframe></div>
<button type="submit" id="btn_editor_save" class="btn btn-default btn-block" style="margin:0;margin-top:12px;">修改插件</button>
<button type="submit" id="btn_editor_save" class="btn btn-primary btn-block" style="margin:0;margin-top:12px;">修改插件</button>
</div>
<div class="col-sm-4 col-md-3 deve-editor-right">
<div class="nav-tabs-custom deve-editor-apps-nav">
@ -64,6 +64,14 @@
</div>
</div>
</div>
<div class="dropup" style="margin:12px 0 0 10px;">
<button class="btn btn-default btn-block" id="plugin_skycaiji" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
可用方法
<span class="caret"></span>
</button>
<ul class="dropdown-menu" id="plugin_skycaiji_ul" style="width:100%;height:400px;overflow:scroll;border:2px solid #ddd;" aria-labelledby="plugin_skycaiji">
</ul>
</div>
</div>
</div>
<script type="text/javascript">

29
vendor/skycaiji/app/admin/view/develop/editor_code.html vendored

@ -52,13 +52,26 @@ body{padding:0;margin:0;width:100%;height:100%;}
window.codeEditor.setSize(null,bodyHeight);
}
})();
function set_editor_code(val){
window.codeEditor.setValue(val);
}
function get_editor_code(val){
var val=window.codeEditor.getValue(val);
val=val?val:'';
return val;
}
var editor_code_op={
get:function(val){
var val=window.codeEditor.getValue(val);
val=val?val:'';
return val;
},
set:function(val){
window.codeEditor.setValue(val);
},
ctrl_s:function(func){
$(document).bind('keydown', function(e){
if(e.ctrlKey && e.which == 83){
e.preventDefault();
if(func&&typeof(func)=='function'){
func();
}
return false;
}
});
}
};
</script>
{/block}

11
vendor/skycaiji/app/admin/view/develop/plugin_skycaiji_method.html vendored

@ -0,0 +1,11 @@
<textarea id="win_func_method_txt" style="display:none;">
{$methodCmt?htmlspecialchars($methodCmt):''}
{$methodCode?htmlspecialchars($methodCode):''}
</textarea>
<iframe id="win_func_method_ifr" style="width:100%;height:100%;border:0;"></iframe>
<script type="text/javascript">
$(document).ready(function(){
editorCodeIfr('#win_func_method_ifr',{'set_value':$('#win_func_method_txt').val()});
});
</script>

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

@ -386,32 +386,54 @@
<div class="form-group">
<div>
<label>响应状态</label>
<small style="margin-left:5px;color:#999;">接口必须返回json格式的数组用来记录数据入库的状态,否则会标记为失败</small>
<small style="margin-left:5px;color:#999;">接口必须返回内容用来记录数据入库的状态,否则会标记为失败</small>
</div>
<div class="table-responsive">
<table class="table table-hover" style="margin-bottom:0;">
<thead>
<tr>
<td style="width:150px;">名称</td>
<td>绑定响应的json数组健名</td>
<td>
绑定响应的数据
<select name="toapi[response][module]" class="form-control" style="width:110px;height:auto;display:inline;padding:2px 5px;">
<option value="">json提取</option>
<option value="xpath">xpath匹配</option>
<option value="rule">正则匹配</option>
</select>
</td>
</tr>
</thead>
<tbody>
<tr>
<td>id(编号)</td>
<td><input type="text" name="toapi[response][id]" class="form-control" placeholder="默认:id,表示入库返回的自增id或入库状态" /></td>
<td><input type="text" name="toapi[response][id]" class="form-control" data-placeholder="记录入库的自增id或入库状态" autocomplete="off" /></td>
</tr>
<tr>
<td>target(位置)</td>
<td><input type="text" name="toapi[response][target]" class="form-control" placeholder="默认:target,记录入库的数据位置(发布的网址等)" /></td>
<td><input type="text" name="toapi[response][target]" class="form-control" data-placeholder="记录入库的数据位置(发布的网址等)" autocomplete="off" /></td>
</tr>
<tr>
<td>desc(描述)</td>
<td><input type="text" name="toapi[response][desc]" class="form-control" placeholder="默认:desc,记录入库的数据位置附加信息" /></td>
<td><input type="text" name="toapi[response][desc]" class="form-control" data-placeholder="记录入库的数据位置附加信息" autocomplete="off" /></td>
</tr>
<tr>
<td>error(错误)</td>
<td><input type="text" name="toapi[response][error]" class="form-control" placeholder="默认:error,记录入库失败的错误信息" /></td>
<td><input type="text" name="toapi[response][error]" class="form-control" data-placeholder="记录入库失败的错误信息" 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="xpath">使用xpath规则</p>
<p class="help-block" data-module="rule">
使用正则表达式
<a href="javascript:;" data-rule-sign="sign_wildcard" title="{$Think.lang.tips_sign_wildcard}">{$Think.lang.sign_wildcard}</a>
<a href="javascript:;" data-rule-sign="sign_match" title="{$Think.lang.tips_sign_match}">{:cp_sign('match')}</a>
<a href="javascript:;" data-rule-sign="sign_group" title="{$Think.lang.tips_sign_group}">捕获组</a>
,规则中有{:cp_sign('match')}标签时将所有{:cp_sign('match')}拼接为结果,否则将完全匹配的值作为结果
<a href="javascript:;" title="提示信息" class="glyphicon glyphicon-info-sign icon-info-tips" onclick="ruleInsertSign.tips()"></a>
</p>
</td>
</tr>
</tbody>
</table>
@ -546,7 +568,7 @@
<iframe id="diy_editor_ifr" style="width:100%;height:300px;border:0"></iframe>
<div class="help-block">
可用变量:$fields = 采集到的字段数据列表,$url = 采集的页面网址,$this->db() = 数据库操作, 可参考thinkphp5的数据库操作
<br>获取字段值必须使用 $this->get_field_val($field);方法(可处理图片本地化等),否则使用$field['value']调用字段原始值
<br>获取字段值必须使用 $this->get_field_val($field);方法(可处理图片、文件本地化等),否则使用$field['value']调用字段原始值
<p style="border-top:dashed 1px #ccc;padding-top:10px;margin-top:10px;">
必须以数组形式返回:

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

@ -55,9 +55,10 @@
</select>
<p class="help-block run-backstage">将在PHP后台开启一个持续进程用来运行采集,会占用一些服务器资源</p>
<p class="help-block run-visit" style="display:none;">
需在您的网站底部模板中加入一条html代码:<br/>
需在您的网站前端页面中加入一条html代码:<br/>
<em><b>&lt;script src="{:url('admin/index/caiji',null,false,true)}" async&gt;&lt;/script&gt;</b></em>
<br/>添加后,用户访问页面时即可触发采集,该方法不会额外消耗服务器资源
<br/>添加后,用户访问页面时即可触发采集,您也可以触发指定任务:
<br/><em><b>&lt;script src="{:url('admin/index/caiji?task_ids=',null,false,true)}任务id多个逗号分隔" async&gt;&lt;/script&gt;</b></em>
</p>
</div>
</div>

1
vendor/skycaiji/app/admin/view/setting/caiji_nav.html vendored

@ -2,6 +2,7 @@
<ul class="nav nav-tabs">
<li{$curNav['caiji']}><a href="{:url('setting/caiji')}">采集设置</a></li>
<li{$curNav['download_img']}><a href="{:url('setting/download_img')}">图片本地化</a></li>
<li{$curNav['download_file']}><a href="{:url('setting/download_file')}">文件本地化</a></li>
<li{$curNav['page_render']}><a href="{:url('setting/page_render')}">页面渲染</a></li>
<li{$curNav['proxy']}><a href="{:url('setting/proxy')}">代理</a></li>
<li{$curNav['translate']}><a href="{:url('setting/translate')}">翻译</a></li>

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

@ -0,0 +1,155 @@
{extend name="common:main" /}
{block name="cssjs"}
<script src="__PUBLIC__/static/js/admin/setting.js?{$Think.config.html_v}"></script>
{/block}
{block name="content"}
<form id="form_set" method="post" ajax-submit="true" role="form" action="{:url('admin/setting/download_file')}">
{:html_usertoken()}
<div class="nav-tabs-custom">
{include file="setting/caiji_nav" /}
<div class="tab-content">
<div class="tab-pane active" style="padding:0px 5px;">
<div class="form-group">
<label>全局开启</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="download_file" value="1"></label>
<label class="radio-inline"><input type="radio" name="download_file" value="0" checked="checked"></label>
</div>
<p class="help-block">开启后“任务»采集器设置»数据处理»本地化”中的文件下载功能才会生效,可单独在任务»更多设置中控制开关</p>
</div>
<div class="form-group">
<label>下载间隔(毫秒,1000毫秒=1秒)</label>
<input type="number" name="file_interval" class="form-control" />
<p class="help-block">可防止下载太快造成目标网站响应超时或宕机,留空或0表示不限制</p>
</div>
<div class="form-group">
<label>文件保存目录(绝对路径)</label>
<input type="text" name="file_path" class="form-control" placeholder="默认:{:config('root_path')}{:DS}data{:DS}files" />
<p class="help-block">可设置为服务器中的任意文件夹(必须开启读写权限),如果保存到本程序中,目录必须在data文件夹里</p>
</div>
<div class="form-group">
<label>文件链接地址(绝对地址)</label>
<input type="text" name="file_url" class="form-control" placeholder="默认:{:config('root_website')}/data/files" />
<p class="help-block">网页中可访问的文件网址目录,请务必对应到文件保存目录,否则文件无法显示</p>
</div>
<div class="form-group">
<label>文件名称</label>
<select name="file_name" class="form-control">
<option value="url">{$Think.lang.down_file_name_url}</option>
<option value="">{$Think.lang.down_file_name_}</option>
<option value="custom">{$Think.lang.down_file_name_custom}</option>
</select>
<div id="file_name_custom" style="margin-top:5px;display:none;">
<div class="input-group">
<span class="input-group-addon">路径</span>
<input type="text" name="name_custom_path" class="form-control" />
<span class="input-group-addon" style="border-left:0;border-right:0;">名称</span>
<select name="name_custom_name" class="form-control">
<option value="">{$Think.lang.down_file_name_custom_name_}</option>
</select>
</div>
<div class="help-block name-custom-path">
<ul class="in-line-mg">
<li><a href="javascript:;" data-val="[年]">[]</a></li>
<li><a href="javascript:;" data-val="[月]">[]</a></li>
<li><a href="javascript:;" data-val="[日]">[]</a></li>
<li><a href="javascript:;" data-val="[时]">[]</a></li>
<li><a href="javascript:;" data-val="[分]">[]</a></li>
<li><a href="javascript:;" data-val="[秒]">[]</a></li>
<li><a href="javascript:;" data-val="[前两位]" title="文件网址MD5码的前两位">[前两位]</a></li>
<li><a href="javascript:;" data-val="[后两位]" title="文件网址MD5码的后两位">[后两位]</a></li>
<li><a href="javascript:;" data-val="[任务名]">[任务名]</a></li>
<li><a href="javascript:;" data-val="[任务ID]">[任务ID]</a></li>
<li>/分隔子目录,如需调用字段可在任务的更多设置中编辑</li>
</ul>
</div>
</div>
</div>
<div class="form-group">
<label>系统编码</label>
<div class="input-group input-select-custom">
<div class="input-group-btn">
<select name="charset" class="form-control">
<option value="">默认</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" name="charset_custom" class="form-control" />
</div>
<p class="help-block">如果保存后的文件路径或名称乱码,需设置服务器系统编码,一般windows默认gbk,linux默认utf-8</p>
</div>
<div class="form-group">
<label>下载超时(秒)</label>
<input type="number" name="file_timeout" class="form-control" />
<p class="help-block">多少秒内未下载完,跳过下载该文件,留空或0表示不限制</p>
</div>
<div class="form-group">
<label>失败等待(秒)</label>
<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" />
<p class="help-block">下载失败重试次数,留空或0表示不重试</p>
</div>
<div class="form-group">
<label>限制大小(MB)</label>
<input type="number" name="file_max" class="form-control" />
<p class="help-block">超过兆数的文件不下载,留空或0表示不限制</p>
</div>
</div>
</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>
<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>
<script type="text/javascript">
settingClass.down_file_init({$fileConfig|json_encode});
</script>
{/block}

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

@ -3,7 +3,7 @@
<script src="__PUBLIC__/static/js/admin/setting.js?{$Think.config.html_v}"></script>
{/block}
{block name="content"}
<form id="form_set" method="post" ajax-submit="true" role="form" action="{:url('admin/setting/download_img')}">
<form id="form_set" method="post" ajax-submit="true" enctype="multipart/form-data" role="form" action="{:url('admin/setting/download_img')}">
{:html_usertoken()}
<div class="nav-tabs-custom">
{include file="setting/caiji_nav" /}
@ -15,7 +15,7 @@
<label class="radio-inline"><input type="radio" name="download_img" value="1"></label>
<label class="radio-inline"><input type="radio" name="download_img" value="0" checked="checked"></label>
</div>
<p class="help-block">将网页中的图片下载到本地,可单独在任务»更多设置中控制开关</p>
<p class="help-block">开启后可自动将网页中的图片下载到本地,可单独在任务»更多设置中控制开关</p>
</div>
<div class="form-group">
<label>下载间隔(毫秒,1000毫秒=1秒)</label>
@ -44,9 +44,9 @@
<div class="form-group">
<label>图片名称</label>
<select name="img_name" class="form-control">
<option value="">{$Think.lang.down_img_name_}</option>
<option value="url">{$Think.lang.down_img_name_url}</option>
<option value="custom">{$Think.lang.down_img_name_custom}</option>
<option value="url">{$Think.lang.down_file_name_url}</option>
<option value="">{$Think.lang.down_file_name_}</option>
<option value="custom">{$Think.lang.down_file_name_custom}</option>
</select>
<div id="img_name_custom" style="margin-top:5px;display:none;">
<div class="input-group">
@ -115,6 +115,30 @@
<input type="number" name="img_max" class="form-control" />
<p class="help-block">超过兆数的图片不下载,留空或0表示不限制</p>
</div>
<div class="form-group">
<label>图片加水印 {if $imgWmError}<span style="color:red;margin-left:5px;">{$imgWmError}</span>{/if}</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="img_watermark" value="1"></label>
<label class="radio-inline"><input type="radio" name="img_watermark" value="0" checked="checked"></label>
</div>
</div>
<div class="box-enable-wrapper">
<div class="form-group">
<label>水印logo</label>
<div class="input-group">
<span class="input-group-addon">logo</span>
<input type="file" name="img_wm_logo_upload" class="form-control" />
<span class="input-group-addon brl_0 brr_0">下边距</span>
<input type="number" name="img_wm_bottom" class="form-control" placeholder="默认0" />
<span class="input-group-addon brl_0 brr_0">右边距</span>
<input type="number" name="img_wm_right" class="form-control" placeholder="默认0" />
<span class="input-group-addon brl_0 brr_0">透明度</span>
<input type="number" name="img_wm_opacity" class="form-control" placeholder="默认不透明" />
</div>
<input type="hidden" name="img_wm_logo" class="form-control" />
<img src="" id="img_wm_logo_show" style="max-width:300px;margin-top:10px;border:solid 1px #ccc;display:none;" />
</div>
</div>
</div>
</div>
</div>
@ -127,9 +151,12 @@
<p class="help-block">图片下载后使用函数</p>
<div class="form-group">
<label>函数名</label>
<select name="img_func" class="form-control">
<option value="">不使用</option>
</select>
<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>
@ -149,7 +176,7 @@
<li><a href="javascript:;" data-val="[图片:网址]">[图片:网址](图片源网址)</a></li>
</ul>
</div>
&nbsp;请按函数传参,否则运行出错!<a href="javascript:;" onclick="tipsPluginFunc('downloadImg')">扩展函数</a>
&nbsp;请按函数传参,否则运行出错!
</div>
</div>
</div>

2
vendor/skycaiji/app/admin/view/setting/proxy.html vendored

@ -15,7 +15,7 @@
<label class="radio-inline"><input type="radio" name="open" value="1">{$Think.lang.yes}</label>
<label class="radio-inline"><input type="radio" name="open" value="0" checked="checked">{$Think.lang.no}</label>
</div>
<p class="help-block">采集页面和下载图片时使用代理设置,可单独在任务»更多设置中控制开关</p>
<p class="help-block">采集页面和下载时使用代理设置,可单独在任务»更多设置中控制开关</p>
</div>
<div id="proxy_open" class="proxy-ip-box">
<div class="form-group">

2
vendor/skycaiji/app/admin/view/setting/translate.html vendored

@ -15,7 +15,7 @@
<label class="radio-inline"><input type="radio" name="open" value="1">{$Think.lang.yes}</label>
<label class="radio-inline"><input type="radio" name="open" value="0" checked="checked">{$Think.lang.no}</label>
</div>
<p class="help-block">开启后采集器中的翻译功能才会生效</p>
<p class="help-block">开启后“任务»采集器设置»数据处理»翻译”功能才会生效,可单独在任务»更多设置中控制开关</p>
</div>
<div class="form-group">
<label>翻译API接口</label>

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

@ -148,17 +148,17 @@
<div class="form-group">
<label>{$Think.lang.set_caiji_num}</label>
<input type="number" name="config[num]" class="form-control" placeholder="全局设置:{$gConfig['num']}" />
<p class="help-block">该任务每次采集的数据量,不能超过采集设置中的“{$Think.lang.set_caiji_num}”,留空或0使用全局设置</p>
<p class="help-block">该任务每次采集的数据量,不能超过采集设置中的“{$Think.lang.set_caiji_num}”,留空使用全局设置</p>
</div>
<div class="form-group">
<label>{$Think.lang.set_caiji_interval}(分钟)</label>
<input type="number" name="config[interval]" class="form-control" placeholder="全局设置:{$gConfig['interval']}" />
<p class="help-block">留空或0使用全局设置,输入-1表示无间隔</p>
<input type="number" name="config[num_interval]" class="form-control" placeholder="全局设置:{$gConfig['num_interval']}" />
<p class="help-block">留空使用全局设置</p>
</div>
<div class="form-group">
<label>页面抓取间隔(毫秒,1000毫秒=1秒)</label>
<input type="number" name="config[interval_html]" class="form-control" placeholder="全局设置:{$gConfig['interval_html']}" />
<p class="help-block">留空或0使用全局设置,输入-1表示无间隔</p>
<input type="number" name="config[num_interval_html]" class="form-control" placeholder="全局设置:{$gConfig['num_interval_html']}" />
<p class="help-block">留空使用全局设置</p>
</div>
<div class="form-group">
<label>不同任务采集同一网址</label>
@ -190,9 +190,19 @@
<label class="radio-inline"><input type="radio" name="config[real_time]" value="n"></label>
</div>
</div>
<div class="form-group">
<label>使用翻译</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="config[translate]" value="" checked="checked">
全局设置:{$gConfig['translate']?'是':'否'}
</label>
<label class="radio-inline"><input type="radio" name="config[translate]" value="y"></label>
<label class="radio-inline"><input type="radio" name="config[translate]" value="n"></label>
</div>
</div>
</div>
<div class="panel-body{$gConfig['proxy']?'':' box-not-enable'}" id="config_proxy" style="border-top:solid 1px #ddd;">
<div class="form-group">
<div class="form-group" style="margin-bottom:0;">
<label>使用代理</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="config[proxy]" value="" data-global="{$gConfig['proxy']}" checked="checked">
@ -202,19 +212,21 @@
<label class="radio-inline"><input type="radio" name="config[proxy]" value="n"></label>
</div>
</div>
<div class="form-group">
<label>使用分组IP</label>
<select name="config[proxy_group_id]" class="form-control">
<option value="">全局设置:{$gConfig['proxy_group_id']}</option>
<option value="0">全部</option>
{foreach $proxyGroups as $proxyGroup}
<option value="{$proxyGroup['id']}">{$proxyGroup['name']}</option>
{/foreach}
</select>
<div class="box-enable-wrapper">
<div class="form-group">
<label>使用分组IP</label>
<select name="config[proxy_group_id]" class="form-control">
<option value="">全局设置:{$gConfig['proxy_group_id']}</option>
<option value="0">全部</option>
{foreach $proxyGroups as $proxyGroup}
<option value="{$proxyGroup['id']}">{$proxyGroup['name']}</option>
{/foreach}
</select>
</div>
</div>
</div>
<div class="panel-body{$gConfig['download_img']?'':' box-not-enable'}" id="config_download_img" style="border-top:solid 1px #ddd;">
<div class="form-group">
<div class="form-group" style="margin-bottom:0;">
<label>图片本地化</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="config[download_img]" value="" data-global="{$gConfig['download_img']}" checked="checked">
@ -224,135 +236,319 @@
<label class="radio-inline"><input type="radio" name="config[download_img]" value="n"></label>
</div>
</div>
<div class="form-group">
<label>图片下载间隔(毫秒,1000毫秒=1秒)</label>
<input type="number" name="config[interval_img]" class="form-control" placeholder="全局设置:{$gConfig['interval_img']}" />
<p class="help-block">留空或0使用全局设置,输入-1表示无间隔</p>
</div>
<div class="form-group">
<label>图片保存目录(绝对路径)</label>
<input type="text" name="config[img_path]" class="form-control" placeholder="全局设置:{$gConfig['img_path']}">
</div>
<div class="form-group">
<label>图片链接地址(绝对地址)</label>
<input type="text" name="config[img_url]" class="form-control" placeholder="全局设置:{$gConfig['img_url']}">
</div>
<div class="form-group">
<label>图片名称</label>
<select name="config[img_name]" class="form-control">
<option value="">全局设置:{:lang('down_img_name_'.$gConfig['img_name'])}</option>
<option value="time">{$Think.lang.down_img_name_time}</option>
<option value="url">{$Think.lang.down_img_name_url}</option>
<option value="custom">{$Think.lang.down_img_name_custom}</option>
</select>
<div id="config_img_name_custom" style="display:none;">
<p class="help-block" style="margin-bottom:5px;font-size:12px;">注意:字段值的长度限制100字内(超出自动截取),字段值中任何特殊字符都会被替换成下划线,自定义路径或名称太长都可能导致图片保存失败</p>
<div style="width:100%;">
<div style="width:50%;float:left">
<div class="input-group">
<input type="text" name="config[name_custom_path]" class="form-control" placeholder="路径,全局设置:{$gConfig['name_custom_path']}" autocomplete="off" />
<div class="input-group-addon" style="border-left:0;border-right:0;font-weight:bold;">/</div>
<div class="box-enable-wrapper">
<div class="form-group">
<label>图片下载间隔(毫秒,1000毫秒=1秒)</label>
<input type="number" name="config[num_interval_img]" class="form-control" placeholder="全局设置:{$gConfig['num_interval_img']}" />
<p class="help-block">留空使用全局设置</p>
</div>
<div class="form-group">
<label>图片保存目录(绝对路径)</label>
<input type="text" name="config[img_path]" class="form-control" placeholder="全局设置:{$gConfig['img_path']}">
</div>
<div class="form-group">
<label>图片链接地址(绝对地址)</label>
<input type="text" name="config[img_url]" class="form-control" placeholder="全局设置:{$gConfig['img_url']}">
</div>
<div class="form-group">
<label>图片名称</label>
<select name="config[img_name]" class="form-control">
<option value="">全局设置:{:lang('down_file_name_'.$gConfig['img_name'])}</option>
<option value="url">{$Think.lang.down_file_name_url}</option>
<option value="time">{$Think.lang.down_file_name_time}</option>
<option value="custom">{$Think.lang.down_file_name_custom}</option>
</select>
<div id="config_img_name_custom" style="display:none;">
<p class="help-block" style="margin-bottom:5px;font-size:12px;">注意:字段值的长度限制100字内(超出自动截取),字段值中任何特殊字符都会被替换成下划线,自定义路径或名称太长都可能导致图片保存失败</p>
<div style="width:100%;">
<div style="width:50%;float:left">
<div class="input-group">
<input type="text" name="config[name_custom_path]" class="form-control" placeholder="路径,全局设置:{$gConfig['name_custom_path']}" autocomplete="off" />
<div class="input-group-addon" style="border-left:0;border-right:0;font-weight:bold;">/</div>
</div>
<div class="help-block name-custom-path">
<div class="dropup" style="display:inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
系统
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="javascript:;" data-val="[年]">[]</a></li>
<li><a href="javascript:;" data-val="[月]">[]</a></li>
<li><a href="javascript:;" data-val="[日]">[]</a></li>
<li><a href="javascript:;" data-val="[时]">[]</a></li>
<li><a href="javascript:;" data-val="[分]">[]</a></li>
<li><a href="javascript:;" data-val="[秒]">[]</a></li>
<li><a href="javascript:;" data-val="[前两位]" title="图片网址MD5码的前两位">[前两位]</a></li>
<li><a href="javascript:;" data-val="[后两位]" title="图片网址MD5码的后两位">[后两位]</a></li>
<li><a href="javascript:;" data-val="[任务名]">[任务名]</a></li>
<li><a href="javascript:;" data-val="[任务ID]">[任务ID]</a></li>
</ul>
</div>&nbsp;
<div class="dropup" style="display:inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
采集器字段
<span class="caret"></span>
</a>
<ul class="dropdown-menu name-custom-path-fields">
<li><a href="javascript:;">没有字段,请先配置采集器设置!</a></li>
</ul>
</div>&nbsp;
/分隔子目录
</div>
</div>
<div class="help-block name-custom-path">
<div class="dropup" style="display:inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
系统
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="javascript:;" data-val="[年]">[]</a></li>
<li><a href="javascript:;" data-val="[月]">[]</a></li>
<li><a href="javascript:;" data-val="[日]">[]</a></li>
<li><a href="javascript:;" data-val="[时]">[]</a></li>
<li><a href="javascript:;" data-val="[分]">[]</a></li>
<li><a href="javascript:;" data-val="[秒]">[]</a></li>
<li><a href="javascript:;" data-val="[前两位]" title="图片网址MD5码的前两位">[前两位]</a></li>
<li><a href="javascript:;" data-val="[后两位]" title="图片网址MD5码的后两位">[后两位]</a></li>
<li><a href="javascript:;" data-val="[任务名]">[任务名]</a></li>
<li><a href="javascript:;" data-val="[任务ID]">[任务ID]</a></li>
</ul>
</div>&nbsp;
<div class="dropup" style="display:inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
采集器字段
<span class="caret"></span>
</a>
<ul class="dropdown-menu name-custom-path-fields">
<li><a href="javascript:;">没有字段,请先配置采集器设置!</a></li>
</ul>
</div>&nbsp;
/分隔子目录
</div>
</div>
<div style="width:50%;float:left">
<input type="text" name="config[name_custom_name]" class="form-control" placeholder="名称,全局设置:{$gConfig['name_custom_name']}" autocomplete="off" />
<div class="help-block name-custom-name">
<div class="dropup" style="display:inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
系统
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="javascript:;" data-val="[图片网址MD5码]">[图片网址MD5码]</a></li>
<li><a href="javascript:;" data-val="[图片原名]">[图片原名]</a></li>
<li><a href="javascript:;" data-val="[年]">[]</a></li>
<li><a href="javascript:;" data-val="[月]">[]</a></li>
<li><a href="javascript:;" data-val="[日]">[]</a></li>
<li><a href="javascript:;" data-val="[时]">[]</a></li>
<li><a href="javascript:;" data-val="[分]">[]</a></li>
<li><a href="javascript:;" data-val="[秒]">[]</a></li>
<li><a href="javascript:;" data-val="[前两位]" title="图片网址MD5码的前两位">[前两位]</a></li>
<li><a href="javascript:;" data-val="[后两位]" title="图片网址MD5码的后两位">[后两位]</a></li>
<li><a href="javascript:;" data-val="[任务名]">[任务名]</a></li>
<li><a href="javascript:;" data-val="[任务ID]">[任务ID]</a></li>
</ul>
</div>&nbsp;
<div class="dropup" style="display:inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
采集器字段
<span class="caret"></span>
</a>
<ul class="dropdown-menu name-custom-name-fields">
<li><a href="javascript:;">没有字段,请先配置采集器设置!</a></li>
</ul>
</div>
</div>
</div>
</div>
<div style="clear:both;height:0;">&nbsp;</div>
</div>
<div style="width:50%;float:left">
<input type="text" name="config[name_custom_name]" class="form-control" placeholder="名称,全局设置:{$gConfig['name_custom_name']}" autocomplete="off" />
<div class="help-block name-custom-name">
<div class="dropup" style="display:inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
系统
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="javascript:;" data-val="[图片网址MD5码]">[图片网址MD5码]</a></li>
<li><a href="javascript:;" data-val="[图片原名]">[图片原名]</a></li>
<li><a href="javascript:;" data-val="[年]">[]</a></li>
<li><a href="javascript:;" data-val="[月]">[]</a></li>
<li><a href="javascript:;" data-val="[日]">[]</a></li>
<li><a href="javascript:;" data-val="[时]">[]</a></li>
<li><a href="javascript:;" data-val="[分]">[]</a></li>
<li><a href="javascript:;" data-val="[秒]">[]</a></li>
<li><a href="javascript:;" data-val="[前两位]" title="图片网址MD5码的前两位">[前两位]</a></li>
<li><a href="javascript:;" data-val="[后两位]" title="图片网址MD5码的后两位">[后两位]</a></li>
<li><a href="javascript:;" data-val="[任务名]">[任务名]</a></li>
<li><a href="javascript:;" data-val="[任务ID]">[任务ID]</a></li>
</ul>
</div>&nbsp;
<div class="dropup" style="display:inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
采集器字段
<span class="caret"></span>
</a>
<ul class="dropdown-menu name-custom-name-fields">
<li><a href="javascript:;">没有字段,请先配置采集器设置!</a></li>
</ul>
</div>
</div>
</div>
</div>
<div style="clear:both;height:0;">&nbsp;</div>
</div>
</div>
<div class="form-group">
<label>图片加水印</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="config[img_watermark]" value="" data-global="{$gConfig['img_watermark']}" checked="checked">
全局设置:{$gConfig['img_watermark']?'是':'否'}
</label>
<label class="radio-inline"><input type="radio" name="config[img_watermark]" value="y"></label>
<label class="radio-inline"><input type="radio" name="config[img_watermark]" value="n"></label>
</div>
</div>
<div class="form-group" id="config_img_watermark" style="{$gConfig['img_watermark']?'':'display:none;'}">
<div class="form-group">
<label>水印logo</label>
<div class="input-group">
<span class="input-group-addon">logo</span>
<input type="file" name="img_wm_logo_upload" class="form-control" />
<span class="input-group-addon brl_0 brr_0">下边距</span>
<input type="number" name="config[img_wm_bottom]" class="form-control" placeholder="全局设置:{$gConfig['img_wm_bottom']}" />
<span class="input-group-addon brl_0 brr_0">右边距</span>
<input type="number" name="config[img_wm_right]" class="form-control" placeholder="全局设置:{$gConfig['img_wm_right']}" />
<span class="input-group-addon brl_0 brr_0">透明度</span>
<input type="number" name="config[img_wm_opacity]" class="form-control" placeholder="全局设置:{$gConfig['img_wm_opacity']}" />
</div>
<p class="help-block">留空使用全局设置</p>
<input type="hidden" name="config[img_wm_logo]" class="form-control" />
<div id="img_wm_logo_show" data-global="{$gConfig['img_wm_logo']}" style="display:none;">
<p class="help-block">默认使用全局设置logo</p>
<div>
<img src="" style="max-width:300px;border:solid 1px #ccc;" />
<a href="javascript:;" class="glyphicon glyphicon-remove" style="display:none;font-size:20px;margin:10px;"></a>
</div>
</div>
</div>
</div>
<div class="form-group">
<label>使用函数</label>
<div class="input-group">
<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>
</div>
</div>
<div class="form-group">
<label>使用函数</label>
<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>
<div class="panel-body{$gConfig['download_file']?'':' box-not-enable'}" id="config_download_file" style="border-top:solid 1px #ddd;">
<div class="form-group" style="margin-bottom:0;">
<label>文件本地化</label>
<div class="input-group">
<label class="radio-inline"><input type="radio" name="config[download_file]" value="" data-global="{$gConfig['download_file']}" checked="checked">
全局设置:{$gConfig['download_file']?'是':'否'}
</label>
<label class="radio-inline"><input type="radio" name="config[download_file]" value="y"></label>
<label class="radio-inline"><input type="radio" name="config[download_file]" value="n"></label>
</div>
</div>
<div id="config_img_func" style="display:none;">
<div class="box-enable-wrapper">
<div class="form-group">
<label>文件下载间隔(毫秒,1000毫秒=1秒)</label>
<input type="number" name="config[file_interval]" class="form-control" placeholder="全局设置:{$gConfig['file_interval']}" />
<p class="help-block">留空使用全局设置</p>
</div>
<div class="form-group">
<label>文件保存目录(绝对路径)</label>
<input type="text" name="config[file_path]" class="form-control" placeholder="全局设置:{$gConfig['file_path']}">
</div>
<div class="form-group">
<label>文件链接地址(绝对地址)</label>
<input type="text" name="config[file_url]" class="form-control" placeholder="全局设置:{$gConfig['file_url']}">
</div>
<div class="form-group">
<label>传入参数</label>
<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>
<label>文件名称</label>
<select name="config[file_name]" class="form-control">
<option value="">全局设置:{:lang('down_file_name_'.$gConfig['file_name'])}</option>
<option value="url">{$Think.lang.down_file_name_url}</option>
<option value="time">{$Think.lang.down_file_name_time}</option>
<option value="custom">{$Think.lang.down_file_name_custom}</option>
</select>
<div id="config_file_name_custom" style="display:none;">
<p class="help-block" style="margin-bottom:5px;font-size:12px;">注意:字段值的长度限制100字内(超出自动截取),字段值中任何特殊字符都会被替换成下划线,自定义路径或名称太长都可能导致文件保存失败</p>
<div style="width:100%;">
<div style="width:50%;float:left">
<div class="input-group">
<input type="text" name="config[file_custom_path]" class="form-control" placeholder="路径,全局设置:{$gConfig['file_custom_path']}" autocomplete="off" />
<div class="input-group-addon" style="border-left:0;border-right:0;font-weight:bold;">/</div>
</div>
<div class="help-block file-custom-path">
<div class="dropup" style="display:inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
系统
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="javascript:;" data-val="[年]">[]</a></li>
<li><a href="javascript:;" data-val="[月]">[]</a></li>
<li><a href="javascript:;" data-val="[日]">[]</a></li>
<li><a href="javascript:;" data-val="[时]">[]</a></li>
<li><a href="javascript:;" data-val="[分]">[]</a></li>
<li><a href="javascript:;" data-val="[秒]">[]</a></li>
<li><a href="javascript:;" data-val="[前两位]" title="文件网址MD5码的前两位">[前两位]</a></li>
<li><a href="javascript:;" data-val="[后两位]" title="文件网址MD5码的后两位">[后两位]</a></li>
<li><a href="javascript:;" data-val="[任务名]">[任务名]</a></li>
<li><a href="javascript:;" data-val="[任务ID]">[任务ID]</a></li>
</ul>
</div>&nbsp;
<div class="dropup" style="display:inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
采集器字段
<span class="caret"></span>
</a>
<ul class="dropdown-menu file-custom-path-fields">
<li><a href="javascript:;">没有字段,请先配置采集器设置!</a></li>
</ul>
</div>&nbsp;
/分隔子目录
</div>
</div>
<div style="width:50%;float:left">
<input type="text" name="config[file_custom_name]" class="form-control" placeholder="名称,全局设置:{$gConfig['file_custom_name']}" autocomplete="off" />
<div class="help-block file-custom-name">
<div class="dropup" style="display:inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
系统
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="javascript:;" data-val="[文件网址MD5码]">[文件网址MD5码]</a></li>
<li><a href="javascript:;" data-val="[文件原名]">[文件原名]</a></li>
<li><a href="javascript:;" data-val="[年]">[]</a></li>
<li><a href="javascript:;" data-val="[月]">[]</a></li>
<li><a href="javascript:;" data-val="[日]">[]</a></li>
<li><a href="javascript:;" data-val="[时]">[]</a></li>
<li><a href="javascript:;" data-val="[分]">[]</a></li>
<li><a href="javascript:;" data-val="[秒]">[]</a></li>
<li><a href="javascript:;" data-val="[前两位]" title="文件网址MD5码的前两位">[前两位]</a></li>
<li><a href="javascript:;" data-val="[后两位]" title="文件网址MD5码的后两位">[后两位]</a></li>
<li><a href="javascript:;" data-val="[任务名]">[任务名]</a></li>
<li><a href="javascript:;" data-val="[任务ID]">[任务ID]</a></li>
</ul>
</div>&nbsp;
<div class="dropup" style="display:inline;">
<a class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
采集器字段
<span class="caret"></span>
</a>
<ul class="dropdown-menu file-custom-name-fields">
<li><a href="javascript:;">没有字段,请先配置采集器设置!</a></li>
</ul>
</div>
</div>
</div>
</div>
<div style="clear:both;height:0;">&nbsp;</div>
</div>
</div>
<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>
&nbsp;请按函数传参,否则运行出错!<a href="javascript:;" onclick="tipsPluginFunc('downloadImg')">扩展函数</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="form-group">

34
vendor/skycaiji/app/common.php vendored

@ -10,7 +10,7 @@
*/
define('SKYCAIJI_VERSION', '2.5.4');
define('SKYCAIJI_VERSION', '2.5.5');
\think\Loader::addNamespace('plugin', realpath(SKYCAIJI_PATH.'plugin'));
\think\Loader::addNamespace('util',realpath(APP_PATH.'extend/util'));
@ -82,8 +82,19 @@ function g_sc_c($key1,$key2=null,$key3=null){
return \util\Funcs::array_get($GLOBALS['_sc']['c'], $keys);
}
function is_empty($val){
return empty($val);
function is_empty($val,$notContainZero=false){
if(empty($val)){
if($notContainZero){
if($val===0||$val==='0'){
return false;
}
}
return true;
}else{
return false;
}
}
/*写入文件*/
function write_dir_file($filename,$data,$flags=0,$content=null){
@ -240,7 +251,7 @@ function get_html($url,$headers=array(),$options=array(),$fromEncode='auto',$pos
$options['curlopts'][CURLOPT_IPRESOLVE]=$confIpResolve=='ipv6'?CURL_IPRESOLVE_V6:CURL_IPRESOLVE_V4;
}
$msg='';
$curl=null;
try {
if(isset($postData)&&$postData!==false){
@ -308,12 +319,21 @@ function get_html($url,$headers=array(),$options=array(),$fromEncode='auto',$pos
$contLen=intval($contLen[1]);
if($contLen>=$max_bytes){
$allow_get=false;
$msg='超出限制大小';
}
}
}
if($allow_get){
$curl=\util\Curl::get($url,$headers,$options);
if(!empty($options['return_head'])){
if(empty($curl)){
$curl=\util\Curl::head($url,$headers,$options);
}
}else{
$curl=\util\Curl::get($url,$headers,$options);
}
}else{
$curl=null;
}
@ -418,6 +438,10 @@ function get_html($url,$headers=array(),$options=array(),$fromEncode='auto',$pos
$info['error']=$curl->error;
$info['info']=$curl->info;
}
if($msg){
$info['msg']=$msg;
}
return $info;
}else{
return $html;

6
vendor/skycaiji/app/common/exception/CommonHandle.php vendored

@ -17,7 +17,7 @@ class CommonHandle extends \think\exception\Handle {
{
if(\util\Param::is_collector_collecting()&&IS_CLI){
controller('admin/CollectController')->echo_msg_exit(strip_tags($e->getMessage()));
\util\Tools::collect_output(strip_tags($e->getMessage()));
}else{
parent::renderForConsole($output,$e);
}
@ -26,7 +26,7 @@ class CommonHandle extends \think\exception\Handle {
protected function renderHttpException(\think\exception\HttpException $e){
if(\util\Param::is_collector_collecting()){
controller('admin/CollectController')->echo_msg_exit(strip_tags($e->getMessage()));
\util\Tools::collect_output(strip_tags($e->getMessage()));
}else{
return parent::renderHttpException($e);
}
@ -34,7 +34,7 @@ class CommonHandle extends \think\exception\Handle {
protected function convertExceptionToResponse(\Exception $exception){
if(\util\Param::is_collector_collecting()){
controller('admin/CollectController')->echo_msg_exit(strip_tags($exception->getMessage()));
\util\Tools::collect_output(strip_tags($exception->getMessage()));
}else{
return parent::convertExceptionToResponse($exception);
}

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','page_render','proxy','translate','site','email');
static $arrKeys=array('caiji','download_img','download_file','page_render','proxy','translate','site','email');
$keyConfig='cache_config_all';
$configDbList=$this->column('*');

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

@ -120,6 +120,8 @@ class ChromeSocket{
}
public function websocket($url='',$headers=array(),$options=array()){
$this->startTime=time();
$headers=is_array($headers)?$headers:array();
$headers=array_change_key_case($headers,CASE_LOWER);
@ -208,6 +210,7 @@ class ChromeSocket{
foreach ($htmlInfo['resp_header'] as $k=>$v){
if('location'==strtolower($v['name'])){
$locUrl=$v['value'];
$htmlInfo['code']=200;
break;
}
}

33
vendor/skycaiji/app/extend/util/Curl.php vendored

@ -43,7 +43,11 @@ class Curl{
* @param string $postData
* @return \util\Curl
*/
public static function request($url,$headers=array(),$options=array(),$postData=null){
public static function request($url,$rHeaders=array(),$rOptions=array(),$rPostData=null,$curRedirs=0){
$headers=$rHeaders;
$options=$rOptions;
$postData=$rPostData;
$instance=self::init();
$isPost=false;
@ -71,6 +75,7 @@ class Curl{
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt ( $ch, CURLOPT_HEADER, 1 );
curl_setopt ( $ch, CURLOPT_AUTOREFERER, 1 );
if($options['nobody']){
curl_setopt($ch, CURLOPT_NOBODY, true);
@ -79,6 +84,11 @@ class Curl{
curl_setopt($ch, CURLOPT_USERAGENT, $options['useragent']);
}
$options['max_redirs']=intval($options['max_redirs']);
if($options['max_redirs']){
curl_setopt($ch, CURLOPT_MAXREDIRS, $options['max_redirs']);
}
curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, FALSE );
@ -185,7 +195,26 @@ class Curl{
$instance->info=array();
}
}
curl_close ( $ch );
if(!$instance->ok&&$instance->code>=300&&$instance->code<400){
$info=empty($instance->info)?curl_getinfo($ch):$instance->info;
if(is_array($info)&&$info){
$rurl=$info['redirect_url']?:'';
if($rurl&&$rurl!=$url){
$maxRedirs=max(3,$options['max_redirs']);
if($curRedirs<$maxRedirs){
$curRedirs++;
curl_close($ch);
return self::request($rurl,$rHeaders,$rOptions,$rPostData,$curRedirs);
}
}
}
}
curl_close($ch);
return $instance;
}

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

@ -457,6 +457,15 @@ class Funcs{
}
return $data;
}
public static function get_url_suffix($url){
if(preg_match('/\.([a-zA-Z][\w\-]+)([\?\#]|$)/',$url,$suffix)){
$suffix=strtolower($suffix[1]);
}else{
$suffix='';
}
return $suffix;
}
}
?>

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

@ -100,14 +100,19 @@ class Param{
}
}
public static function key_gsc_use_cookie($isImg=false){
return 'collector_use_cookie'.($isImg?'_img':'');
public static function key_gsc_use_cookie($type=''){
$key='collector_use_cookie';
if($type){
$type=strtolower($type);
$key.='_'.$type;
}
return $key;
}
public static function set_gsc_use_cookie($isImg,$val){
set_g_sc(self::key_gsc_use_cookie($isImg),$val);
public static function set_gsc_use_cookie($type,$val){
set_g_sc(self::key_gsc_use_cookie($type),$val);
}
public static function get_gsc_use_cookie($isImg=false,$convert2str=false){
$data=g_sc(self::key_gsc_use_cookie($isImg));
public static function get_gsc_use_cookie($type='',$convert2str=false){
$data=g_sc(self::key_gsc_use_cookie($type));
init_array($data);
if($convert2str){

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

@ -636,5 +636,29 @@ class Tools{
}
return $url;
}
/**
* 采集输出信息
* @param mixed $strArgs
* @param string $color
*/
public static function collect_output($strArgs,$color='red',$exit=true){
static $class=null;
if(!isset($class)){
$class=controller('admin/CollectController');
}
if($exit){
$class->echo_msg_exit($strArgs,$color);
}else{
$class->echo_msg($strArgs,$color);
}
}
public static function cp_rule_module_name($name,$namePre,$nameKey){
if($name=='data-process'){
return 'data-process="'.$namePre.$nameKey.'"';
}else{
return 'name="'.$name.'['.$namePre.$nameKey.']"';
}
}
}
?>

2
vendor/skycaiji/app/extend/util/Translator.php vendored

@ -406,7 +406,7 @@ class Translator
}
}
}
return is_array($apiLangs) ? $apiLangs : null;
return is_array($apiLangs) ? $apiLangs : array();
}
}

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/install/event/LocSystem.php vendored

@ -48,7 +48,7 @@ class LocSystem extends BaseController{
}
public function environmentPath(){
$pathFiles=array('./data','./data/config.php','./data/images','./data/app','./data/program/upgrade','./data/program/backup','./app','./plugin','./runtime');
$pathFiles=array('./data','./data/config.php','./data/images','./data/files','./data/app','./data/program/upgrade','./data/program/backup','./app','./plugin','./runtime');
$pathFileList=array();
foreach ($pathFiles as $pathFile){
$filename=config('root_path').'/'.$pathFile;

Loading…
Cancel
Save