Skip to content

Commit

Permalink
2.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
zorlan committed Jul 21, 2020
1 parent b219706 commit f5af21e
Show file tree
Hide file tree
Showing 49 changed files with 1,445 additions and 620 deletions.
26 changes: 2 additions & 24 deletions SkycaijiApp/admin/behavior/Init.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,8 @@ public function run(){

$curController=strtolower(request()->controller());
if('store'==$curController){

$httpOrigin=strtolower(request()->server('HTTP_ORIGIN'));
$httpOrigin=rtrim($httpOrigin,'/');

$allowOrigin='';
if(in_array($httpOrigin,config('allow_origins'))){

$allowOrigin=$httpOrigin;
}else{

if(model('Provider')->where(array('domain'=>$httpOrigin,'enable'=>1))->count()>0){

$allowOrigin=$httpOrigin;
}
}


header('Access-Control-Allow-Origin:'.$allowOrigin);

header('Access-Control-Allow-Credentials:true');

header('Access-Control-Allow-Methods:POST,GET');



controller('Store','controller')->_checkCors(true);
}
/*自动登录*/
$muser=model('User');
Expand Down
13 changes: 10 additions & 3 deletions SkycaijiApp/admin/controller/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ public function collectAction(){
}
define('IS_COLLECTING', 1);
$mcache=CacheModel::getInstance();
if($mcache->getCache('auto_collecting')){

$this->error('有任务正在自动采集');
$autoCacheData=$mcache->getCache('auto_collecting');
if($autoCacheData){


if((time()-intval($autoCacheData['dateline']))>60*($GLOBALS['_sc']['c']['caiji']['interval']+15)){

}else{

$this->error('有任务正在自动采集');
}
}
$mcache->setCache('auto_collecting',1);
register_shutdown_function('remove_auto_collecting');
Expand Down
116 changes: 103 additions & 13 deletions SkycaijiApp/admin/controller/Cpattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ public function fieldAction(){
case 'list':if(empty($field['list']))$this->error('随机抽取不能为空!');break;
case 'extract':if(empty($field['extract']))$this->error('请选择字段!');break;
case 'merge':if(empty($field['merge']))$this->error('字段组合不能为空!');break;
case 'sign':
if($field['source']=='source_url')$this->error('抱歉,起始页无法使用'.lang('field_module_sign'));
if(empty($field['sign']))$this->error('请输入'.lang('field_module_sign'));
break;
}

$modules = array (
Expand All @@ -196,7 +200,8 @@ public function fieldAction(){
'time' => array ('time_format','time_start','time_end','time_stamp'),
'list' => 'list',
'extract' =>array('extract','extract_module','extract_rule','extract_xpath','extract_xpath_attr','extract_xpath_attr_custom','extract_json','extract_json_arr','extract_json_arr_implode'),
'merge' => 'merge'
'merge' => 'merge',
'sign' => 'sign'
);
$returnField=array('name'=>$field['name'],'source'=>$field['source'],'module'=>$field['module']);

Expand All @@ -212,7 +217,25 @@ public function fieldAction(){
$field=input('field','','url_b64decode');
$objid=input('objid');
$field=$field?json_decode($field,true):array();
if(!is_array($field)){
$field=array();
}
$field['time_format']=$field['time_format']?$field['time_format']:'[年]/[月]/[日] [时]:[分]';


$sortField=array();
foreach(array('source','module') as $k){
if(isset($field[$k])){
$sortField[$k]=$field[$k];
unset($field[$k]);
}
}

foreach ($field as $k=>$v){
$sortField[$k]=$v;
}
$field=$sortField;

$this->assign('field',$field);
$this->assign('objid',$objid);
return $this->fetch();
Expand Down Expand Up @@ -340,7 +363,7 @@ public function level_urlAction(){

$this->success('',null,array('level_url'=>$level_url,'objid'=>$objid));
}else{
$level_url=input('level_url','','url_b64decode');
$level_url=input('level_url','','url_b64decode');
$objid=input('objid');
$level_url=$level_url?json_decode($level_url,true):array();
$this->assign('level_url',$level_url);
Expand Down Expand Up @@ -392,8 +415,7 @@ public function testAction(){

$op=input('op');
$taskData=model('Task')->getById($eCpattern->collector['task_id']);

model('Task')->loadConfig($taskData['config']);
model('Task')->loadConfig($taskData);

$GLOBALS['_sc']['p_nav']=breadcrumb(array(array('url'=>url('Collector/set?task_id='.$taskData['id']),'title'=>lang('task').lang('separator').$taskData['name']),array('url'=>url('Cpattern/test&op='.$op.'&coll_id='.$coll_id),'title'=>'测试')));

Expand Down Expand Up @@ -440,17 +462,41 @@ public function testAction(){

$input_urls=array();
foreach ($eCpattern->config['new_field_list'] as $field){
if('source_url'==strtolower($field['field']['source'])){

$input_urls['source_url']=input('source_url');
$input_urls['source_url']=$input_urls['source_url']?$input_urls['source_url']:'';
if(empty($field['field']['source'])){

if($field['field']['module']=='sign'){
if(empty($eCpattern->config['level_urls'])){
$input_urls['source_url']=input('source_url','');
}else{

$endLevelNum=count($eCpattern->config['level_urls']);
$endLevel=$eCpattern->config['level_urls'][$endLevelNum-1];
$input_urls['level_url'][$endLevelNum]=array('level'=>$endLevelNum,'name'=>$endLevel['name'],'url'=>input('level_'.$endLevelNum));
}
}
}elseif('source_url'==strtolower($field['field']['source'])){

$input_urls['source_url']=input('source_url','');
}elseif(preg_match('/level_url:/i', $field['field']['source'])){

foreach($eCpattern->config['level_urls'] as $levIx=>$levVal){
if($field['field']['source']==('level_url:'.$levVal['name'])){

$level=$levIx+1;
$input_urls['level_url'][$level]=array('level'=>$level,'name'=>$levVal['name'],'url'=>input('level_'.$level));
if($field['field']['source']==('level_url:'.$levVal['name'])){

$level=$levIx+1;
if($field['field']['module']=='sign'){

if($level==1){

$input_urls['source_url']=input('source_url','');
}else{

$prevLevel=$level-1;
$input_urls['level_url'][$prevLevel]=array('level'=>$prevLevel,'name'=>$eCpattern->config['level_urls'][$prevLevel-1]['name'],'url'=>input('level_'.$prevLevel));
}
}else{

$input_urls['level_url'][$level]=array('level'=>$level,'name'=>$levVal['name'],'url'=>input('level_'.$level));
}
break;
}
}
Expand Down Expand Up @@ -489,6 +535,50 @@ public function testAction(){
}
}

$signLevels=array();
$signCont=false;
foreach($eCpattern->config['new_field_list'] as $fieldConfig){
if($fieldConfig['field']['module']=='sign'){

if(empty($fieldConfig['field']['source'])){
$signCont=true;
}elseif(preg_match('/^level_url:(.*+)$/i', $fieldConfig['field']['source'],$levelName)){

$levelName=$levelName[1];
$signLevels[$levelName]=$levelName;
}
}
}

if(!empty($signLevels)){

foreach ($eCpattern->config['level_urls'] as $k=>$v){
if(in_array($v['name'],$signLevels)){
if($k==0){

$eCpattern->getLevelUrls($eCpattern->cur_source_url,$k+1,true);
}else{

$prevLevelUrl=$eCpattern->config['level_urls'][$k-1];
$eCpattern->getLevelUrls($eCpattern->cur_level_urls[$prevLevelUrl['name']],$k+1,true);
}
}
}
}

if($signCont){

if(empty($eCpattern->config['level_urls'])){

$eCpattern->getContUrls($eCpattern->cur_source_url);
}else{

$endLevelNum=count($eCpattern->config['level_urls']);
$endLevel=$eCpattern->config['level_urls'][$endLevelNum-1];
$eCpattern->getContUrls($eCpattern->cur_level_urls[$endLevel['name']]);
}
}

$val_list=$eCpattern->getFields($cont_url);
if(empty($eCpattern->first_loop_field)){

Expand All @@ -509,7 +599,7 @@ public function testAction(){
foreach ($eCpattern->exclude_cont_urls[$md5Url] as $k=>$v){
$num+=count((array)$v);
}
$msg='通过数据处理排除了'.$num.'条数据';
$msg='通过数据处理筛除了'.$num.'条数据';
}
}

Expand Down
34 changes: 33 additions & 1 deletion SkycaijiApp/admin/controller/Mystore.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,39 @@
use skycaiji\admin\model\FuncApp;
class Mystore extends BaseController {
public function indexAction(){
$this->redirect('Mystore/rule');
$this->redirect('Mystore/store');
}
public function storeAction(){
$url=input('url','','strip_tags');
if(!empty($url)&&!is_official_url($url)){

$provData=model('Provider')->where('url',$url)->find();
if(empty($provData)){
$this->error($url.' 平台未添加');
}
if(empty($provData['enable'])){
$this->error($url.' 已设置为拒绝访问');
}
$url=$provData['url'];

$url.=strpos($url, '?')===false?'?':'&';
$url.='clientinfo='.urlencode($GLOBALS['_sc']['clientinfo']);

$this->assign('provData',$provData);
}
if(empty($url)){
$url='https://www.skycaiji.com/store';
}

if(!empty($url)){

}

$GLOBALS['_sc']['p_name']=lang('store');
$GLOBALS['_sc']['p_nav']=breadcrumb(array(array('url'=>url('Mystore/store'),'title'=>lang('store'))));

$this->assign('url',$url);
return $this->fetch();
}
public function ruleAction(){
$mrule=model('Rule');
Expand Down
2 changes: 1 addition & 1 deletion SkycaijiApp/admin/controller/Release.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function testAction(){
$this->echo_msg(lang('task_error_empty_task'));
exit();
}
model('Task')->loadConfig($taskData['config']);
model('Task')->loadConfig($taskData);

$collData=model('Collector')->where(array('task_id'=>$taskData['id'],'module'=>$taskData['module']))->find();
if(empty($collData)){
Expand Down
15 changes: 14 additions & 1 deletion SkycaijiApp/admin/controller/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function download_imgAction(){
if($config['img_name']=='custom'){

if(empty($config['name_custom_path'])){
$this->error('请输入图片名称自定义目录');
$this->error('请输入图片名称自定义路径');
}
if(!$checkNamePath['success']){
$this->error($checkNamePath['msg']);
Expand All @@ -151,6 +151,19 @@ public function download_imgAction(){
}
}

$checkNameName=$mconfig->check_img_name_name($config['name_custom_name']);
if($config['img_name']=='custom'){

if(!empty($config['name_custom_name'])&&!$checkNameName['success']){
$this->error($checkNameName['msg']);
}
}else{

if(!$checkNameName['success']){
$config['name_custom_name']='';
}
}

$mconfig->setConfig('download_img',$config);

$this->success(lang('op_success'),'Setting/download_img');
Expand Down
Loading

0 comments on commit f5af21e

Please sign in to comment.