From 4214dc2899da87741e21c5c73574714ff0f95231 Mon Sep 17 00:00:00 2001
From: zorlan <285909184@qq.com>
Date: Sun, 23 Jun 2019 10:56:18 +0800
Subject: [PATCH] 2.2
---
SkycaijiApp/admin/controller/App.php | 464 +--
SkycaijiApp/admin/controller/Provider.php | 284 +-
SkycaijiApp/admin/event/CpatternBase.php | 2802 ++++++++---------
SkycaijiApp/admin/model/App.php | 62 +-
SkycaijiApp/admin/model/Provider.php | 22 +-
SkycaijiApp/admin/view/app/agreement.html | 20 +-
SkycaijiApp/admin/view/app/apiop.html | 116 +-
SkycaijiApp/admin/view/app/manage.html | 134 +-
SkycaijiApp/admin/view/develop/app.html | 310 +-
.../admin/view/develop/appAddPack.html | 82 +-
SkycaijiApp/admin/view/mystore/app.html | 202 +-
SkycaijiApp/admin/view/provider/list.html | 136 +-
SkycaijiApp/admin/view/provider/save.html | 72 +-
SkycaijiApp/public/app/index_php.tpl | 14 +-
SkycaijiApp/public/app/skycaiji_php.tpl | 40 +-
app/app/skycaiji.php | 538 ++--
build.php | 50 +-
nginx.conf | 6 +-
public/static/css/app.css | 48 +-
public/static/js/admin/app.js | 18 +-
public/static/js/admin/provider.js | 18 +-
21 files changed, 2719 insertions(+), 2719 deletions(-)
diff --git a/SkycaijiApp/admin/controller/App.php b/SkycaijiApp/admin/controller/App.php
index 7d4c74d0..bc9f4459 100644
--- a/SkycaijiApp/admin/controller/App.php
+++ b/SkycaijiApp/admin/controller/App.php
@@ -1,233 +1,233 @@
-error('app标识错误');
- }
- $mapp=model('App');
- $appData=$mapp->getByApp($app);
- if(empty($appData)){
- $this->error('应用未安装');
- }
- $appUrl=config('root_website').'/app/'.$app.'/';
-
- $navPacks=array();
- if(is_array($appData['config']['packs'])){
- $manageUrl=url('App/manage?app='.$app);
- $manageUrl.=strpos($manageUrl,'?')===false?'?':'&';
- foreach ($appData['config']['packs'] as $k=>$v){
- if($v['type']=='nav'){
- $v['nav_link']=str_replace(array('{app}','{apps}'), array(config('root_website').'/app/'.$app.'/',config('root_website').'/app/'),$v['nav_link']);
- if(!preg_match('/^\w+\:\/\//', $v['nav_link'])){
-
- $v['nav_link']=$appUrl.$v['nav_link'];
- }
-
- if(isset($navid)&&$navid==$k){
-
- $v['is_current']=true;
- }
- $navPacks[$k]=$v;
- }
- }
- }
- $provData=null;
- $mprov=model('Provider');
- if($appData['provider_id']>0){
- $provData=$mprov->where('id',$appData['provider_id'])->find();
- }
-
- $appClass=$mapp->app_class($app);
- if(is_object($appClass)){
- if(version_compare($appClass->config['version'], $appData['config']['version'],'>')===true){
-
- $this->assign('newest_version',$appClass->config['version']);
- }
-
- $appData['app_class']=$mapp->get_class_vars($appClass);
- }
-
-
-
-
- $this->assign('app',$app);
- $this->assign('appUrl',$appUrl);
- $this->assign('navid',$navid);
- $this->assign('navPacks',$navPacks);
- $this->assign('appData',$appData);
- $this->assign('provData',$provData);
- return $this->fetch();
- }
- /*协议*/
- public function agreementAction(){
- $app=input('app');
- $appClass=model('App')->app_class($app);
- $this->assign('app',$app);
- $this->assign('name',$appClass->config['name']);
- $this->assign('agreement',$appClass->config['agreement']);
-
- return $this->fetch('agreement');
- }
- /*安装*/
- public function installAction(){
- $app=input('app');
- $success=input('success');
- if(empty($app)){
- $this->error('app标识错误');
- }
- $mapp=model('App');
-
- if(!$mapp->right_app($app)){
- $this->error('抱歉,app标识不规范!');
- }
- if($mapp->where('app',$app)->count()>0){
- $this->success('该应用已安装!','Mystore/app');
- }
- $appClass=$mapp->app_class($app);
- if(!is_object($appClass)||empty($appClass->install)){
- $this->error('不存在安装接口!');
- }
- if(!empty($appClass->config['phpv'])){
-
- if(version_compare(PHP_VERSION, $appClass->config['phpv'],'<')){
- $this->error('抱歉,该应用要求PHP版本最低'.$appClass->config['phpv']);
- }
- }
-
- if($appClass->install!='1'){
-
- if(!$success){
-
- $apiUrl=config('root_url').'/app/'.$app.'/'.$appClass->install;
- $this->assign('app',$app);
- $this->assign('op','install');
- $this->assign('apiUrl',$apiUrl);
- return $this->fetch('apiop');
- }
- }
- $newData=array(
- 'app'=>$app,
- 'addtime'=>time(),
- 'uptime'=>time(),
- 'provider_id'=>model('Provider')->getIdByUrl($appClass->config['website'])
- );
- $mapp->isUpdate(false)->allowField(true)->save($newData);
- if($mapp->id>0){
- $mapp->set_config($app,$appClass->config);
- $this->success('恭喜!安装成功','Mystore/app');
- }else{
- $this->error('安装失败!');
- }
- }
- /*卸载应用*/
- public function uninstallAction(){
- $app=input('app');
- $success=input('success');
- if(empty($app)){
- $this->error('app标识错误');
- }
- $mapp=model('App');
-
- if($mapp->where('app',$app)->count()<=0){
- $this->success('该应用已卸载!','Mystore/app');
- }
- $appClass=$mapp->app_class($app);
- if(!is_object($appClass)){
-
- $mapp->deleteByApp($app);
- $this->success('卸载成功');
- }
- if(empty($appClass->uninstall)){
- $this->error('不存在卸载接口!');
- }
-
- if($appClass->uninstall!='1'){
-
- if(!$success){
-
- $apiUrl=config('root_url').'/app/'.$app.'/'.$appClass->uninstall;
- $this->assign('app',$app);
- $this->assign('op','uninstall');
- $this->assign('apiUrl',$apiUrl);
- return $this->fetch('apiop');
- }
- }
-
- $mapp->deleteByApp($app);
-
- $this->success('卸载成功,您可以手动删除app/'.$app.'目录彻底清除应用');
- }
- /*升级应用*/
- public function upgradeAction(){
- $app=input('app');
- $success=input('success');
- if(empty($app)){
- $this->error('app标识错误');
- }
- $mapp=model('App');
-
- $appData=$mapp->getByApp($app);
- if(empty($appData)){
- $this->success('请先安装应用!','Mystore/app');
- }
- $appClass=$mapp->app_class($app);
- if(!is_object($appClass)||empty($appClass->upgrade)){
- $this->error('不存在升级接口!');
- }
- $referer=\think\Request::instance()->server('HTTP_REFERER',null,null);
- if(version_compare($appClass->config['version'], $appData['config']['version'],'=')===true){
-
- $this->success('已升级!',$referer);
- }
-
- if($appClass->upgrade!='1'){
-
- if(!$success){
-
- $apiUrl=config('root_url').'/app/'.$app.'/'.$appClass->upgrade;
- $this->assign('app',$app);
- $this->assign('op','upgrade');
- $this->assign('apiUrl',$apiUrl);
- return $this->fetch('apiop');
- }
- }
-
- $mapp->strict(false)->where('app',$app)->update(array(
- 'uptime'=>time(),
- 'provider_id'=>model('Provider')->getIdByUrl($appClass->config['website'])
- ));
- $mapp->set_config($app,$appClass->config);
-
- $this->success('恭喜!升级成功',$referer);
- }
- /*开启、关闭应用*/
- public function enableAction(){
- $app=input('app');
- $enable=input('enable/d',0);
- if(empty($app)){
- $this->error('app标识错误');
- }
- $mapp=model('App');
-
- $enable=$enable?1:0;
-
- $mapp->set_config($app,array('enable'=>$enable));
-
- $referer=\think\Request::instance()->server('HTTP_REFERER',null,null);
- $this->success('应用已'.($enable?'开启':'关闭'),$referer);
- }
+error('app标识错误');
+ }
+ $mapp=model('App');
+ $appData=$mapp->getByApp($app);
+ if(empty($appData)){
+ $this->error('应用未安装');
+ }
+ $appUrl=config('root_website').'/app/'.$app.'/';
+
+ $navPacks=array();
+ if(is_array($appData['config']['packs'])){
+ $manageUrl=url('App/manage?app='.$app);
+ $manageUrl.=strpos($manageUrl,'?')===false?'?':'&';
+ foreach ($appData['config']['packs'] as $k=>$v){
+ if($v['type']=='nav'){
+ $v['nav_link']=str_replace(array('{app}','{apps}'), array(config('root_website').'/app/'.$app.'/',config('root_website').'/app/'),$v['nav_link']);
+ if(!preg_match('/^\w+\:\/\//', $v['nav_link'])){
+
+ $v['nav_link']=$appUrl.$v['nav_link'];
+ }
+
+ if(isset($navid)&&$navid==$k){
+
+ $v['is_current']=true;
+ }
+ $navPacks[$k]=$v;
+ }
+ }
+ }
+ $provData=null;
+ $mprov=model('Provider');
+ if($appData['provider_id']>0){
+ $provData=$mprov->where('id',$appData['provider_id'])->find();
+ }
+
+ $appClass=$mapp->app_class($app);
+ if(is_object($appClass)){
+ if(version_compare($appClass->config['version'], $appData['config']['version'],'>')===true){
+
+ $this->assign('newest_version',$appClass->config['version']);
+ }
+
+ $appData['app_class']=$mapp->get_class_vars($appClass);
+ }
+
+
+
+
+ $this->assign('app',$app);
+ $this->assign('appUrl',$appUrl);
+ $this->assign('navid',$navid);
+ $this->assign('navPacks',$navPacks);
+ $this->assign('appData',$appData);
+ $this->assign('provData',$provData);
+ return $this->fetch();
+ }
+ /*协议*/
+ public function agreementAction(){
+ $app=input('app');
+ $appClass=model('App')->app_class($app);
+ $this->assign('app',$app);
+ $this->assign('name',$appClass->config['name']);
+ $this->assign('agreement',$appClass->config['agreement']);
+
+ return $this->fetch('agreement');
+ }
+ /*安装*/
+ public function installAction(){
+ $app=input('app');
+ $success=input('success');
+ if(empty($app)){
+ $this->error('app标识错误');
+ }
+ $mapp=model('App');
+
+ if(!$mapp->right_app($app)){
+ $this->error('抱歉,app标识不规范!');
+ }
+ if($mapp->where('app',$app)->count()>0){
+ $this->success('该应用已安装!','Mystore/app');
+ }
+ $appClass=$mapp->app_class($app);
+ if(!is_object($appClass)||empty($appClass->install)){
+ $this->error('不存在安装接口!');
+ }
+ if(!empty($appClass->config['phpv'])){
+
+ if(version_compare(PHP_VERSION, $appClass->config['phpv'],'<')){
+ $this->error('抱歉,该应用要求PHP版本最低'.$appClass->config['phpv']);
+ }
+ }
+
+ if($appClass->install!='1'){
+
+ if(!$success){
+
+ $apiUrl=config('root_url').'/app/'.$app.'/'.$appClass->install;
+ $this->assign('app',$app);
+ $this->assign('op','install');
+ $this->assign('apiUrl',$apiUrl);
+ return $this->fetch('apiop');
+ }
+ }
+ $newData=array(
+ 'app'=>$app,
+ 'addtime'=>time(),
+ 'uptime'=>time(),
+ 'provider_id'=>model('Provider')->getIdByUrl($appClass->config['website'])
+ );
+ $mapp->isUpdate(false)->allowField(true)->save($newData);
+ if($mapp->id>0){
+ $mapp->set_config($app,$appClass->config);
+ $this->success('恭喜!安装成功','Mystore/app');
+ }else{
+ $this->error('安装失败!');
+ }
+ }
+ /*卸载应用*/
+ public function uninstallAction(){
+ $app=input('app');
+ $success=input('success');
+ if(empty($app)){
+ $this->error('app标识错误');
+ }
+ $mapp=model('App');
+
+ if($mapp->where('app',$app)->count()<=0){
+ $this->success('该应用已卸载!','Mystore/app');
+ }
+ $appClass=$mapp->app_class($app);
+ if(!is_object($appClass)){
+
+ $mapp->deleteByApp($app);
+ $this->success('卸载成功');
+ }
+ if(empty($appClass->uninstall)){
+ $this->error('不存在卸载接口!');
+ }
+
+ if($appClass->uninstall!='1'){
+
+ if(!$success){
+
+ $apiUrl=config('root_url').'/app/'.$app.'/'.$appClass->uninstall;
+ $this->assign('app',$app);
+ $this->assign('op','uninstall');
+ $this->assign('apiUrl',$apiUrl);
+ return $this->fetch('apiop');
+ }
+ }
+
+ $mapp->deleteByApp($app);
+
+ $this->success('卸载成功,您可以手动删除app/'.$app.'目录彻底清除应用');
+ }
+ /*升级应用*/
+ public function upgradeAction(){
+ $app=input('app');
+ $success=input('success');
+ if(empty($app)){
+ $this->error('app标识错误');
+ }
+ $mapp=model('App');
+
+ $appData=$mapp->getByApp($app);
+ if(empty($appData)){
+ $this->success('请先安装应用!','Mystore/app');
+ }
+ $appClass=$mapp->app_class($app);
+ if(!is_object($appClass)||empty($appClass->upgrade)){
+ $this->error('不存在升级接口!');
+ }
+ $referer=\think\Request::instance()->server('HTTP_REFERER',null,null);
+ if(version_compare($appClass->config['version'], $appData['config']['version'],'=')===true){
+
+ $this->success('已升级!',$referer);
+ }
+
+ if($appClass->upgrade!='1'){
+
+ if(!$success){
+
+ $apiUrl=config('root_url').'/app/'.$app.'/'.$appClass->upgrade;
+ $this->assign('app',$app);
+ $this->assign('op','upgrade');
+ $this->assign('apiUrl',$apiUrl);
+ return $this->fetch('apiop');
+ }
+ }
+
+ $mapp->strict(false)->where('app',$app)->update(array(
+ 'uptime'=>time(),
+ 'provider_id'=>model('Provider')->getIdByUrl($appClass->config['website'])
+ ));
+ $mapp->set_config($app,$appClass->config);
+
+ $this->success('恭喜!升级成功',$referer);
+ }
+ /*开启、关闭应用*/
+ public function enableAction(){
+ $app=input('app');
+ $enable=input('enable/d',0);
+ if(empty($app)){
+ $this->error('app标识错误');
+ }
+ $mapp=model('App');
+
+ $enable=$enable?1:0;
+
+ $mapp->set_config($app,array('enable'=>$enable));
+
+ $referer=\think\Request::instance()->server('HTTP_REFERER',null,null);
+ $this->success('应用已'.($enable?'开启':'关闭'),$referer);
+ }
}
\ No newline at end of file
diff --git a/SkycaijiApp/admin/controller/Provider.php b/SkycaijiApp/admin/controller/Provider.php
index 6079948b..0a03878e 100644
--- a/SkycaijiApp/admin/controller/Provider.php
+++ b/SkycaijiApp/admin/controller/Provider.php
@@ -1,143 +1,143 @@
-where($cond)->order('sort desc')->paginate(20,false,paginate_auto_config());
- $pagenav=$list->render();
- $list=$list->all();
-
- $GLOBALS['content_header']='第三方平台';
- $GLOBALS['breadcrumb']=breadcrumb(array('第三方平台'));
-
- $this->assign('list',$list);
- $this->assign('pagenav',$pagenav);
-
- return $this->fetch();
- }
- public function deleteAction(){
- $id=input('id/d');
- if(empty($id)){
- $this->error('id不存在');
- }
- $mprovider=model('Provider');
- $mprovider->where('id',$id)->delete();
-
- $this->success();
- }
- public function enableAction(){
- $id=input('id/d');
- $enable=input('enable/d');
- if(empty($id)){
- $this->error('id不存在');
- }
- $mprovider=model('Provider');
- $mprovider->strict(false)->where('id',$id)->update(array('enable'=>$enable));
-
- $this->success();
- }
- public function saveAction(){
- $id=input('id/d');
- $mprovider=model('Provider');
- if($id>0){
- $proData=$mprovider->where('id',$id)->find();
- if(!empty($proData)){
- $proData=$proData->toArray();
- }
- $this->assign('proData',$proData);
- }
- if(request()->isPost()){
- $url=input('url','','strip_tags');
- $title=input('title');
- $sort=input('sort/d',0);
- $enable=input('enable/d',0);
-
- $domain=\skycaiji\admin\model\Provider::matchDomain($url);
- if(empty($domain)){
- $this->error('网址格式错误');
- }
-
- if(empty($proData)||strcasecmp($proData['url'], $url)!==0){
-
- if($mprovider->where('url',$url)->count()>0){
-
- $this->error('该网址已存在');
- }
- }
-
- $domainCond=array(
- 'domain'=>$domain
- );
- if(!empty($proData)){
- $domainCond['id']=array('<>',$proData['id']);
- }
- if($mprovider->where($domainCond)->count()>0){
-
- $this->error($domain.' 域名已存在');
- }
-
- if(empty($title)){
- $html=get_html($url,null,array('timeout'=>3));
- if(preg_match('/
]*>(.*?)<\/title>/i', $html,$title)){
- $title=strip_tags($title[1]);
- }else{
- $title='';
- }
- }
-
- $newData=array(
- 'url'=>$url,
- 'title'=>$title,
- 'domain'=>$domain,
- 'enable'=>$enable,
- 'sort'=>$sort
- );
- if(empty($proData)){
-
- $mprovider->isUpdate(false)->allowField(true)->save($newData);
- $this->success('添加成功','Provider/list');
- }else{
-
- $mprovider->strict(false)->where('id',$id)->update($newData);
- $this->success('修改成功','Provider/list');
- }
- }else{
- return $this->fetch();
- }
- }
-
- public function saveallAction(){
- $newsort=input('newsort/a');
- $mprovider=model('Provider');
- if(is_array($newsort)&&count($newsort)>0){
- foreach ($newsort as $key=>$val){
- $mprovider->strict(false)->where('id',intval($key))->update(array('sort'=>intval($val)));
- }
- }
- $this->success('保存成功','Provider/list');
- }
+where($cond)->order('sort desc')->paginate(20,false,paginate_auto_config());
+ $pagenav=$list->render();
+ $list=$list->all();
+
+ $GLOBALS['content_header']='第三方平台';
+ $GLOBALS['breadcrumb']=breadcrumb(array('第三方平台'));
+
+ $this->assign('list',$list);
+ $this->assign('pagenav',$pagenav);
+
+ return $this->fetch();
+ }
+ public function deleteAction(){
+ $id=input('id/d');
+ if(empty($id)){
+ $this->error('id不存在');
+ }
+ $mprovider=model('Provider');
+ $mprovider->where('id',$id)->delete();
+
+ $this->success();
+ }
+ public function enableAction(){
+ $id=input('id/d');
+ $enable=input('enable/d');
+ if(empty($id)){
+ $this->error('id不存在');
+ }
+ $mprovider=model('Provider');
+ $mprovider->strict(false)->where('id',$id)->update(array('enable'=>$enable));
+
+ $this->success();
+ }
+ public function saveAction(){
+ $id=input('id/d');
+ $mprovider=model('Provider');
+ if($id>0){
+ $proData=$mprovider->where('id',$id)->find();
+ if(!empty($proData)){
+ $proData=$proData->toArray();
+ }
+ $this->assign('proData',$proData);
+ }
+ if(request()->isPost()){
+ $url=input('url','','strip_tags');
+ $title=input('title');
+ $sort=input('sort/d',0);
+ $enable=input('enable/d',0);
+
+ $domain=\skycaiji\admin\model\Provider::matchDomain($url);
+ if(empty($domain)){
+ $this->error('网址格式错误');
+ }
+
+ if(empty($proData)||strcasecmp($proData['url'], $url)!==0){
+
+ if($mprovider->where('url',$url)->count()>0){
+
+ $this->error('该网址已存在');
+ }
+ }
+
+ $domainCond=array(
+ 'domain'=>$domain
+ );
+ if(!empty($proData)){
+ $domainCond['id']=array('<>',$proData['id']);
+ }
+ if($mprovider->where($domainCond)->count()>0){
+
+ $this->error($domain.' 域名已存在');
+ }
+
+ if(empty($title)){
+ $html=get_html($url,null,array('timeout'=>3));
+ if(preg_match('/]*>(.*?)<\/title>/i', $html,$title)){
+ $title=strip_tags($title[1]);
+ }else{
+ $title='';
+ }
+ }
+
+ $newData=array(
+ 'url'=>$url,
+ 'title'=>$title,
+ 'domain'=>$domain,
+ 'enable'=>$enable,
+ 'sort'=>$sort
+ );
+ if(empty($proData)){
+
+ $mprovider->isUpdate(false)->allowField(true)->save($newData);
+ $this->success('添加成功','Provider/list');
+ }else{
+
+ $mprovider->strict(false)->where('id',$id)->update($newData);
+ $this->success('修改成功','Provider/list');
+ }
+ }else{
+ return $this->fetch();
+ }
+ }
+
+ public function saveallAction(){
+ $newsort=input('newsort/a');
+ $mprovider=model('Provider');
+ if(is_array($newsort)&&count($newsort)>0){
+ foreach ($newsort as $key=>$val){
+ $mprovider->strict(false)->where('id',intval($key))->update(array('sort'=>intval($val)));
+ }
+ }
+ $this->success('保存成功','Provider/list');
+ }
}
\ No newline at end of file
diff --git a/SkycaijiApp/admin/event/CpatternBase.php b/SkycaijiApp/admin/event/CpatternBase.php
index 8a9a273e..d820433c 100644
--- a/SkycaijiApp/admin/event/CpatternBase.php
+++ b/SkycaijiApp/admin/event/CpatternBase.php
@@ -1,1402 +1,1402 @@
-used_cont_urls)){
-
- $usedContUrls=array_keys($this->used_cont_urls);
- if(!empty($usedContUrls)&&is_array($usedContUrls)){
- $total=count($usedContUrls);
- $limit=800;
- $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')->db()->where('cname','in',$list)->delete();
- }
- }
- }
- }
- }
-
- /*规则匹配区域*/
- public function rule_match_area($config,$html){
- if(!empty($config['reg_area'])){
- if(empty($config['reg_area_module'])){
-
- if(preg_match('/'.$config['reg_area'].'/i',$html,$area_cont)){
- if(isset($area_cont['match'])){
- $html=$area_cont['match'];
- }else{
- $html=$area_cont[0];
- }
- }else{
- $html='';
- }
- }elseif('json'==$config['reg_area_module']){
- $html=$this->rule_module_json_data(array('json'=>$config['reg_area'],'json_arr'=>'jsonencode'),$html);
- }elseif('xpath'==$config['reg_area_module']){
- $html=$this->rule_module_xpath_data(array('xpath'=>$config['reg_area'],'xpath_attr'=>'outerHtml'),$html);
- }else{
- $html='';
- }
- }
- return $html;
- }
- /**
- * 规则匹配网址
- * @param array $config 配置参数
- * @param string $html 源码
- * @param bool $whole 完全匹配模式
- *
- */
- public function rule_match_urls($config,$html,$whole=false){
- $cont_urls=array();
- if(!empty($config['reg_url'])&&!empty($config['url_merge'])){
-
- $sign_match=$this->sign_addslashes(cp_sign('match','(?P\d*)'));
- if(preg_match_all('/'.$sign_match.'/i', $config['url_merge'],$match_signs)){
-
- $url_merge=true;
- if(empty($config['reg_url_module'])){
-
- if(preg_match('/\(\?P/i', $config['reg_url'])){
-
- if(preg_match_all('/'.$config['reg_url'].'/i',$html,$cont_urls,PREG_SET_ORDER)){
- if($config['url_merge']==cp_sign('match')){
-
- $url_merge=false;
- foreach ($cont_urls as $k=>$v){
- $cont_urls[$k]=$v['match'];
- }
- }
- }
- }else{
-
- if($whole){
-
- if(preg_match_all('/'.$config['reg_url'].'/i',$html,$cont_urls)){
- $cont_urls=$cont_urls[0];
-
- if($config['url_merge']==cp_sign('match')){
-
- $url_merge=false;
- }else{
-
- foreach ($cont_urls as $k=>$v){
- $cont_urls[$k]=array(
- 'match'=>$v
- );
- }
- }
- }
- }
- }
- }elseif(in_array($config['reg_url_module'],array('xpath','json'))){
-
- if('xpath'==$config['reg_url_module']){
-
- $cont_urls=$this->rule_module_xpath_data ( array (
- 'xpath' => $config['reg_url'],
- 'xpath_attr' => 'href',
- 'xpath_multi'=>true,
- 'xpath_multi_type'=>'loop'
- ),$html);
- $cont_urls=is_array($cont_urls)?$cont_urls:array();
- }elseif('json'==$config['reg_url_module']){
-
- $cont_urls=$this->rule_module_json_data(array('json'=>$config['reg_url'],'json_arr'=>'_original_'),$html);
- if(empty($cont_urls)){
- $cont_urls=array();
- }elseif(!is_array($cont_urls)){
- $cont_urls=array($cont_urls);
- }
- }
-
- if($config['url_merge']==cp_sign('match')){
-
- $url_merge=false;
- }else{
-
- foreach ($cont_urls as $k=>$v){
- $cont_urls[$k]=array(
- 'match'=>$v
- );
- }
- }
- }
-
- if($url_merge){
-
- foreach ($cont_urls as $k=>$v){
- $re_match=array();
- foreach($match_signs['num'] as $ms_k=>$ms_v){
-
- $re_match[$ms_k]=$v['match'.$ms_v];
- }
-
- $cont_urls[$k]=str_replace($match_signs[0], $re_match, $config['url_merge']);
- }
- }
- }
- }
- $cont_urls=is_array($cont_urls)?array_unique($cont_urls):array();
- $cont_urls=array_values($cont_urls);
- return $cont_urls;
- }
-
-
- public function match_rule($html,$rule,$merge,$multi=false,$multi_str=''){
- $val='';
- $sign_match=$this->sign_addslashes(cp_sign('match','(?P\d*)'));
- if(!empty($rule)&&preg_match_all('/'.$sign_match.'/i',$merge,$match_signs)){
-
- $multiStr='';
- if(!empty($multi)){
-
- preg_match_all('/'.$rule.'/i',$html,$match_conts,PREG_SET_ORDER);
- $multiStr=str_replace(array('\r','\n'), array("\r","\n"), $multi_str);
- }else{
- if(preg_match('/'.$rule.'/i', $html,$match_cont)){
- $match_conts=array($match_cont);
- }
- }
- $curI=0;
- foreach ($match_conts as $match_cont){
- $curI++;
-
- $re_match=array();
- foreach($match_signs['num'] as $ms_k=>$ms_v){
- $re_match[$ms_k]=$match_cont['match'.$ms_v];
- }
- $val.=($curI<=1?'':$multiStr).str_replace($match_signs[0], $re_match, $merge);
- }
- }
- return $val;
- }
-
- /**
- * 规则匹配,方法可调用,$field_params传入规则参数
- * @param array $field_params
- * @param string $html
- * @return string
- */
- public function field_module_rule($field_params,&$html){
-
- $val='';
- $sign_match=$this->sign_addslashes(cp_sign('match','(?P\d*)'));
- if(!empty($field_params['reg_rule'])&&preg_match_all('/'.$sign_match.'/i', $field_params['rule_merge'],$match_signs)){
-
- $multiStr='';
- $is_loop=false;
- if(!empty($field_params['rule_multi'])){
-
- preg_match_all('/'.$field_params['reg_rule'].'/i',$html,$match_conts,PREG_SET_ORDER);
- $is_loop='loop'==$field_params['rule_multi_type']?true:false;
- if($is_loop){
- if(empty($this->first_loop_field)){
-
- $this->first_loop_field=$field_params['name'];
- }
- $val=array();
- }else{
- $multiStr=str_replace(array('\r','\n'), array("\r","\n"), $field_params['rule_multi_str']);
- }
- }else{
- if(preg_match('/'.$field_params['reg_rule'].'/i', $html,$match_cont)){
- $match_conts=array($match_cont);
- }
- }
-
- $curI=0;
- if(is_array($match_conts)){
- foreach ($match_conts as $match_cont){
- $curI++;
-
- $re_match=array();
- foreach($match_signs['num'] as $ms_k=>$ms_v){
- $re_match[$ms_k]=$match_cont['match'.$ms_v];
- }
- $contVal=str_replace($match_signs[0], $re_match, $field_params['rule_merge']);
- if($is_loop){
-
- $val[]=$contVal;
- }else{
-
- $val.=($curI<=1?'':$multiStr).$contVal;
- }
- }
- }
- }
- return $val;
- }
- /**
- * xpath规则,方法可调用,$field_params传入规则参数
- * @param array $field_params
- * @param string $html
- * @return string
- */
- public function field_module_xpath($field_params,$html){
- if(!empty($field_params['xpath_multi'])){
-
- if('loop'==$field_params['xpath_multi_type']){
-
- if(empty($this->first_loop_field)){
-
- $this->first_loop_field=$field_params['name'];
- }
- }
- }
- return $this->rule_module_xpath_data($field_params,$html);
- }
- public function rule_module_xpath_data($field_params,$html){
- $vals='';
- if(!empty($field_params['xpath'])){
- $dom=new \DOMDocument;
- $libxml_previous_state = libxml_use_internal_errors(true);
- @$dom->loadHTML(''.$html);
-
- $dom->normalize();
-
- $xPath = new \DOMXPath($dom);
-
- $xpath_attr=strtolower($field_params['xpath_attr']);
- $xpath_attr='custom'==$xpath_attr?strtolower($field_params['xpath_attr_custom']):$xpath_attr;
-
- $normal_attr=true;
- if(in_array($xpath_attr,array('innerhtml','outerhtml','text'))){
-
- $normal_attr=false;
- }
- $xpath_q=trim($field_params['xpath']);
- if(!empty($xpath_attr)){
-
- if(preg_match('/\/\@[\w\-]+$/', $xpath_q)){
-
- $xpath_q=preg_replace('/\@[\w\-]+$/', '', $xpath_q);
- }
- if($normal_attr){
-
- $xpath_q=$xpath_q.(preg_match('/\/$/', $xpath_q)?'':'/').'@'.$xpath_attr;
- }
- }else{
-
- if(!preg_match('/\/\@[\w\-]+$/', $xpath_q)){
-
- $xpath_attr='innerhtml';
- $normal_attr=false;
- }
- }
-
- $nodes = $xPath->query($xpath_q);
-
- $multiStr='';
- $is_loop=false;
- if(!empty($field_params['xpath_multi'])){
-
- $is_loop='loop'==$field_params['xpath_multi_type']?true:false;
- if($is_loop){
-
-
-
-
- $vals=array();
- }else{
-
- $multiStr=str_replace(array('\r','\n'), array("\r","\n"), $field_params['xpath_multi_str']);
- }
- }
-
- $curI=0;
- foreach ($nodes as $node){
- $curI++;
- $val=($curI<=1?'':$multiStr);
- if($normal_attr){
-
- $val.=$node->nodeValue;
- }else{
-
- switch ($xpath_attr){
- case 'innerhtml':
- $nchilds = $node->childNodes;
- foreach ($nchilds as $nchild){
- $val .= $nchild->ownerDocument->saveHTML($nchild);
- }
- break;
- case 'outerhtml':$val.=$node->ownerDocument->saveHTML($node);break;
- case 'text':
-
-
- $nchilds = $node->childNodes;
- foreach ($nchilds as $nchild){
- $val .= $nchild->ownerDocument->saveHTML($nchild);
- }
- $val=$this->filter_html_tags($val, array('style','script','object'));
- $val=strip_tags($val);
- break;
- }
- }
-
- if($is_loop){
-
- $vals[]=$val;
- }else{
- $vals.=$val;
- }
-
- if(empty($field_params['xpath_multi'])){
-
- break;
- }
- }
-
- libxml_clear_errors();
-
- }
- return $vals;
- }
-
- /*自动获取*/
- public function field_module_auto($field_params,&$html,$cur_url){
- switch (strtolower($field_params['auto'])){
- case 'title':$val=$this->get_title($html);break;
- case 'content':$val=$this->get_content($html);break;
- case 'keywords':$val=$this->get_keywords($html);break;
- case 'description':$val=$this->get_description($html);break;
- case 'url':$val=$cur_url;break;
- }
- return $val;
- }
- public function field_module_words($field_params){
-
- return $field_params['words'];
- }
- public function field_module_num($field_params){
-
- $start=intval($field_params['num_start']);
- $end=intval($field_params['num_end']);
- return rand($start, $end);
- }
- public function field_module_time($field_params){
- $val='';
- $start=empty($field_params['time_start'])?NOW_TIME:strtotime($field_params['time_start']);
- $end=empty($field_params['time_end'])?NOW_TIME:strtotime($field_params['time_end']);
- $time=rand($start, $end);
- if(empty($field_params['time_stamp'])){
-
- $fmt=empty($field_params['time_format'])?'Y-m-d H:i':
- str_replace(array('[年]','[月]','[日]','[时]','[分]','[秒]'), array('Y','m','d','H','i','s'), $field_params['time_format']);
- $val=date($fmt,$time);
- }else{
- $val=$time;
- }
- return $val;
- }
- public function field_module_list($field_params){
- static $list=array();
- $key=md5($field_params['list']);
- if(!isset($list[$key])){
-
- if(preg_match_all('/[^\r\n]+/', $field_params['list'],$str_list)){
- $str_list=$str_list[0];
- }else{
- $str_list=array();
- }
- $list[$key]=$str_list;
- }
- $str_list=$list[$key];
- $val='';
- if(!empty($str_list)){
- $randi=array_rand($str_list,1);
- $val=$str_list[$randi];
- }
- return $val;
- }
- public function field_module_merge($field_params,$val_list){
- $val='';
-
- if(preg_match_all('/\[\x{5b57}\x{6bb5}\:(.+?)\]/u', $field_params['merge'],$match_fields)){
- $val=$field_params['merge'];
-
- for($i=0;$i[\s\S]+)\}\s*\)\s*[\;]{0,1}/i';
- public function field_module_json($field_params,$html,$cur_url=''){
- static $jsonList=array();
- $jsonKey=!empty($cur_url)?md5($cur_url):md5($html);
- if(!isset($jsonList[$jsonKey])){
- $jsonList[$jsonKey]=json_decode($html,true);
- if(empty($jsonList[$jsonKey])&&preg_match(self::$jsonpRegExp, $html,$json)){
-
- $json=trim($json['json']).'}';
- $jsonList[$jsonKey]=json_decode($json,true);
- }
- }
- $jsonArrType=$field_params['json_arr'];
- if($field_params['json_loop']){
-
- $field_params['json_arr']='_original_';
- }
- $val=$this->rule_module_json_data($field_params,$jsonList[$jsonKey]);
- if($field_params['json_loop']){
-
- if(is_array($val)){
- $field_params['json_arr']=$jsonArrType;
- foreach ($val as $k=>$v){
- $val[$k]=$this->rule_module_json_data_convert($v,$field_params);
- }
-
- if(empty($this->first_loop_field)){
-
- $this->first_loop_field=$field_params['name'];
- }
- }
- }
- return $val;
- }
- public function rule_module_json_data($field_params,$jsonArrOrStr){
- $jsonArr=array();
- if(is_array($jsonArrOrStr)){
- $jsonArr=&$jsonArrOrStr;
- }else{
-
- $jsonArr=json_decode($jsonArrOrStr,true);
- if(empty($jsonArr)&&preg_match(self::$jsonpRegExp,$jsonArrOrStr,$jsonArrOrStr)){
-
- $jsonArr=trim($jsonArrOrStr['json']).'}';
- $jsonArr=json_decode($jsonArr,true);
- }
- unset($jsonArrOrStr);
- }
- $val='';
- if(!empty($jsonArr)){
- if(!empty($field_params['json'])){
-
- $jsonFmt=str_replace(array('"',"'",'[',' '), '', $field_params['json']);
- $jsonFmt=str_replace(']','.',$jsonFmt);
- $jsonFmt=trim($jsonFmt,'.');
- $jsonFmt=explode('.', $jsonFmt);
- $jsonFmt=array_values($jsonFmt);
- if(!empty($jsonFmt)){
-
- $val=$jsonArr;
- $prevKey='';
- foreach ($jsonFmt as $i=>$key){
- if($prevKey=='*'){
-
- $new_field_params=$field_params;
- $new_field_params['json']=array_slice($jsonFmt, $i);
- $new_field_params['json']=implode('.', $new_field_params['json']);
-
- foreach ($val as $vk=>$vv){
-
- $val[$vk]=$this->rule_module_json_data($new_field_params,$vv);
- }
- break;
- }else{
- if($key!='*'){
-
- $val=$val[$key];
- }
- }
- $prevKey=$key;
- }
- }
- }
- }
-
- return $this->rule_module_json_data_convert($val, $field_params);
- }
- public function rule_module_json_data_convert($val,$field_params){
- if(is_array($val)){
-
- $json_arr=strtolower($field_params['json_arr']);
- if(empty($json_arr)){
- $json_arr='implode';
- }
- switch ($json_arr){
- case 'implode':$arrImplode=str_replace(array('\r','\n'), array("\r","\n"), $field_params['json_arr_implode']);$val=array_implode($arrImplode,$val);break;
- case 'jsonencode':$val=json_encode($val);break;
- case 'serialize':$val=serialize($val);break;
- case '_original_': break;
- }
- }
- return $val;
- }
-
- /*字段提取内容*/
- public function field_module_extract($field_params,$extract_field_val,$base_url,$domain_url){
- $field_html=$extract_field_val['value'];
- if(empty($field_html)){
- return '';
- }
- $val='';
- $extract_module=strtolower($field_params['extract_module']);
- switch ($extract_module){
- case 'cover':
-
- if(!empty($extract_field_val['img'])){
- $val=reset($extract_field_val['img']);
- }else{
- if(preg_match('/]*\bsrc=[\'\"](?P[^\'\"]+?)[\'\"]/i',$field_html,$cover)){
- $cover=$cover['url'];
- $cover=$this->create_complete_url($cover, $base_url, $domain_url);
- $val=$cover;
- }
- }
- break;
- case 'phone':
-
- $field_html=$this->filter_html_tags($field_html,'style,script,object');
- $field_html=strip_tags($field_html);
- if(preg_match('/\d{11}/', $field_html,$phone)){
- $val=$phone[0];
- }
- break;
- case 'email':
- $field_html=$this->filter_html_tags($field_html,'style,script,object');
- $field_html=strip_tags($field_html);
- if(preg_match('/[\w\-]+\@[\w\-\.]+/i', $field_html,$email)){
- $val=$email[0];
- }
- break;
- case 'rule':
-
- $val=$this->field_module_rule(array('reg_rule'=>$field_params['reg_extract_rule']), $field_html);
- if(empty($val)){
-
- if(preg_match('/'.$field_params['reg_extract_rule'].'/i', $field_html,$val)){
- $val=$val[0];
- }
- }
- break;
- case 'xpath':
- $val=$this->field_module_xpath(array('xpath'=>$field_params['extract_xpath'],'xpath_attr'=>$field_params['extract_xpath_attr'],'xpath_attr_custom'=>$field_params['extract_xpath_attr_custom']), $field_html);
- break;
- case 'json':
- $val=$this->field_module_json(array('json'=>$field_params['extract_json'],'json_arr'=>$field_params['extract_json_arr'],'json_arr_implode'=>$field_params['extract_json_arr_implode']), $field_html);
- break;
- }
- return $val;
- }
- /*数据处理方法*/
- public function process_f_html($fieldVal,$params){
- $htmlAllow=array_filter(explode(',',$params['html_allow']));
- $htmlFilter=array_filter(explode(',',$params['html_filter']));
- if(!empty($htmlAllow)){
-
- $htmlAllowStr='';
- foreach ($htmlAllow as $v){
- $htmlAllowStr.='<'.$v.'>';
- }
- $fieldVal=strip_tags($fieldVal,$htmlAllowStr);
- }
- if(!empty($htmlFilter)){
-
- if(in_array('all', $htmlFilter)){
-
- $fieldVal=$this->filter_html_tags($fieldVal, array('style','script','object'));
- $fieldVal=strip_tags($fieldVal);
- }else{
- $fieldVal=$this->filter_html_tags($fieldVal, $htmlFilter);
- }
- }
- return $fieldVal;
- }
- public function process_f_replace($fieldVal,$params){
- return preg_replace('/'.$params['replace_from'].'/i',$params['replace_to'], $fieldVal);
- }
- public function process_f_tool($fieldVal,$params){
-
- if(in_array('format', $params['tool_list'])){
-
- $fieldVal=$this->filter_html_tags($fieldVal,array('style','script'));
- $fieldVal=preg_replace('/\b(id|class|style|width|height|align)\s*=\s*([\'\"])[^\<\>\'\"]+?\\2(?=\s|$|\/|>)/i', ' ', $fieldVal);
- }
- if(in_array('trim', $params['tool_list'])){
-
- $fieldVal=trim($fieldVal);
- }
- if(in_array('is_img', $params['tool_list'])){
-
- if(!empty($GLOBALS['config']['caiji']['download_img'])){
-
- $fieldVal=preg_replace('/(\bhttp[s]{0,1}\:\/\/[^\s]+)/i','{[img]}'."$1".'{[/img]}',$fieldVal);
- }
- }
- return $fieldVal;
- }
- public function process_f_translate($fieldVal,$params){
-
- if(!empty($GLOBALS['config']['translate'])&&!empty($GLOBALS['config']['translate']['open'])){
-
- $fieldVal=\util\Translator::translate($fieldVal, $params['translate_from'], $params['translate_to']);
- }
- return $fieldVal;
- }
- public function process_f_batch($fieldVal,$params){
-
- static $batch_list=array();
- if(!empty($params['batch_list'])){
- $listMd5=md5($params['batch_list']);
- if(!isset($batch_list[$listMd5])){
-
- if(preg_match_all('/([^\r\n]+?)\=([^\r\n]+)/', $params['batch_list'],$mlist)){
- $batch_re=$mlist[1];
- $batch_to=$mlist[2];
- $batch_list[$listMd5]=array($batch_re,$batch_to);
- }
- }else{
- $batch_re=$batch_list[$listMd5][0];
- $batch_to=$batch_list[$listMd5][1];
- }
- $batch_re=is_array($batch_re)?$batch_re:null;
- $batch_to=is_array($batch_to)?$batch_to:null;
- if(!empty($batch_re)&&count($batch_re)==count($batch_to)){
-
- $fieldVal=str_replace($batch_re, $batch_to, $fieldVal);
- }
- }
- return $fieldVal;
- }
- public function process_f_substr($fieldVal,$params){
- $params['substr_len']=intval($params['substr_len']);
- if($params['substr_len']>0){
- if(mb_strlen($fieldVal,'utf-8')>$params['substr_len']){
-
- $fieldVal=mb_substr($fieldVal,0,$params['substr_len'],'utf-8').$params['substr_end'];
- }
- }
- return $fieldVal;
- }
- public function process_f_func($fieldVal,$params){
-
- if(!empty($params['func_name'])){
- if(!function_exists($params['func_name'])){
-
- $this->error('数据处理》无效的函数:'.$params['func_name']);
- }else{
-
- if(array_key_exists($params['func_name'], config('allow_process_func'))||array_key_exists($params['func_name'], config('EXTEND_PROCESS_FUNC'))){
-
- static $func_param_list=array();
- $funcParam=null;
- if(empty($params['func_param'])){
-
- $funcParam=array($fieldVal);
- }else{
- $fparamMd5=md5($params['func_param']);
- if(!isset($func_param_list[$fparamMd5])){
- if(preg_match_all('/[^\r\n]+/', $params['func_param'],$mfuncParam)){
- $func_param_list[$fparamMd5]=$mfuncParam[0];
- }
- }
- $funcParam=$func_param_list[$fparamMd5];
- foreach ($funcParam as $k=>$v){
- $funcParam[$k]=str_replace('###', $fieldVal, $v);
- }
- }
- if(!empty($funcParam)&&is_array($funcParam)){
- try {
- $fieldVal=call_user_func_array($params['func_name'], $funcParam);
- }catch (\Exception $ex){
-
- }
- }
- }else{
- $this->error('数据处理》未配置函数:'.$params['func_name']);
- }
- }
- }
- return $fieldVal;
- }
- public function process_f_filter($fieldVal,$params,$curUrlMd5,$loopIndex,$contUrlMd5){
- static $key_list=array();
- if(!empty($params['filter_list'])){
- $listMd5=md5($params['filter_list']);
- if(!isset($key_list[$listMd5])){
- $filterList=explode("\r\n", $params['filter_list']);
- $filterList=array_filter($filterList);
- $key_list[$listMd5]=$filterList;
- }else{
- $filterList=$key_list[$listMd5];
- }
- $filterList=is_array($filterList)?$filterList:array();
-
-
- if(!empty($params['filter_pass'])){
- if($params['filter_pass']=='1'){
-
- foreach ($filterList as $filterStr){
- if(stripos($fieldVal,$filterStr)!==false){
-
- $fieldVal='';
- break;
- }
- }
- }elseif($params['filter_pass']=='2'){
-
- foreach ($filterList as $filterStr){
- if(stripos($fieldVal,$filterStr)!==false){
-
- if(!isset($this->exclude_cont_urls[$contUrlMd5])){
- $this->exclude_cont_urls[$contUrlMd5]=array();
- }
-
- if(empty($this->first_loop_field)){
-
- $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]='filter:'.$filterStr;
- }else{
-
- if(!isset($this->exclude_cont_urls[$contUrlMd5][$curUrlMd5])){
- $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]=array();
- }
- $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5][$loopIndex]='filter:'.$filterStr;
- }
- break;
- }
- }
- }elseif($params['filter_pass']=='3'){
-
- $hasKey=false;
- foreach ($filterList as $filterStr){
- if(stripos($fieldVal,$filterStr)!==false){
-
- $hasKey=true;
- break;
- }
- }
- if(!$hasKey){
- $fieldVal='';
- }
- }elseif($params['filter_pass']=='4'){
-
- $hasKey=false;
- foreach ($filterList as $filterStr){
- if(stripos($fieldVal,$filterStr)!==false){
-
- $hasKey=true;
- break;
- }
- }
- if(!$hasKey){
-
- if(!isset($this->exclude_cont_urls[$contUrlMd5])){
- $this->exclude_cont_urls[$contUrlMd5]=array();
- }
-
- if(empty($this->first_loop_field)){
-
- $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]='filter:';
- }else{
-
- if(!isset($this->exclude_cont_urls[$contUrlMd5][$curUrlMd5])){
- $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]=array();
- }
- $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5][$loopIndex]='filter:';
- }
- }
- }
- }else{
-
- $fieldVal=str_ireplace($filterList, $params['filter_replace'], $fieldVal);
- }
- }
- return $fieldVal;
- }
- public function process_f_if($fieldVal,$params,$curUrlMd5,$loopIndex,$contUrlMd5){
- static $func_list=array();
-
- if(is_array($params['if_logic'])&&!empty($params['if_logic'])){
-
- $resultOr=array();
- $resultAnd=array();
- foreach($params['if_logic'] as $ifk=>$iflv){
- if(empty($iflv)||empty($params['if_cond'][$ifk])){
-
- continue;
- }
- $ifVal=$params['if_val'][$ifk];
- $ifCond=$params['if_cond'][$ifk];
- $result=false;
- switch($ifCond){
- case 'regexp':
- if(preg_match('/'.$ifVal.'/', $fieldVal)){
- $result=true;
- }
- break;
- case 'func':
- if(!empty($ifVal)){
-
- $funcMd5=md5($ifVal);
- if(!isset($func_list[$funcMd5])){
- if(preg_match_all('/[^\r\n]+/',$ifVal,$funcParam)){
-
- $funcParam=$funcParam[0];
- }else{
-
- $funcParam=array($ifVal);
- }
- $func_list[$funcMd5]=$funcParam;
- }else{
- $funcParam=$func_list[$funcMd5];
- }
- $funcName=$funcParam[0];
- $isTurn=false;
- if(strpos($funcName,'!')===0){
-
- $funcName=substr($funcName, 1);
- $isTurn=true;
- }
- unset($funcParam[0]);
- if(empty($funcParam)){
-
- $funcParam=array($fieldVal);
- }else{
- foreach($funcParam as $k=>$v){
- $funcParam[$k]=str_replace('###', $fieldVal, $v);
- }
- }
-
- if(!function_exists($funcName)){
-
- $this->error('数据处理》条件判断》无效的函数:'.$funcName);
- }else{
- if(array_key_exists($funcName, config('allow_process_if'))||array_key_exists($funcName, config('EXTEND_PROCESS_IF'))){
-
- try {
- $result=call_user_func_array($funcName, $funcParam);
- if($isTurn){
-
- $result=$result?false:true;
- }
- }catch (\Exception $ex){
-
- $this->error('数据处理》条件判断》函数'.$funcName.'运行错误,'.$ex->getMessage());
- }
- }else{
- $this->error('数据处理》条件判断》未配置函数:'.$funcName);
- }
- }
- }
- break;
- case 'has':$result=stripos($fieldVal,$ifVal)!==false?true:false;break;
- case 'nhas':$result=stripos($fieldVal,$ifVal)===false?true:false;break;
- case 'eq':$result=$fieldVal==$ifVal?true:false;break;
- case 'neq':$result=$fieldVal!=$ifVal?true:false;break;
- case 'heq':$result=$fieldVal===$ifVal?true:false;break;
- case 'nheq':$result=$fieldVal!==$ifVal?true:false;break;
- case 'gt':$result=$fieldVal>$ifVal?true:false;break;
- case 'egt':$result=$fieldVal>=$ifVal?true:false;break;
- case 'lt':$result=$fieldVal<$ifVal?true:false;break;
- case 'elt':$result=$fieldVal<=$ifVal?true:false;break;
- case 'time_eq':
- case 'time_egt':
- case 'time_elt':
- $fieldTime=is_numeric($fieldVal)?$fieldVal:strtotime($fieldVal);
- $valTime=is_numeric($ifVal)?$ifVal:strtotime($ifVal);
- if($ifCond=='time_eq'){
-
- $result=$fieldTime==$valTime?true:false;
- }elseif($ifCond=='time_egt'){
-
- $result=$fieldTime>=$valTime?true:false;
- }elseif($ifCond=='time_elt'){
-
- $result=$fieldTime<=$valTime?true:false;
- }
- break;
- }
- if('or'==$iflv){
- if(!empty($resultAnd)){
-
- $resultOr[]=$resultAnd;
- }
- $resultAnd=array();
- $resultOr[]=$result;
- }elseif('and'==$iflv){
-
- $resultAnd[]=$result;
- }
- }
- if(!empty($resultAnd)){
-
- $resultOr[]=$resultAnd;
- }
- if(is_array($resultOr)&&!empty($resultOr)){
- $isTrue=false;
- foreach ($resultOr as $results){
- if(is_array($results)){
-
- $andResult=true;
- foreach ($results as $result){
- if(!$result){
-
- $andResult=false;
- break;
- }
- }
- $results=$andResult;
- }
- if($results){
-
- $isTrue=true;
- break;
- }
- }
-
- $exclude='';
-
- switch ($params['if_type']){
- case '1':$exclude=$isTrue?'':'if:1';break;
- case '2':$exclude=$isTrue?'if:2':'';break;
- case '3':$exclude=!$isTrue?'':'if:3';break;
- case '4':$exclude=!$isTrue?'if:4':'';break;
- }
-
- if($exclude){
-
- if(!isset($this->exclude_cont_urls[$contUrlMd5])){
- $this->exclude_cont_urls[$contUrlMd5]=array();
- }
-
- if(empty($this->first_loop_field)){
-
- $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]=$exclude;
- }else{
-
- if(!isset($this->exclude_cont_urls[$contUrlMd5][$curUrlMd5])){
- $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]=array();
- }
- $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5][$loopIndex]=$exclude;
- }
- }
- }
- }
- return $fieldVal;
- }
- /*数据处理*/
- public function process_field($fieldVal,$process,$curUrlMd5,$loopIndex,$contUrlMd5){
- if(empty($process)){
- return $fieldVal;
- }
- static $funcs=array('filter','if');
- foreach ($process as $params){
-
- if(empty($this->first_loop_field)){
-
- if(isset($this->exclude_cont_urls[$contUrlMd5][$curUrlMd5])){
- return $fieldVal;
- }
- }else{
-
- if(isset($this->exclude_cont_urls[$contUrlMd5][$curUrlMd5][$loopIndex])){
- return $fieldVal;
- }
- }
- $funcName='process_f_'.$params['module'];
- if(method_exists($this, $funcName)){
- if(in_array($params['module'],$funcs)){
- $fieldVal=$this->$funcName($fieldVal,$params,$curUrlMd5,$loopIndex,$contUrlMd5);
- }else{
- $fieldVal=$this->$funcName($fieldVal,$params);
- }
- }
- }
- return $fieldVal;
- }
-
-
- /**
- * 拼接默认设置
- * @param unknown $reg 规则
- * @param unknown $merge 拼接字符串
- */
- public function set_merge_default($reg,$merge){
- if(empty($merge)){
- $merge='';
- if(!empty($reg)){
-
- if(preg_match_all('/\\d*)\>/i', $reg,$match_signs)){
- foreach ($match_signs['num'] as $snum){
- $merge.=cp_sign('match',$snum);
- }
- }
- }
- }
- return $merge;
- }
- /**
- * 转换起始网址
- * @param string $url
- * @return multitype:mixed |unknown
- */
- public function convert_source_url($url){
- $urls=array();
- if(preg_match('/\{param\:(?P[a-z]+)\,(?P.*?)\}/i', $url,$match)){
-
- $fmtUrl=preg_replace('/\{param\:.*?\}/i', '__set:param__', $url);
- $type=strtolower($match['type']);
- $val=explode("\t", $match['val']);
- if($type=='num'){
-
- $num_start = intval($val[0]);
- $num_end = intval($val[1]);
- $num_end = max ($num_start,$num_end);
- $num_inc = max ( 1, intval($val[2]));
- $num_desc =$val[3]?1:0;
-
- if($num_desc){
-
- for($i=$num_end;$i>=$num_start;$i--){
- $urls[]=str_replace('__set:param__', $num_start+($i-$num_start)*$num_inc, $fmtUrl);
- }
- }else{
- for($i=$num_start;$i<=$num_end;$i++){
- $urls[]=str_replace('__set:param__', $num_start+($i-$num_start)*$num_inc, $fmtUrl);
- }
- }
- }elseif($type=='letter'){
-
- $letter_start=ord($val[0]);
- $letter_end=ord($val[1]);
- $letter_end=max($letter_start,$letter_end);
- $letter_desc=$val[2]?1:0;
-
- if($letter_desc){
-
- for($i=$letter_end;$i>=$letter_start;$i--) {
- $urls[]=str_replace('__set:param__', chr($i), $fmtUrl);
- }
- }else{
- for($i=$letter_start;$i<=$letter_end;$i++) {
- $urls[]=str_replace('__set:param__', chr($i), $fmtUrl);
- }
- }
- }elseif($type=='custom'){
-
- foreach ($val as $v){
- $urls[]=str_replace('__set:param__', $v, $fmtUrl);
- }
- }
- return $urls;
- }if(preg_match('/\{json\:([^\}]*)\}/i',$url,$match)){
-
- $url=preg_replace('/\{json\:([^\}]*)\}/i','',$url);
- $jsonRule=trim($match[1]);
- if(is_null($jsonRule)||$jsonRule==''){
- $jsonRule='*';
- }
- $jsonData=$this->get_html($url);
- if(!empty($jsonData)){
-
- $urls=$this->rule_module_json_data(array('json'=>$jsonRule,'json_arr'=>'_original_'),$jsonData);
- if(empty($urls)){
- $urls=array();
- }
- if(!is_array($urls)){
- $urls=array($urls);
- }
-
- foreach ($urls as $k=>$v){
- if(!is_string($v)||!preg_match('/^\w+\:\/\//i', $v)){
-
- unset($urls[$k]);
- }
- }
- if(!empty($urls)&&is_array($urls)){
- $urls=array_unique($urls);
- $urls=array_values($urls);
- }
- return $urls;
- }
- }elseif(preg_match('/[\r\n]/', $url)){
-
- if(preg_match_all('/^\w+\:\/\/[^\r\n]+/im',$url,$urls)){
-
- $urls=array_unique($urls[0]);
- $urls=array_values($urls);
- }
- return $urls;
- }else{
-
- return $url;
- }
- }
- /*排除内容网址的提示信息*/
- public function exclude_url_msg($val){
- $val=explode(':', $val);
- $type='';
- if(is_array($val)){
- $type=$val[0];
- $val=$val[1];
- }else{
- $type=$val;
- $val='';
- }
- $msg='排除网址';
- if($type=='filter'){
-
- if(empty($val)){
- $msg='关键词过滤';
- }else{
- $msg='关键词过滤:'.$val;
- }
- }elseif($type=='if'){
- $msg='条件';
-
- switch ($val){
- case '1':$msg.='假';break;
- case '2':$msg.='真';break;
- case '3':$msg.='假';break;
- case '4':$msg.='真';break;
- }
- if(lang('?p_m_if_'.$val)){
- $msg.=':'.lang('p_m_if_'.$val);
- }
- }
- return $msg;
- }
-
- /*转换(*)通配符*/
- public function convert_sign_wildcard($str){
- return str_replace(lang('sign_wildcard'), '[\s\S]*?', $str);
- }
- /*转换[参数]*/
- public function convert_sign_match($str){
- $str=preg_replace('/\(\?<(content|match)/i', '(?Psign_addslashes(cp_sign('match','(?P\d*)'));
- $str=preg_replace_callback('/(\={0,1})(\s*)([\'\"]{0,1})'.$sign_match.'\3/', function($matches){
- $ruleStr=$matches[1].$matches[2].$matches[3].'(?P';
- if(!empty($matches[1])&&!empty($matches[3])){
-
- $ruleStr.='[^\<\>]*?)';
- }else{
- $ruleStr.='[\s\S]*?)';
- }
- $ruleStr.=$matches[3];
- return $ruleStr;
- }, $str);
- return $str;
- }
- public function sign_addslashes($str){
- $str=str_replace(array('[',']'), array('\[','\]'), $str);
- return $str;
- }
- /*过滤html标签*/
- public function filter_html_tags($content,$tags){
- $tags=$this->clear_tags($tags);
- $arr1=$arr2=array();
- foreach ($tags as $tag){
- $tag=strtolower($tag);
- if($tag=='script'||$tag=='style'||$tag=='object'){
- $arr1[$tag]=$tag;
- }else{
- $arr2[$tag]=$tag;
- }
- }
-
- if($arr1){
- $content=preg_replace('/<('.implode('|', $arr1).')[^<>]*>[\s\S]*?<\/\1>/i', '', $content);
- }
-
- if($arr2){
- $content=preg_replace('/<[\/]*('.implode('|', $arr2).')[^<>]*>/i', '', $content);
- }
- return $content;
- }
- /*过滤标签*/
- public function clear_tags($tags){
- if(!is_array($tags)){
- $tags = preg_replace('/[\s\,\x{ff0c}]+/u', ',', $tags);
- $tags=explode(',', $tags);
- }
- if(!empty($tags)&&is_array($tags)){
-
- $tags=array_filter($tags);
- $tags=array_unique($tags);
- $tags=array_values($tags);
- }else{
- $tags=array();
- }
- return $tags;
- }
- /*获取源码*/
- public function get_html($url,$open_cache=false,$is_post=false){
- if($open_cache&&!empty($this->html_cache_list[$url])){
-
- return $this->html_cache_list[$url];
- }
- $pageRenderTool=null;
- if($this->config['page_render']){
- $pageRenderTool=$GLOBALS['config']['page_render']['tool'];
- if(empty($pageRenderTool)){
-
- $this->error('页面渲染未设置,请检查渲染设置','Setting/page_render');
- return null;
- }
- }
-
- $html=null;
- $headers=array();
- $options=array();
- if($this->config['request_headers']['open']){
-
- if(!empty($this->config['request_headers']['useragent'])){
-
- $options['useragent']=$this->config['request_headers']['useragent'];
- }
- if(!empty($this->config['request_headers']['cookie'])){
- $headers['cookie']=$this->config['request_headers']['cookie'];
- }
- if(!empty($this->config['request_headers']['referer'])){
- $headers['referer']=$this->config['request_headers']['referer'];
- }
-
- if(!empty($this->config['request_headers']['custom_names'])){
- foreach ($this->config['request_headers']['custom_names'] as $k=>$v){
- if(!empty($v)){
- $headers[$v]=$this->config['request_headers']['custom_vals'][$k];
- }
- }
- }
- }
- $mproxy=model('Proxyip');
- $proxy_ip=null;
- if(!empty($GLOBALS['config']['proxy']['open'])){
-
- $proxy_ip=$mproxy->get_usable_ip();
- $proxyIp=$mproxy->to_proxy_ip($proxy_ip);
-
- if(!empty($proxyIp)){
-
- $options['proxy']=$proxyIp;
- }
- }
- $urlPost=null;
- if($is_post){
-
- $urlPost=strpos($url, '?');
- if($urlPost!==false){
- $urlPost=substr($url, $urlPost+1);
- $url=preg_replace('/\?.*$/', '', $url);
- }else{
- $urlPost='';
- }
- }
-
- if($pageRenderTool){
-
- if(!empty($options['useragent'])){
-
- $headers['user-agent']=$options['useragent'];
- unset($options['useragent']);
- }
- if(!empty($options['proxy'])){
-
- $options['proxy']=$proxy_ip;
- }
-
- if($pageRenderTool=='chrome'){
- $chromeConfig=$GLOBALS['config']['page_render']['chrome'];
- try {
- $chromeSocket=new \util\ChromeSocket($chromeConfig['host'],$chromeConfig['port'],$GLOBALS['config']['page_render']['timeout'],$chromeConfig['filename']);
- $chromeSocket->newTab();
- $chromeSocket->websocket(null);
- if($is_post){
-
- $html=$chromeSocket->getRenderHtml($url,$headers,$options,$this->config['charset'],$urlPost);
- }else{
- $html=$chromeSocket->getRenderHtml($url,$headers,$options);
- }
- }catch (\Exception $ex){
- $this->error('页面渲染失败,请检查渲染设置','Setting/page_render');
- return null;
- }
- }else{
- $this->error('渲染工具不可用,请检查渲染设置','Setting/page_render');
- return null;
- }
- }else{
- if($is_post){
- $html=get_html($url,$headers,$options,$this->config['charset'],$urlPost);
- }else{
- $html=get_html($url,$headers,$options,$this->config['charset']);
- }
- }
-
- if($html==null){
-
- if(!empty($proxy_ip)){
- $mproxy->set_ip_failed($proxy_ip);
- }
- return null;
- }
-
- if($this->config['url_complete']){
-
- $base_url=$this->match_base_url($url, $html);
- $domain_url=$this->match_domain_url($url, $html);
- $html=preg_replace_callback('/(?<=\bhref\=[\'\"])([^\'\"]*)(?=[\'\"])/i',function($matche) use ($base_url,$domain_url){
-
- return \skycaiji\admin\event\Cpattern::create_complete_url($matche[1], $base_url, $domain_url);
- },$html);
- $html=preg_replace_callback('/(?<=\bsrc\=[\'\"])([^\'\"]*)(?=[\'\"])/i',function($matche) use ($base_url,$domain_url){
- return \skycaiji\admin\event\Cpattern::create_complete_url($matche[1], $base_url, $domain_url);
- },$html);
- }
- if($open_cache){
- $this->html_cache_list[$url]=$html;
- }
- return $html;
- }
-}
+used_cont_urls)){
+
+ $usedContUrls=array_keys($this->used_cont_urls);
+ if(!empty($usedContUrls)&&is_array($usedContUrls)){
+ $total=count($usedContUrls);
+ $limit=800;
+ $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')->db()->where('cname','in',$list)->delete();
+ }
+ }
+ }
+ }
+ }
+
+ /*规则匹配区域*/
+ public function rule_match_area($config,$html){
+ if(!empty($config['reg_area'])){
+ if(empty($config['reg_area_module'])){
+
+ if(preg_match('/'.$config['reg_area'].'/i',$html,$area_cont)){
+ if(isset($area_cont['match'])){
+ $html=$area_cont['match'];
+ }else{
+ $html=$area_cont[0];
+ }
+ }else{
+ $html='';
+ }
+ }elseif('json'==$config['reg_area_module']){
+ $html=$this->rule_module_json_data(array('json'=>$config['reg_area'],'json_arr'=>'jsonencode'),$html);
+ }elseif('xpath'==$config['reg_area_module']){
+ $html=$this->rule_module_xpath_data(array('xpath'=>$config['reg_area'],'xpath_attr'=>'outerHtml'),$html);
+ }else{
+ $html='';
+ }
+ }
+ return $html;
+ }
+ /**
+ * 规则匹配网址
+ * @param array $config 配置参数
+ * @param string $html 源码
+ * @param bool $whole 完全匹配模式
+ *
+ */
+ public function rule_match_urls($config,$html,$whole=false){
+ $cont_urls=array();
+ if(!empty($config['reg_url'])&&!empty($config['url_merge'])){
+
+ $sign_match=$this->sign_addslashes(cp_sign('match','(?P\d*)'));
+ if(preg_match_all('/'.$sign_match.'/i', $config['url_merge'],$match_signs)){
+
+ $url_merge=true;
+ if(empty($config['reg_url_module'])){
+
+ if(preg_match('/\(\?P/i', $config['reg_url'])){
+
+ if(preg_match_all('/'.$config['reg_url'].'/i',$html,$cont_urls,PREG_SET_ORDER)){
+ if($config['url_merge']==cp_sign('match')){
+
+ $url_merge=false;
+ foreach ($cont_urls as $k=>$v){
+ $cont_urls[$k]=$v['match'];
+ }
+ }
+ }
+ }else{
+
+ if($whole){
+
+ if(preg_match_all('/'.$config['reg_url'].'/i',$html,$cont_urls)){
+ $cont_urls=$cont_urls[0];
+
+ if($config['url_merge']==cp_sign('match')){
+
+ $url_merge=false;
+ }else{
+
+ foreach ($cont_urls as $k=>$v){
+ $cont_urls[$k]=array(
+ 'match'=>$v
+ );
+ }
+ }
+ }
+ }
+ }
+ }elseif(in_array($config['reg_url_module'],array('xpath','json'))){
+
+ if('xpath'==$config['reg_url_module']){
+
+ $cont_urls=$this->rule_module_xpath_data ( array (
+ 'xpath' => $config['reg_url'],
+ 'xpath_attr' => 'href',
+ 'xpath_multi'=>true,
+ 'xpath_multi_type'=>'loop'
+ ),$html);
+ $cont_urls=is_array($cont_urls)?$cont_urls:array();
+ }elseif('json'==$config['reg_url_module']){
+
+ $cont_urls=$this->rule_module_json_data(array('json'=>$config['reg_url'],'json_arr'=>'_original_'),$html);
+ if(empty($cont_urls)){
+ $cont_urls=array();
+ }elseif(!is_array($cont_urls)){
+ $cont_urls=array($cont_urls);
+ }
+ }
+
+ if($config['url_merge']==cp_sign('match')){
+
+ $url_merge=false;
+ }else{
+
+ foreach ($cont_urls as $k=>$v){
+ $cont_urls[$k]=array(
+ 'match'=>$v
+ );
+ }
+ }
+ }
+
+ if($url_merge){
+
+ foreach ($cont_urls as $k=>$v){
+ $re_match=array();
+ foreach($match_signs['num'] as $ms_k=>$ms_v){
+
+ $re_match[$ms_k]=$v['match'.$ms_v];
+ }
+
+ $cont_urls[$k]=str_replace($match_signs[0], $re_match, $config['url_merge']);
+ }
+ }
+ }
+ }
+ $cont_urls=is_array($cont_urls)?array_unique($cont_urls):array();
+ $cont_urls=array_values($cont_urls);
+ return $cont_urls;
+ }
+
+
+ public function match_rule($html,$rule,$merge,$multi=false,$multi_str=''){
+ $val='';
+ $sign_match=$this->sign_addslashes(cp_sign('match','(?P\d*)'));
+ if(!empty($rule)&&preg_match_all('/'.$sign_match.'/i',$merge,$match_signs)){
+
+ $multiStr='';
+ if(!empty($multi)){
+
+ preg_match_all('/'.$rule.'/i',$html,$match_conts,PREG_SET_ORDER);
+ $multiStr=str_replace(array('\r','\n'), array("\r","\n"), $multi_str);
+ }else{
+ if(preg_match('/'.$rule.'/i', $html,$match_cont)){
+ $match_conts=array($match_cont);
+ }
+ }
+ $curI=0;
+ foreach ($match_conts as $match_cont){
+ $curI++;
+
+ $re_match=array();
+ foreach($match_signs['num'] as $ms_k=>$ms_v){
+ $re_match[$ms_k]=$match_cont['match'.$ms_v];
+ }
+ $val.=($curI<=1?'':$multiStr).str_replace($match_signs[0], $re_match, $merge);
+ }
+ }
+ return $val;
+ }
+
+ /**
+ * 规则匹配,方法可调用,$field_params传入规则参数
+ * @param array $field_params
+ * @param string $html
+ * @return string
+ */
+ public function field_module_rule($field_params,&$html){
+
+ $val='';
+ $sign_match=$this->sign_addslashes(cp_sign('match','(?P\d*)'));
+ if(!empty($field_params['reg_rule'])&&preg_match_all('/'.$sign_match.'/i', $field_params['rule_merge'],$match_signs)){
+
+ $multiStr='';
+ $is_loop=false;
+ if(!empty($field_params['rule_multi'])){
+
+ preg_match_all('/'.$field_params['reg_rule'].'/i',$html,$match_conts,PREG_SET_ORDER);
+ $is_loop='loop'==$field_params['rule_multi_type']?true:false;
+ if($is_loop){
+ if(empty($this->first_loop_field)){
+
+ $this->first_loop_field=$field_params['name'];
+ }
+ $val=array();
+ }else{
+ $multiStr=str_replace(array('\r','\n'), array("\r","\n"), $field_params['rule_multi_str']);
+ }
+ }else{
+ if(preg_match('/'.$field_params['reg_rule'].'/i', $html,$match_cont)){
+ $match_conts=array($match_cont);
+ }
+ }
+
+ $curI=0;
+ if(is_array($match_conts)){
+ foreach ($match_conts as $match_cont){
+ $curI++;
+
+ $re_match=array();
+ foreach($match_signs['num'] as $ms_k=>$ms_v){
+ $re_match[$ms_k]=$match_cont['match'.$ms_v];
+ }
+ $contVal=str_replace($match_signs[0], $re_match, $field_params['rule_merge']);
+ if($is_loop){
+
+ $val[]=$contVal;
+ }else{
+
+ $val.=($curI<=1?'':$multiStr).$contVal;
+ }
+ }
+ }
+ }
+ return $val;
+ }
+ /**
+ * xpath规则,方法可调用,$field_params传入规则参数
+ * @param array $field_params
+ * @param string $html
+ * @return string
+ */
+ public function field_module_xpath($field_params,$html){
+ if(!empty($field_params['xpath_multi'])){
+
+ if('loop'==$field_params['xpath_multi_type']){
+
+ if(empty($this->first_loop_field)){
+
+ $this->first_loop_field=$field_params['name'];
+ }
+ }
+ }
+ return $this->rule_module_xpath_data($field_params,$html);
+ }
+ public function rule_module_xpath_data($field_params,$html){
+ $vals='';
+ if(!empty($field_params['xpath'])){
+ $dom=new \DOMDocument;
+ $libxml_previous_state = libxml_use_internal_errors(true);
+ @$dom->loadHTML(''.$html);
+
+ $dom->normalize();
+
+ $xPath = new \DOMXPath($dom);
+
+ $xpath_attr=strtolower($field_params['xpath_attr']);
+ $xpath_attr='custom'==$xpath_attr?strtolower($field_params['xpath_attr_custom']):$xpath_attr;
+
+ $normal_attr=true;
+ if(in_array($xpath_attr,array('innerhtml','outerhtml','text'))){
+
+ $normal_attr=false;
+ }
+ $xpath_q=trim($field_params['xpath']);
+ if(!empty($xpath_attr)){
+
+ if(preg_match('/\/\@[\w\-]+$/', $xpath_q)){
+
+ $xpath_q=preg_replace('/\@[\w\-]+$/', '', $xpath_q);
+ }
+ if($normal_attr){
+
+ $xpath_q=$xpath_q.(preg_match('/\/$/', $xpath_q)?'':'/').'@'.$xpath_attr;
+ }
+ }else{
+
+ if(!preg_match('/\/\@[\w\-]+$/', $xpath_q)){
+
+ $xpath_attr='innerhtml';
+ $normal_attr=false;
+ }
+ }
+
+ $nodes = $xPath->query($xpath_q);
+
+ $multiStr='';
+ $is_loop=false;
+ if(!empty($field_params['xpath_multi'])){
+
+ $is_loop='loop'==$field_params['xpath_multi_type']?true:false;
+ if($is_loop){
+
+
+
+
+ $vals=array();
+ }else{
+
+ $multiStr=str_replace(array('\r','\n'), array("\r","\n"), $field_params['xpath_multi_str']);
+ }
+ }
+
+ $curI=0;
+ foreach ($nodes as $node){
+ $curI++;
+ $val=($curI<=1?'':$multiStr);
+ if($normal_attr){
+
+ $val.=$node->nodeValue;
+ }else{
+
+ switch ($xpath_attr){
+ case 'innerhtml':
+ $nchilds = $node->childNodes;
+ foreach ($nchilds as $nchild){
+ $val .= $nchild->ownerDocument->saveHTML($nchild);
+ }
+ break;
+ case 'outerhtml':$val.=$node->ownerDocument->saveHTML($node);break;
+ case 'text':
+
+
+ $nchilds = $node->childNodes;
+ foreach ($nchilds as $nchild){
+ $val .= $nchild->ownerDocument->saveHTML($nchild);
+ }
+ $val=$this->filter_html_tags($val, array('style','script','object'));
+ $val=strip_tags($val);
+ break;
+ }
+ }
+
+ if($is_loop){
+
+ $vals[]=$val;
+ }else{
+ $vals.=$val;
+ }
+
+ if(empty($field_params['xpath_multi'])){
+
+ break;
+ }
+ }
+
+ libxml_clear_errors();
+
+ }
+ return $vals;
+ }
+
+ /*自动获取*/
+ public function field_module_auto($field_params,&$html,$cur_url){
+ switch (strtolower($field_params['auto'])){
+ case 'title':$val=$this->get_title($html);break;
+ case 'content':$val=$this->get_content($html);break;
+ case 'keywords':$val=$this->get_keywords($html);break;
+ case 'description':$val=$this->get_description($html);break;
+ case 'url':$val=$cur_url;break;
+ }
+ return $val;
+ }
+ public function field_module_words($field_params){
+
+ return $field_params['words'];
+ }
+ public function field_module_num($field_params){
+
+ $start=intval($field_params['num_start']);
+ $end=intval($field_params['num_end']);
+ return rand($start, $end);
+ }
+ public function field_module_time($field_params){
+ $val='';
+ $start=empty($field_params['time_start'])?NOW_TIME:strtotime($field_params['time_start']);
+ $end=empty($field_params['time_end'])?NOW_TIME:strtotime($field_params['time_end']);
+ $time=rand($start, $end);
+ if(empty($field_params['time_stamp'])){
+
+ $fmt=empty($field_params['time_format'])?'Y-m-d H:i':
+ str_replace(array('[年]','[月]','[日]','[时]','[分]','[秒]'), array('Y','m','d','H','i','s'), $field_params['time_format']);
+ $val=date($fmt,$time);
+ }else{
+ $val=$time;
+ }
+ return $val;
+ }
+ public function field_module_list($field_params){
+ static $list=array();
+ $key=md5($field_params['list']);
+ if(!isset($list[$key])){
+
+ if(preg_match_all('/[^\r\n]+/', $field_params['list'],$str_list)){
+ $str_list=$str_list[0];
+ }else{
+ $str_list=array();
+ }
+ $list[$key]=$str_list;
+ }
+ $str_list=$list[$key];
+ $val='';
+ if(!empty($str_list)){
+ $randi=array_rand($str_list,1);
+ $val=$str_list[$randi];
+ }
+ return $val;
+ }
+ public function field_module_merge($field_params,$val_list){
+ $val='';
+
+ if(preg_match_all('/\[\x{5b57}\x{6bb5}\:(.+?)\]/u', $field_params['merge'],$match_fields)){
+ $val=$field_params['merge'];
+
+ for($i=0;$i[\s\S]+)\}\s*\)\s*[\;]{0,1}/i';
+ public function field_module_json($field_params,$html,$cur_url=''){
+ static $jsonList=array();
+ $jsonKey=!empty($cur_url)?md5($cur_url):md5($html);
+ if(!isset($jsonList[$jsonKey])){
+ $jsonList[$jsonKey]=json_decode($html,true);
+ if(empty($jsonList[$jsonKey])&&preg_match(self::$jsonpRegExp, $html,$json)){
+
+ $json=trim($json['json']).'}';
+ $jsonList[$jsonKey]=json_decode($json,true);
+ }
+ }
+ $jsonArrType=$field_params['json_arr'];
+ if($field_params['json_loop']){
+
+ $field_params['json_arr']='_original_';
+ }
+ $val=$this->rule_module_json_data($field_params,$jsonList[$jsonKey]);
+ if($field_params['json_loop']){
+
+ if(is_array($val)){
+ $field_params['json_arr']=$jsonArrType;
+ foreach ($val as $k=>$v){
+ $val[$k]=$this->rule_module_json_data_convert($v,$field_params);
+ }
+
+ if(empty($this->first_loop_field)){
+
+ $this->first_loop_field=$field_params['name'];
+ }
+ }
+ }
+ return $val;
+ }
+ public function rule_module_json_data($field_params,$jsonArrOrStr){
+ $jsonArr=array();
+ if(is_array($jsonArrOrStr)){
+ $jsonArr=&$jsonArrOrStr;
+ }else{
+
+ $jsonArr=json_decode($jsonArrOrStr,true);
+ if(empty($jsonArr)&&preg_match(self::$jsonpRegExp,$jsonArrOrStr,$jsonArrOrStr)){
+
+ $jsonArr=trim($jsonArrOrStr['json']).'}';
+ $jsonArr=json_decode($jsonArr,true);
+ }
+ unset($jsonArrOrStr);
+ }
+ $val='';
+ if(!empty($jsonArr)){
+ if(!empty($field_params['json'])){
+
+ $jsonFmt=str_replace(array('"',"'",'[',' '), '', $field_params['json']);
+ $jsonFmt=str_replace(']','.',$jsonFmt);
+ $jsonFmt=trim($jsonFmt,'.');
+ $jsonFmt=explode('.', $jsonFmt);
+ $jsonFmt=array_values($jsonFmt);
+ if(!empty($jsonFmt)){
+
+ $val=$jsonArr;
+ $prevKey='';
+ foreach ($jsonFmt as $i=>$key){
+ if($prevKey=='*'){
+
+ $new_field_params=$field_params;
+ $new_field_params['json']=array_slice($jsonFmt, $i);
+ $new_field_params['json']=implode('.', $new_field_params['json']);
+
+ foreach ($val as $vk=>$vv){
+
+ $val[$vk]=$this->rule_module_json_data($new_field_params,$vv);
+ }
+ break;
+ }else{
+ if($key!='*'){
+
+ $val=$val[$key];
+ }
+ }
+ $prevKey=$key;
+ }
+ }
+ }
+ }
+
+ return $this->rule_module_json_data_convert($val, $field_params);
+ }
+ public function rule_module_json_data_convert($val,$field_params){
+ if(is_array($val)){
+
+ $json_arr=strtolower($field_params['json_arr']);
+ if(empty($json_arr)){
+ $json_arr='implode';
+ }
+ switch ($json_arr){
+ case 'implode':$arrImplode=str_replace(array('\r','\n'), array("\r","\n"), $field_params['json_arr_implode']);$val=array_implode($arrImplode,$val);break;
+ case 'jsonencode':$val=json_encode($val);break;
+ case 'serialize':$val=serialize($val);break;
+ case '_original_': break;
+ }
+ }
+ return $val;
+ }
+
+ /*字段提取内容*/
+ public function field_module_extract($field_params,$extract_field_val,$base_url,$domain_url){
+ $field_html=$extract_field_val['value'];
+ if(empty($field_html)){
+ return '';
+ }
+ $val='';
+ $extract_module=strtolower($field_params['extract_module']);
+ switch ($extract_module){
+ case 'cover':
+
+ if(!empty($extract_field_val['img'])){
+ $val=reset($extract_field_val['img']);
+ }else{
+ if(preg_match('/]*\bsrc=[\'\"](?P[^\'\"]+?)[\'\"]/i',$field_html,$cover)){
+ $cover=$cover['url'];
+ $cover=$this->create_complete_url($cover, $base_url, $domain_url);
+ $val=$cover;
+ }
+ }
+ break;
+ case 'phone':
+
+ $field_html=$this->filter_html_tags($field_html,'style,script,object');
+ $field_html=strip_tags($field_html);
+ if(preg_match('/\d{11}/', $field_html,$phone)){
+ $val=$phone[0];
+ }
+ break;
+ case 'email':
+ $field_html=$this->filter_html_tags($field_html,'style,script,object');
+ $field_html=strip_tags($field_html);
+ if(preg_match('/[\w\-]+\@[\w\-\.]+/i', $field_html,$email)){
+ $val=$email[0];
+ }
+ break;
+ case 'rule':
+
+ $val=$this->field_module_rule(array('reg_rule'=>$field_params['reg_extract_rule']), $field_html);
+ if(empty($val)){
+
+ if(preg_match('/'.$field_params['reg_extract_rule'].'/i', $field_html,$val)){
+ $val=$val[0];
+ }
+ }
+ break;
+ case 'xpath':
+ $val=$this->field_module_xpath(array('xpath'=>$field_params['extract_xpath'],'xpath_attr'=>$field_params['extract_xpath_attr'],'xpath_attr_custom'=>$field_params['extract_xpath_attr_custom']), $field_html);
+ break;
+ case 'json':
+ $val=$this->field_module_json(array('json'=>$field_params['extract_json'],'json_arr'=>$field_params['extract_json_arr'],'json_arr_implode'=>$field_params['extract_json_arr_implode']), $field_html);
+ break;
+ }
+ return $val;
+ }
+ /*数据处理方法*/
+ public function process_f_html($fieldVal,$params){
+ $htmlAllow=array_filter(explode(',',$params['html_allow']));
+ $htmlFilter=array_filter(explode(',',$params['html_filter']));
+ if(!empty($htmlAllow)){
+
+ $htmlAllowStr='';
+ foreach ($htmlAllow as $v){
+ $htmlAllowStr.='<'.$v.'>';
+ }
+ $fieldVal=strip_tags($fieldVal,$htmlAllowStr);
+ }
+ if(!empty($htmlFilter)){
+
+ if(in_array('all', $htmlFilter)){
+
+ $fieldVal=$this->filter_html_tags($fieldVal, array('style','script','object'));
+ $fieldVal=strip_tags($fieldVal);
+ }else{
+ $fieldVal=$this->filter_html_tags($fieldVal, $htmlFilter);
+ }
+ }
+ return $fieldVal;
+ }
+ public function process_f_replace($fieldVal,$params){
+ return preg_replace('/'.$params['replace_from'].'/i',$params['replace_to'], $fieldVal);
+ }
+ public function process_f_tool($fieldVal,$params){
+
+ if(in_array('format', $params['tool_list'])){
+
+ $fieldVal=$this->filter_html_tags($fieldVal,array('style','script'));
+ $fieldVal=preg_replace('/\b(id|class|style|width|height|align)\s*=\s*([\'\"])[^\<\>\'\"]+?\\2(?=\s|$|\/|>)/i', ' ', $fieldVal);
+ }
+ if(in_array('trim', $params['tool_list'])){
+
+ $fieldVal=trim($fieldVal);
+ }
+ if(in_array('is_img', $params['tool_list'])){
+
+ if(!empty($GLOBALS['config']['caiji']['download_img'])){
+
+ $fieldVal=preg_replace('/(\bhttp[s]{0,1}\:\/\/[^\s]+)/i','{[img]}'."$1".'{[/img]}',$fieldVal);
+ }
+ }
+ return $fieldVal;
+ }
+ public function process_f_translate($fieldVal,$params){
+
+ if(!empty($GLOBALS['config']['translate'])&&!empty($GLOBALS['config']['translate']['open'])){
+
+ $fieldVal=\util\Translator::translate($fieldVal, $params['translate_from'], $params['translate_to']);
+ }
+ return $fieldVal;
+ }
+ public function process_f_batch($fieldVal,$params){
+
+ static $batch_list=array();
+ if(!empty($params['batch_list'])){
+ $listMd5=md5($params['batch_list']);
+ if(!isset($batch_list[$listMd5])){
+
+ if(preg_match_all('/([^\r\n]+?)\=([^\r\n]+)/', $params['batch_list'],$mlist)){
+ $batch_re=$mlist[1];
+ $batch_to=$mlist[2];
+ $batch_list[$listMd5]=array($batch_re,$batch_to);
+ }
+ }else{
+ $batch_re=$batch_list[$listMd5][0];
+ $batch_to=$batch_list[$listMd5][1];
+ }
+ $batch_re=is_array($batch_re)?$batch_re:null;
+ $batch_to=is_array($batch_to)?$batch_to:null;
+ if(!empty($batch_re)&&count($batch_re)==count($batch_to)){
+
+ $fieldVal=str_replace($batch_re, $batch_to, $fieldVal);
+ }
+ }
+ return $fieldVal;
+ }
+ public function process_f_substr($fieldVal,$params){
+ $params['substr_len']=intval($params['substr_len']);
+ if($params['substr_len']>0){
+ if(mb_strlen($fieldVal,'utf-8')>$params['substr_len']){
+
+ $fieldVal=mb_substr($fieldVal,0,$params['substr_len'],'utf-8').$params['substr_end'];
+ }
+ }
+ return $fieldVal;
+ }
+ public function process_f_func($fieldVal,$params){
+
+ if(!empty($params['func_name'])){
+ if(!function_exists($params['func_name'])){
+
+ $this->error('数据处理》无效的函数:'.$params['func_name']);
+ }else{
+
+ if(array_key_exists($params['func_name'], config('allow_process_func'))||array_key_exists($params['func_name'], config('EXTEND_PROCESS_FUNC'))){
+
+ static $func_param_list=array();
+ $funcParam=null;
+ if(empty($params['func_param'])){
+
+ $funcParam=array($fieldVal);
+ }else{
+ $fparamMd5=md5($params['func_param']);
+ if(!isset($func_param_list[$fparamMd5])){
+ if(preg_match_all('/[^\r\n]+/', $params['func_param'],$mfuncParam)){
+ $func_param_list[$fparamMd5]=$mfuncParam[0];
+ }
+ }
+ $funcParam=$func_param_list[$fparamMd5];
+ foreach ($funcParam as $k=>$v){
+ $funcParam[$k]=str_replace('###', $fieldVal, $v);
+ }
+ }
+ if(!empty($funcParam)&&is_array($funcParam)){
+ try {
+ $fieldVal=call_user_func_array($params['func_name'], $funcParam);
+ }catch (\Exception $ex){
+
+ }
+ }
+ }else{
+ $this->error('数据处理》未配置函数:'.$params['func_name']);
+ }
+ }
+ }
+ return $fieldVal;
+ }
+ public function process_f_filter($fieldVal,$params,$curUrlMd5,$loopIndex,$contUrlMd5){
+ static $key_list=array();
+ if(!empty($params['filter_list'])){
+ $listMd5=md5($params['filter_list']);
+ if(!isset($key_list[$listMd5])){
+ $filterList=explode("\r\n", $params['filter_list']);
+ $filterList=array_filter($filterList);
+ $key_list[$listMd5]=$filterList;
+ }else{
+ $filterList=$key_list[$listMd5];
+ }
+ $filterList=is_array($filterList)?$filterList:array();
+
+
+ if(!empty($params['filter_pass'])){
+ if($params['filter_pass']=='1'){
+
+ foreach ($filterList as $filterStr){
+ if(stripos($fieldVal,$filterStr)!==false){
+
+ $fieldVal='';
+ break;
+ }
+ }
+ }elseif($params['filter_pass']=='2'){
+
+ foreach ($filterList as $filterStr){
+ if(stripos($fieldVal,$filterStr)!==false){
+
+ if(!isset($this->exclude_cont_urls[$contUrlMd5])){
+ $this->exclude_cont_urls[$contUrlMd5]=array();
+ }
+
+ if(empty($this->first_loop_field)){
+
+ $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]='filter:'.$filterStr;
+ }else{
+
+ if(!isset($this->exclude_cont_urls[$contUrlMd5][$curUrlMd5])){
+ $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]=array();
+ }
+ $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5][$loopIndex]='filter:'.$filterStr;
+ }
+ break;
+ }
+ }
+ }elseif($params['filter_pass']=='3'){
+
+ $hasKey=false;
+ foreach ($filterList as $filterStr){
+ if(stripos($fieldVal,$filterStr)!==false){
+
+ $hasKey=true;
+ break;
+ }
+ }
+ if(!$hasKey){
+ $fieldVal='';
+ }
+ }elseif($params['filter_pass']=='4'){
+
+ $hasKey=false;
+ foreach ($filterList as $filterStr){
+ if(stripos($fieldVal,$filterStr)!==false){
+
+ $hasKey=true;
+ break;
+ }
+ }
+ if(!$hasKey){
+
+ if(!isset($this->exclude_cont_urls[$contUrlMd5])){
+ $this->exclude_cont_urls[$contUrlMd5]=array();
+ }
+
+ if(empty($this->first_loop_field)){
+
+ $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]='filter:';
+ }else{
+
+ if(!isset($this->exclude_cont_urls[$contUrlMd5][$curUrlMd5])){
+ $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]=array();
+ }
+ $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5][$loopIndex]='filter:';
+ }
+ }
+ }
+ }else{
+
+ $fieldVal=str_ireplace($filterList, $params['filter_replace'], $fieldVal);
+ }
+ }
+ return $fieldVal;
+ }
+ public function process_f_if($fieldVal,$params,$curUrlMd5,$loopIndex,$contUrlMd5){
+ static $func_list=array();
+
+ if(is_array($params['if_logic'])&&!empty($params['if_logic'])){
+
+ $resultOr=array();
+ $resultAnd=array();
+ foreach($params['if_logic'] as $ifk=>$iflv){
+ if(empty($iflv)||empty($params['if_cond'][$ifk])){
+
+ continue;
+ }
+ $ifVal=$params['if_val'][$ifk];
+ $ifCond=$params['if_cond'][$ifk];
+ $result=false;
+ switch($ifCond){
+ case 'regexp':
+ if(preg_match('/'.$ifVal.'/', $fieldVal)){
+ $result=true;
+ }
+ break;
+ case 'func':
+ if(!empty($ifVal)){
+
+ $funcMd5=md5($ifVal);
+ if(!isset($func_list[$funcMd5])){
+ if(preg_match_all('/[^\r\n]+/',$ifVal,$funcParam)){
+
+ $funcParam=$funcParam[0];
+ }else{
+
+ $funcParam=array($ifVal);
+ }
+ $func_list[$funcMd5]=$funcParam;
+ }else{
+ $funcParam=$func_list[$funcMd5];
+ }
+ $funcName=$funcParam[0];
+ $isTurn=false;
+ if(strpos($funcName,'!')===0){
+
+ $funcName=substr($funcName, 1);
+ $isTurn=true;
+ }
+ unset($funcParam[0]);
+ if(empty($funcParam)){
+
+ $funcParam=array($fieldVal);
+ }else{
+ foreach($funcParam as $k=>$v){
+ $funcParam[$k]=str_replace('###', $fieldVal, $v);
+ }
+ }
+
+ if(!function_exists($funcName)){
+
+ $this->error('数据处理》条件判断》无效的函数:'.$funcName);
+ }else{
+ if(array_key_exists($funcName, config('allow_process_if'))||array_key_exists($funcName, config('EXTEND_PROCESS_IF'))){
+
+ try {
+ $result=call_user_func_array($funcName, $funcParam);
+ if($isTurn){
+
+ $result=$result?false:true;
+ }
+ }catch (\Exception $ex){
+
+ $this->error('数据处理》条件判断》函数'.$funcName.'运行错误,'.$ex->getMessage());
+ }
+ }else{
+ $this->error('数据处理》条件判断》未配置函数:'.$funcName);
+ }
+ }
+ }
+ break;
+ case 'has':$result=stripos($fieldVal,$ifVal)!==false?true:false;break;
+ case 'nhas':$result=stripos($fieldVal,$ifVal)===false?true:false;break;
+ case 'eq':$result=$fieldVal==$ifVal?true:false;break;
+ case 'neq':$result=$fieldVal!=$ifVal?true:false;break;
+ case 'heq':$result=$fieldVal===$ifVal?true:false;break;
+ case 'nheq':$result=$fieldVal!==$ifVal?true:false;break;
+ case 'gt':$result=$fieldVal>$ifVal?true:false;break;
+ case 'egt':$result=$fieldVal>=$ifVal?true:false;break;
+ case 'lt':$result=$fieldVal<$ifVal?true:false;break;
+ case 'elt':$result=$fieldVal<=$ifVal?true:false;break;
+ case 'time_eq':
+ case 'time_egt':
+ case 'time_elt':
+ $fieldTime=is_numeric($fieldVal)?$fieldVal:strtotime($fieldVal);
+ $valTime=is_numeric($ifVal)?$ifVal:strtotime($ifVal);
+ if($ifCond=='time_eq'){
+
+ $result=$fieldTime==$valTime?true:false;
+ }elseif($ifCond=='time_egt'){
+
+ $result=$fieldTime>=$valTime?true:false;
+ }elseif($ifCond=='time_elt'){
+
+ $result=$fieldTime<=$valTime?true:false;
+ }
+ break;
+ }
+ if('or'==$iflv){
+ if(!empty($resultAnd)){
+
+ $resultOr[]=$resultAnd;
+ }
+ $resultAnd=array();
+ $resultOr[]=$result;
+ }elseif('and'==$iflv){
+
+ $resultAnd[]=$result;
+ }
+ }
+ if(!empty($resultAnd)){
+
+ $resultOr[]=$resultAnd;
+ }
+ if(is_array($resultOr)&&!empty($resultOr)){
+ $isTrue=false;
+ foreach ($resultOr as $results){
+ if(is_array($results)){
+
+ $andResult=true;
+ foreach ($results as $result){
+ if(!$result){
+
+ $andResult=false;
+ break;
+ }
+ }
+ $results=$andResult;
+ }
+ if($results){
+
+ $isTrue=true;
+ break;
+ }
+ }
+
+ $exclude='';
+
+ switch ($params['if_type']){
+ case '1':$exclude=$isTrue?'':'if:1';break;
+ case '2':$exclude=$isTrue?'if:2':'';break;
+ case '3':$exclude=!$isTrue?'':'if:3';break;
+ case '4':$exclude=!$isTrue?'if:4':'';break;
+ }
+
+ if($exclude){
+
+ if(!isset($this->exclude_cont_urls[$contUrlMd5])){
+ $this->exclude_cont_urls[$contUrlMd5]=array();
+ }
+
+ if(empty($this->first_loop_field)){
+
+ $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]=$exclude;
+ }else{
+
+ if(!isset($this->exclude_cont_urls[$contUrlMd5][$curUrlMd5])){
+ $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5]=array();
+ }
+ $this->exclude_cont_urls[$contUrlMd5][$curUrlMd5][$loopIndex]=$exclude;
+ }
+ }
+ }
+ }
+ return $fieldVal;
+ }
+ /*数据处理*/
+ public function process_field($fieldVal,$process,$curUrlMd5,$loopIndex,$contUrlMd5){
+ if(empty($process)){
+ return $fieldVal;
+ }
+ static $funcs=array('filter','if');
+ foreach ($process as $params){
+
+ if(empty($this->first_loop_field)){
+
+ if(isset($this->exclude_cont_urls[$contUrlMd5][$curUrlMd5])){
+ return $fieldVal;
+ }
+ }else{
+
+ if(isset($this->exclude_cont_urls[$contUrlMd5][$curUrlMd5][$loopIndex])){
+ return $fieldVal;
+ }
+ }
+ $funcName='process_f_'.$params['module'];
+ if(method_exists($this, $funcName)){
+ if(in_array($params['module'],$funcs)){
+ $fieldVal=$this->$funcName($fieldVal,$params,$curUrlMd5,$loopIndex,$contUrlMd5);
+ }else{
+ $fieldVal=$this->$funcName($fieldVal,$params);
+ }
+ }
+ }
+ return $fieldVal;
+ }
+
+
+ /**
+ * 拼接默认设置
+ * @param unknown $reg 规则
+ * @param unknown $merge 拼接字符串
+ */
+ public function set_merge_default($reg,$merge){
+ if(empty($merge)){
+ $merge='';
+ if(!empty($reg)){
+
+ if(preg_match_all('/\\d*)\>/i', $reg,$match_signs)){
+ foreach ($match_signs['num'] as $snum){
+ $merge.=cp_sign('match',$snum);
+ }
+ }
+ }
+ }
+ return $merge;
+ }
+ /**
+ * 转换起始网址
+ * @param string $url
+ * @return multitype:mixed |unknown
+ */
+ public function convert_source_url($url){
+ $urls=array();
+ if(preg_match('/\{param\:(?P[a-z]+)\,(?P.*?)\}/i', $url,$match)){
+
+ $fmtUrl=preg_replace('/\{param\:.*?\}/i', '__set:param__', $url);
+ $type=strtolower($match['type']);
+ $val=explode("\t", $match['val']);
+ if($type=='num'){
+
+ $num_start = intval($val[0]);
+ $num_end = intval($val[1]);
+ $num_end = max ($num_start,$num_end);
+ $num_inc = max ( 1, intval($val[2]));
+ $num_desc =$val[3]?1:0;
+
+ if($num_desc){
+
+ for($i=$num_end;$i>=$num_start;$i--){
+ $urls[]=str_replace('__set:param__', $num_start+($i-$num_start)*$num_inc, $fmtUrl);
+ }
+ }else{
+ for($i=$num_start;$i<=$num_end;$i++){
+ $urls[]=str_replace('__set:param__', $num_start+($i-$num_start)*$num_inc, $fmtUrl);
+ }
+ }
+ }elseif($type=='letter'){
+
+ $letter_start=ord($val[0]);
+ $letter_end=ord($val[1]);
+ $letter_end=max($letter_start,$letter_end);
+ $letter_desc=$val[2]?1:0;
+
+ if($letter_desc){
+
+ for($i=$letter_end;$i>=$letter_start;$i--) {
+ $urls[]=str_replace('__set:param__', chr($i), $fmtUrl);
+ }
+ }else{
+ for($i=$letter_start;$i<=$letter_end;$i++) {
+ $urls[]=str_replace('__set:param__', chr($i), $fmtUrl);
+ }
+ }
+ }elseif($type=='custom'){
+
+ foreach ($val as $v){
+ $urls[]=str_replace('__set:param__', $v, $fmtUrl);
+ }
+ }
+ return $urls;
+ }if(preg_match('/\{json\:([^\}]*)\}/i',$url,$match)){
+
+ $url=preg_replace('/\{json\:([^\}]*)\}/i','',$url);
+ $jsonRule=trim($match[1]);
+ if(is_null($jsonRule)||$jsonRule==''){
+ $jsonRule='*';
+ }
+ $jsonData=$this->get_html($url);
+ if(!empty($jsonData)){
+
+ $urls=$this->rule_module_json_data(array('json'=>$jsonRule,'json_arr'=>'_original_'),$jsonData);
+ if(empty($urls)){
+ $urls=array();
+ }
+ if(!is_array($urls)){
+ $urls=array($urls);
+ }
+
+ foreach ($urls as $k=>$v){
+ if(!is_string($v)||!preg_match('/^\w+\:\/\//i', $v)){
+
+ unset($urls[$k]);
+ }
+ }
+ if(!empty($urls)&&is_array($urls)){
+ $urls=array_unique($urls);
+ $urls=array_values($urls);
+ }
+ return $urls;
+ }
+ }elseif(preg_match('/[\r\n]/', $url)){
+
+ if(preg_match_all('/^\w+\:\/\/[^\r\n]+/im',$url,$urls)){
+
+ $urls=array_unique($urls[0]);
+ $urls=array_values($urls);
+ }
+ return $urls;
+ }else{
+
+ return $url;
+ }
+ }
+ /*排除内容网址的提示信息*/
+ public function exclude_url_msg($val){
+ $val=explode(':', $val);
+ $type='';
+ if(is_array($val)){
+ $type=$val[0];
+ $val=$val[1];
+ }else{
+ $type=$val;
+ $val='';
+ }
+ $msg='排除网址';
+ if($type=='filter'){
+
+ if(empty($val)){
+ $msg='关键词过滤';
+ }else{
+ $msg='关键词过滤:'.$val;
+ }
+ }elseif($type=='if'){
+ $msg='条件';
+
+ switch ($val){
+ case '1':$msg.='假';break;
+ case '2':$msg.='真';break;
+ case '3':$msg.='假';break;
+ case '4':$msg.='真';break;
+ }
+ if(lang('?p_m_if_'.$val)){
+ $msg.=':'.lang('p_m_if_'.$val);
+ }
+ }
+ return $msg;
+ }
+
+ /*转换(*)通配符*/
+ public function convert_sign_wildcard($str){
+ return str_replace(lang('sign_wildcard'), '[\s\S]*?', $str);
+ }
+ /*转换[参数]*/
+ public function convert_sign_match($str){
+ $str=preg_replace('/\(\?<(content|match)/i', '(?Psign_addslashes(cp_sign('match','(?P\d*)'));
+ $str=preg_replace_callback('/(\={0,1})(\s*)([\'\"]{0,1})'.$sign_match.'\3/', function($matches){
+ $ruleStr=$matches[1].$matches[2].$matches[3].'(?P';
+ if(!empty($matches[1])&&!empty($matches[3])){
+
+ $ruleStr.='[^\<\>]*?)';
+ }else{
+ $ruleStr.='[\s\S]*?)';
+ }
+ $ruleStr.=$matches[3];
+ return $ruleStr;
+ }, $str);
+ return $str;
+ }
+ public function sign_addslashes($str){
+ $str=str_replace(array('[',']'), array('\[','\]'), $str);
+ return $str;
+ }
+ /*过滤html标签*/
+ public function filter_html_tags($content,$tags){
+ $tags=$this->clear_tags($tags);
+ $arr1=$arr2=array();
+ foreach ($tags as $tag){
+ $tag=strtolower($tag);
+ if($tag=='script'||$tag=='style'||$tag=='object'){
+ $arr1[$tag]=$tag;
+ }else{
+ $arr2[$tag]=$tag;
+ }
+ }
+
+ if($arr1){
+ $content=preg_replace('/<('.implode('|', $arr1).')[^<>]*>[\s\S]*?<\/\1>/i', '', $content);
+ }
+
+ if($arr2){
+ $content=preg_replace('/<[\/]*('.implode('|', $arr2).')[^<>]*>/i', '', $content);
+ }
+ return $content;
+ }
+ /*过滤标签*/
+ public function clear_tags($tags){
+ if(!is_array($tags)){
+ $tags = preg_replace('/[\s\,\x{ff0c}]+/u', ',', $tags);
+ $tags=explode(',', $tags);
+ }
+ if(!empty($tags)&&is_array($tags)){
+
+ $tags=array_filter($tags);
+ $tags=array_unique($tags);
+ $tags=array_values($tags);
+ }else{
+ $tags=array();
+ }
+ return $tags;
+ }
+ /*获取源码*/
+ public function get_html($url,$open_cache=false,$is_post=false){
+ if($open_cache&&!empty($this->html_cache_list[$url])){
+
+ return $this->html_cache_list[$url];
+ }
+ $pageRenderTool=null;
+ if($this->config['page_render']){
+ $pageRenderTool=$GLOBALS['config']['page_render']['tool'];
+ if(empty($pageRenderTool)){
+
+ $this->error('页面渲染未设置,请检查渲染设置','Setting/page_render');
+ return null;
+ }
+ }
+
+ $html=null;
+ $headers=array();
+ $options=array();
+ if($this->config['request_headers']['open']){
+
+ if(!empty($this->config['request_headers']['useragent'])){
+
+ $options['useragent']=$this->config['request_headers']['useragent'];
+ }
+ if(!empty($this->config['request_headers']['cookie'])){
+ $headers['cookie']=$this->config['request_headers']['cookie'];
+ }
+ if(!empty($this->config['request_headers']['referer'])){
+ $headers['referer']=$this->config['request_headers']['referer'];
+ }
+
+ if(!empty($this->config['request_headers']['custom_names'])){
+ foreach ($this->config['request_headers']['custom_names'] as $k=>$v){
+ if(!empty($v)){
+ $headers[$v]=$this->config['request_headers']['custom_vals'][$k];
+ }
+ }
+ }
+ }
+ $mproxy=model('Proxyip');
+ $proxy_ip=null;
+ if(!empty($GLOBALS['config']['proxy']['open'])){
+
+ $proxy_ip=$mproxy->get_usable_ip();
+ $proxyIp=$mproxy->to_proxy_ip($proxy_ip);
+
+ if(!empty($proxyIp)){
+
+ $options['proxy']=$proxyIp;
+ }
+ }
+ $urlPost=null;
+ if($is_post){
+
+ $urlPost=strpos($url, '?');
+ if($urlPost!==false){
+ $urlPost=substr($url, $urlPost+1);
+ $url=preg_replace('/\?.*$/', '', $url);
+ }else{
+ $urlPost='';
+ }
+ }
+
+ if($pageRenderTool){
+
+ if(!empty($options['useragent'])){
+
+ $headers['user-agent']=$options['useragent'];
+ unset($options['useragent']);
+ }
+ if(!empty($options['proxy'])){
+
+ $options['proxy']=$proxy_ip;
+ }
+
+ if($pageRenderTool=='chrome'){
+ $chromeConfig=$GLOBALS['config']['page_render']['chrome'];
+ try {
+ $chromeSocket=new \util\ChromeSocket($chromeConfig['host'],$chromeConfig['port'],$GLOBALS['config']['page_render']['timeout'],$chromeConfig['filename']);
+ $chromeSocket->newTab();
+ $chromeSocket->websocket(null);
+ if($is_post){
+
+ $html=$chromeSocket->getRenderHtml($url,$headers,$options,$this->config['charset'],$urlPost);
+ }else{
+ $html=$chromeSocket->getRenderHtml($url,$headers,$options);
+ }
+ }catch (\Exception $ex){
+ $this->error('页面渲染失败,请检查渲染设置','Setting/page_render');
+ return null;
+ }
+ }else{
+ $this->error('渲染工具不可用,请检查渲染设置','Setting/page_render');
+ return null;
+ }
+ }else{
+ if($is_post){
+ $html=get_html($url,$headers,$options,$this->config['charset'],$urlPost);
+ }else{
+ $html=get_html($url,$headers,$options,$this->config['charset']);
+ }
+ }
+
+ if($html==null){
+
+ if(!empty($proxy_ip)){
+ $mproxy->set_ip_failed($proxy_ip);
+ }
+ return null;
+ }
+
+ if($this->config['url_complete']){
+
+ $base_url=$this->match_base_url($url, $html);
+ $domain_url=$this->match_domain_url($url, $html);
+ $html=preg_replace_callback('/(?<=\bhref\=[\'\"])([^\'\"]*)(?=[\'\"])/i',function($matche) use ($base_url,$domain_url){
+
+ return \skycaiji\admin\event\Cpattern::create_complete_url($matche[1], $base_url, $domain_url);
+ },$html);
+ $html=preg_replace_callback('/(?<=\bsrc\=[\'\"])([^\'\"]*)(?=[\'\"])/i',function($matche) use ($base_url,$domain_url){
+ return \skycaiji\admin\event\Cpattern::create_complete_url($matche[1], $base_url, $domain_url);
+ },$html);
+ }
+ if($open_cache){
+ $this->html_cache_list[$url]=$html;
+ }
+ return $html;
+ }
+}
?>
\ No newline at end of file
diff --git a/SkycaijiApp/admin/model/App.php b/SkycaijiApp/admin/model/App.php
index f9c7d993..91127f90 100644
--- a/SkycaijiApp/admin/model/App.php
+++ b/SkycaijiApp/admin/model/App.php
@@ -1,43 +1,43 @@
-right_app($app)){
-
- $path=realpath(config('apps_path').'/'.$app);
+
+ $path=realpath(config('apps_path').'/'.$app);
if(!empty($path)&&is_dir($path)){
$appFilename=$this->app_class_file($app);
if(!in_array($app,$passPaths)&&file_exists($appFilename)){
-
+
if($includeClass){
-
+
include $appFilename;
$appClass=new $app();
}else{
-
+
$appFile=file_get_contents($appFilename);
if(!empty($appFile)){
$appClass=new \stdClass();
if(preg_match('/public\s*\$config\s*=(\s*[\s\S]+?[\]\)]\s*\;)/i', $appFile,$config)){
-
- set_error_handler(null);
+
+ set_error_handler(null);
$config=trim($config[1]);
try {
- $config=@eval('return '.$config);
+ $config=@eval('return '.$config);
}catch(\Exception $e){
$config=array();
}
@@ -47,7 +47,7 @@ public function app_class($app,$includeClass=true){
}
if($appClass){
- $appClass->config=$this->clear_config($appClass->config);
+ $appClass->config=$this->clear_config($appClass->config);
return $appClass;
}
}
@@ -68,17 +68,17 @@ public function getByApp($app){
public function deleteByApp($app){
if($app){
$this->where('app',$app)->delete();
- $this->delete_config($app);
+ $this->delete_config($app);
}
}
/*应用配置文件名*/
public function app_class_file($app){
- return realpath(config('apps_path')).DIRECTORY_SEPARATOR.$app.DIRECTORY_SEPARATOR.$app.'.php';
+ return realpath(config('apps_path')).DIRECTORY_SEPARATOR.$app.DIRECTORY_SEPARATOR.$app.'.php';
}
/*应用命名规范*/
public function right_app($app){
-
+
if(preg_match('/^[a-z]+[a-z\_0-9]*$/', $app)){
return strlen($app)<3?false:true;
}else{
@@ -104,9 +104,9 @@ public function right_name($name){
}
/*清理描述html*/
public function clear_desc($desc){
- $desc=strip_tags($desc,'
');
- $desc=preg_replace('/<(p|br|b|i)\s+.*?>/i', "<$1>", $desc);
- $desc=preg_replace('/[\r\n]+/', ' ', $desc);
+ $desc=strip_tags($desc,'
');
+ $desc=preg_replace('/<(p|br|b|i)\s+.*?>/i', "<$1>", $desc);
+ $desc=preg_replace('/[\r\n]+/', ' ', $desc);
$desc=trim($desc);
return $desc;
}
@@ -117,7 +117,7 @@ public function clear_config($arr){
$arr=$this->_array_map('strip_tags', $arr);
$arr['desc']=$desc;
if(!empty($arr['agreement'])){
- $arr['agreement']=preg_replace('/^[\s]+/m', '', $arr['agreement']);
+ $arr['agreement']=preg_replace('/^[\s]+/m', '', $arr['agreement']);
}
return $arr;
}
@@ -128,10 +128,10 @@ public function set_config($app,$config){
}
$config=is_array($config)?$config:array();
$filename=$this->config_filename($app);
- $oldConfig=$this->get_config($app);
+ $oldConfig=$this->get_config($app);
$oldConfig=is_array($oldConfig)?$oldConfig:array();
- $config=array_merge($oldConfig,$config);
+ $config=array_merge($oldConfig,$config);
$config=$this->clear_config($config);
$config=var_export($config,true);
@@ -144,7 +144,7 @@ public function get_config($app){
$filename=$this->config_filename($app);
$config=array();
if(file_exists($filename)){
-
+
$config=include $filename;
$config=is_array($config)?$config:array();
}
@@ -170,7 +170,7 @@ private function _array_map($callback, $arr1){
return $arr;
}
public function config_filename($app){
- return config('apps_path').'/app/config/'.$app.'.php';
+ return config('apps_path').'/app/config/'.$app.'.php';
}
/*获取应用类的变量*/
public function get_class_vars($appClass){
diff --git a/SkycaijiApp/admin/model/Provider.php b/SkycaijiApp/admin/model/Provider.php
index 732dbe0a..5256d835 100644
--- a/SkycaijiApp/admin/model/Provider.php
+++ b/SkycaijiApp/admin/model/Provider.php
@@ -1,13 +1,13 @@
-{$agreement}
-
\ No newline at end of file
diff --git a/SkycaijiApp/admin/view/app/apiop.html b/SkycaijiApp/admin/view/app/apiop.html
index 52139085..a4417e0c 100644
--- a/SkycaijiApp/admin/view/app/apiop.html
+++ b/SkycaijiApp/admin/view/app/apiop.html
@@ -1,59 +1,59 @@
-
\ No newline at end of file
diff --git a/SkycaijiApp/admin/view/app/manage.html b/SkycaijiApp/admin/view/app/manage.html
index 9babbc55..2cdbe05c 100644
--- a/SkycaijiApp/admin/view/app/manage.html
+++ b/SkycaijiApp/admin/view/app/manage.html
@@ -1,68 +1,68 @@
-{extend name="common:main" /}
-{block name="cssjs"}
-
-
-{/block}
-{block name="content"}
-
-{if !isset($navid)}
-
- - 启用
- -
- {$appData['config']['enable']?'已开启':'已关闭'}
-
- - 名称
- - {$appData['config']['name']}
- - 标识
- - {$appData['app']}
- - 版本
- -
- {$appData['config']['version']}
- {if $newest_version}
- 新版本{$newest_version}
- {/if}
-
- - 框架
- - {$appData['config']['framework']?($appData['config']['framework'].$appData['config']['framework_version']):'自定义'}
- {if !empty($appData['config']['phpv'])}
- - PHP
- - 最低要求php{$appData['config']['phpv']}版本
- {/if}
- - 首页
- -
- 应用首页
-
- {if !empty($appData['config']['author'])}
- - 作者
- - {$appData['config']['author']}
- {/if}
- {if !empty($provData)}
- - 平台
- - 第三方平台
- {elseif !empty($appData['config']['website'])}
- - 网站
- - 作者网站
- {/if}
- {if $appData['config']['desc']}
- - 描述
- - {$appData['config']['desc']}
- {/if}
- - 开发
- - 开发应用
-
-{else /}
-
-{/if}
-
+{extend name="common:main" /}
+{block name="cssjs"}
+
+
+{/block}
+{block name="content"}
+
+{if !isset($navid)}
+
+ - 启用
+ -
+ {$appData['config']['enable']?'已开启':'已关闭'}
+
+ - 名称
+ - {$appData['config']['name']}
+ - 标识
+ - {$appData['app']}
+ - 版本
+ -
+ {$appData['config']['version']}
+ {if $newest_version}
+ 新版本{$newest_version}
+ {/if}
+
+ - 框架
+ - {$appData['config']['framework']?($appData['config']['framework'].$appData['config']['framework_version']):'自定义'}
+ {if !empty($appData['config']['phpv'])}
+ - PHP
+ - 最低要求php{$appData['config']['phpv']}版本
+ {/if}
+ - 首页
+ -
+ 应用首页
+
+ {if !empty($appData['config']['author'])}
+ - 作者
+ - {$appData['config']['author']}
+ {/if}
+ {if !empty($provData)}
+ - 平台
+ - 第三方平台
+ {elseif !empty($appData['config']['website'])}
+ - 网站
+ - 作者网站
+ {/if}
+ {if $appData['config']['desc']}
+ - 描述
+ - {$appData['config']['desc']}
+ {/if}
+ - 开发
+ - 开发应用
+
+{else /}
+
+{/if}
+
{/block}
\ No newline at end of file
diff --git a/SkycaijiApp/admin/view/develop/app.html b/SkycaijiApp/admin/view/develop/app.html
index 3493d123..c4b6a5f9 100644
--- a/SkycaijiApp/admin/view/develop/app.html
+++ b/SkycaijiApp/admin/view/develop/app.html
@@ -1,156 +1,156 @@
-{extend name="common:main" /}
-{block name="cssjs"}
-
-{/block}
-{block name="content"}
-
-
+{extend name="common:main" /}
+{block name="cssjs"}
+
+{/block}
+{block name="content"}
+
+
+
+
+
+
{/block}
\ No newline at end of file
diff --git a/SkycaijiApp/admin/view/develop/appAddPack.html b/SkycaijiApp/admin/view/develop/appAddPack.html
index ff9fd42d..b934c40f 100644
--- a/SkycaijiApp/admin/view/develop/appAddPack.html
+++ b/SkycaijiApp/admin/view/develop/appAddPack.html
@@ -1,42 +1,42 @@
-
-
\ No newline at end of file
diff --git a/SkycaijiApp/admin/view/mystore/app.html b/SkycaijiApp/admin/view/mystore/app.html
index e6fbfebd..b8705153 100644
--- a/SkycaijiApp/admin/view/mystore/app.html
+++ b/SkycaijiApp/admin/view/mystore/app.html
@@ -1,102 +1,102 @@
-{extend name="common:main" /}
-{block name="cssjs"}
-
-
-{/block}
-{block name="content"}
-
-
-
-
-
-
-
- 应用 |
- 作者 |
-
- 操作
- |
-
- |
-
-
-
- {foreach name="dbApps" item="item" key="app"}
-
-
-
- {$item['config']['name']} {$item['config']['version']} ({$app})
-
- |
-
- {$item['config']['author']}
- |
-
- 管理
- |
- {if $item['newest_version']}
- 升级
- |
- {/if}
- {if empty($item['config']['enable'])}
- {$item['config']['enable']?'关闭':'开启'}
- |
- {/if}
- 卸载
- |
- {if !empty($provList[$item['provider_id']])}
- 第三方
- {else/}
- 平台
- {/if}
-
- |
-
- {/foreach}
- {if $pathApps}
- 未安装的应用 |
- {foreach name="pathApps" item="item" key="app"}
-
-
-
- {$item['config']['name']} v{$item['config']['version']} ({$app})
-
- |
-
- {$item['config']['author']}
- |
-
- 安装
- |
- {if !empty($provList[$item['provider_id']])}
- 第三方
- {else/}
- 平台
- {/if}
-
- |
-
- {/foreach}
- {/if}
-
-
-
-
- {if condition="!empty($pagenav)"}
-
- {$pagenav} |
-
- {/if}
-
-
-
-
-
-
-
+{extend name="common:main" /}
+{block name="cssjs"}
+
+
+{/block}
+{block name="content"}
+
+
+
+
+
+
+
+ 应用 |
+ 作者 |
+
+ 操作
+ |
+
+ |
+
+
+
+ {foreach name="dbApps" item="item" key="app"}
+
+
+
+ {$item['config']['name']} {$item['config']['version']} ({$app})
+
+ |
+
+ {$item['config']['author']}
+ |
+
+ 管理
+ |
+ {if $item['newest_version']}
+ 升级
+ |
+ {/if}
+ {if empty($item['config']['enable'])}
+ {$item['config']['enable']?'关闭':'开启'}
+ |
+ {/if}
+ 卸载
+ |
+ {if !empty($provList[$item['provider_id']])}
+ 第三方
+ {else/}
+ 平台
+ {/if}
+
+ |
+
+ {/foreach}
+ {if $pathApps}
+ 未安装的应用 |
+ {foreach name="pathApps" item="item" key="app"}
+
+
+
+ {$item['config']['name']} v{$item['config']['version']} ({$app})
+
+ |
+
+ {$item['config']['author']}
+ |
+
+ 安装
+ |
+ {if !empty($provList[$item['provider_id']])}
+ 第三方
+ {else/}
+ 平台
+ {/if}
+
+ |
+
+ {/foreach}
+ {/if}
+
+
+
+
+ {if condition="!empty($pagenav)"}
+
+ {$pagenav} |
+
+ {/if}
+
+
+
+
+
+
+
{/block}
\ No newline at end of file
diff --git a/SkycaijiApp/admin/view/provider/list.html b/SkycaijiApp/admin/view/provider/list.html
index 4f3d31d1..b3912c45 100644
--- a/SkycaijiApp/admin/view/provider/list.html
+++ b/SkycaijiApp/admin/view/provider/list.html
@@ -1,69 +1,69 @@
-{extend name="common:main" /}
-{block name="cssjs"}
-
-{/block}
-{block name="content"}
-
-
- 允许通过下列第三方平台下载规则、插件等,注意:任何第三方平台都可能存在安全隐患,请谨慎下载!
-
-
-
-
+{extend name="common:main" /}
+{block name="cssjs"}
+
+{/block}
+{block name="content"}
+
+
+ 允许通过下列第三方平台下载规则、插件等,注意:任何第三方平台都可能存在安全隐患,请谨慎下载!
+
+
+
+
{/block}
\ No newline at end of file
diff --git a/SkycaijiApp/admin/view/provider/save.html b/SkycaijiApp/admin/view/provider/save.html
index af2bdd43..28d08c3d 100644
--- a/SkycaijiApp/admin/view/provider/save.html
+++ b/SkycaijiApp/admin/view/provider/save.html
@@ -1,37 +1,37 @@
-
-{if !empty($proData)}
-
+
+{if !empty($proData)}
+
{/if}
\ No newline at end of file
diff --git a/SkycaijiApp/public/app/index_php.tpl b/SkycaijiApp/public/app/index_php.tpl
index 30e2d1f6..980c9c28 100644
--- a/SkycaijiApp/public/app/index_php.tpl
+++ b/SkycaijiApp/public/app/index_php.tpl
@@ -1,7 +1,7 @@
-app()->run();
+app()->run();
diff --git a/SkycaijiApp/public/app/skycaiji_php.tpl b/SkycaijiApp/public/app/skycaiji_php.tpl
index d6ef68fd..9a008cef 100644
--- a/SkycaijiApp/public/app/skycaiji_php.tpl
+++ b/SkycaijiApp/public/app/skycaiji_php.tpl
@@ -1,20 +1,20 @@
-'{$framework}', //框架名称
- 'framework_version'=>'{$framework_version}', //框架版本
- 'name'=>'{$name}', //应用名称
- 'desc'=>'{$desc}', //描述
- 'version'=>'{$version}', //版本号
- 'author'=>'{$author}', //作者
- 'website'=>'{$website}', //站点
- 'packs'=>{$packs}, //扩展
- );
-
- public $install='{$install}'; //安装接口
- public $uninstall='{$uninstall}'; //卸载接口
- public $upgrade='{$upgrade}'; //升级接口
-}
+'{$framework}', //框架名称
+ 'framework_version'=>'{$framework_version}', //框架版本
+ 'name'=>'{$name}', //应用名称
+ 'desc'=>'{$desc}', //描述
+ 'version'=>'{$version}', //版本号
+ 'author'=>'{$author}', //作者
+ 'website'=>'{$website}', //站点
+ 'packs'=>{$packs}, //扩展
+ );
+
+ public $install='{$install}'; //安装接口
+ public $uninstall='{$uninstall}'; //卸载接口
+ public $upgrade='{$upgrade}'; //升级接口
+}
diff --git a/app/app/skycaiji.php b/app/app/skycaiji.php
index 7ddd1be5..ea6c943a 100644
--- a/app/app/skycaiji.php
+++ b/app/app/skycaiji.php
@@ -1,269 +1,269 @@
-app=get_class($this);
- $this->systemPath=dirname(dirname(__DIR__));
- $this->appPath=$this->systemPath.$ds.'app'.$ds.$this->app;
- $this->appUrl=$this->root();
- $this->systemUrl=preg_replace('/[\/\\\]app[\/\\\]'.$this->app.'[\/\\\]*$/i', '', $this->appUrl);
-
- $this->install=ltrim($this->install,'/');
- $this->uninstall=ltrim($this->uninstall,'/');
- $this->upgrade=ltrim($this->upgrade,'/');
- }
-
- /*当前应用的实例*/
- public static function app(){
- if(!isset(self::$appInstance)){
- $appInstance=new static;//实例化
- //跳过检测的链接
- $passUrls=array('install'=>$appInstance->install,'uninstall'=>$appInstance->uninstall,'upgrade'=>$appInstance->upgrade);
- foreach ($passUrls as $k=>$v){
- if(empty($v)||$v=='1'){
- //1表示跳过操作
- unset($passUrls[$k]);
- }else{
- $v=$appInstance->appUrl.'/'.$v;
- $passUrls[$k]=strtolower($v);//必须小写
- }
- }
- $curUrl=$appInstance->url();//当前网址
- $curUrl=strtolower($curUrl);//必须小写
-
- $config=array();//已安装配置
- if(!in_array($curUrl,$passUrls)){
- //应用必须安装后才能操作
- $config=__DIR__.'/config/'.$appInstance->app.'.php';//已安装的配置文件
- if(!file_exists($config)){
- exit('未安装应用');
- }
- $config=include $config;
- $config=is_array($config)?$config:array();
- if(empty($config['enable'])){
- exit('未开启应用');
- }
- }
- //应用配置
- $appInstance->config=is_array($appInstance->config)?$appInstance->config:array();
- $appInstance->config=array_merge($appInstance->config,$config);//配置合并
-
- //蓝天采集系统配置
- $systemConfig=$appInstance->systemPath.'/data/config.php';
- if(file_exists($systemConfig)){
- $systemConfig=include $systemConfig;
- }
- $appInstance->system=is_array($systemConfig)?$systemConfig:array();
-
- self::$appInstance=$appInstance;
- }
- return self::$appInstance;
- }
- /**
- * 运行框架
- * 如果应用使用了其他框架,请在应用文件中重写run方法加载框架
- */
- public function run(){
- if(!empty($this->config['framework'])){
- //使用框架
-
- if(empty($this->config['framework_path'])){
- $frameworkPath=$this->appFrameworkPath();
- if(is_dir($frameworkPath)){
- $this->config['framework_path']=$frameworkPath;
- }
- }
- if(empty($this->config['framework_path'])){
- exit('框架路径错误');
- }
-
- $frameworkPath=$this->config['framework_path'];
-
- if('thinkphp'==$this->config['framework']){
- $version='';
- if(file_exists($frameworkPath.'/base.php')&&preg_match('/\bdefine\s*\([\'\"]THINK_VERSION[\'\"],\s*[\'\"](.*?)[\'\"]\);/i', file_get_contents($frameworkPath.'/base.php'),$version)){
- $version=$version[1];
- }elseif(file_exists($frameworkPath.'/library/think/App.php')&&preg_match('/\bconst\s+VERSION\s*=\s*[\'\"](.*?)[\'\"]/i', file_get_contents($frameworkPath.'/library/think/App.php'),$version)){
- $version=$version[1];
- }elseif(file_exists($frameworkPath.'/src/think/App.php')&&preg_match('/\bconst\s+VERSION\s*=\s*[\'\"](.*?)[\'\"]/i', file_get_contents($frameworkPath.'/src/think/App.php'),$version)){
- $version=$version[1];
- }
-
- if(preg_match('/^5\.0\./', $version)){
- //5.0
- define('APP_PATH', $this->appPath . '/application/');
- require $frameworkPath . '/base.php';
- \think\App::run()->send();
- }elseif(preg_match('/^5\.1\./', $version)){
- //5.1
- define('APP_PATH', $this->appPath . '/application/');
- require $frameworkPath . '/base.php';
- \think\Container::get('app')->path(APP_PATH)->run()->send();
- }elseif(preg_match('/^6\.0\./', $version)){
- //6.0
- require $this->appPath . '/vendor/autoload.php';
- $http = (new \think\App())->http;
- $response = $http->run();
- $response->send();
- $http->end($response);
- }
- }elseif('laravel'==$this->config['framework']){
- $version='';
- $frameworkPath.='/src/Illuminate';
- if(preg_match('/\bconst\s+VERSION\s*=\s*[\'\"](.*?)[\'\"]/i', file_get_contents($frameworkPath.'/Foundation/Application.php'),$version)){
- $version=$version[1];
- }else{
- $version='';
- }
- if(preg_match('/^5\.1\./', $version)){
- //5.1.x
- require $this->appPath.'/bootstrap/autoload.php';
- $app = require_once $this->appPath.'/bootstrap/app.php';
- $kernel = $app->make('Illuminate\Contracts\Http\Kernel');
- $response = $kernel->handle(
- $request = \Illuminate\Http\Request::capture()
- );
- $response->send();
- $kernel->terminate($request, $response);
- }elseif(preg_match('/^5\.5\./', $version)){
- //5.5.x
- define('LARAVEL_START', microtime(true));
- require $this->appPath.'/vendor/autoload.php';
- $app = require_once $this->appPath.'/bootstrap/app.php';
- $kernel = $app->make('Illuminate\Contracts\Http\Kernel');
- $response = $kernel->handle(
- $request = \Illuminate\Http\Request::capture()
- );
- $response->send();
- $kernel->terminate($request, $response);
- }
- }
- }
- }
- /**
- * 获取内置的框架路径
- */
- public function appFrameworkPath(){
- $frameworkPath='';
- if(empty($this->config['framework_path'])){
- //检测框架是否存在
- switch ($this->config['framework']){
- case 'thinkphp':
- $frameworkPath=$this->appPath.'/vendor/topthink/framework';
- if(!file_exists($frameworkPath)){
- //不存在目录
- $frameworkPath=$this->appPath.'/thinkphp';//使用旧形式的框架目录
- }
- break;
- case 'laravel':$frameworkPath=$this->appPath.'/vendor/laravel/framework';break;
- }
- }
- return $frameworkPath;
- }
- /**
- * 获取当前执行的文件
- */
- public function baseFile(){
- $url='';
- $script_name = basename($_SERVER['SCRIPT_FILENAME']);
- if (basename($_SERVER['SCRIPT_NAME']) === $script_name) {
- $url = $_SERVER['SCRIPT_NAME'];
- } elseif (basename($_SERVER['PHP_SELF']) === $script_name) {
- $url = $_SERVER['PHP_SELF'];
- } elseif (isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME']) === $script_name) {
- $url = $_SERVER['ORIG_SCRIPT_NAME'];
- } elseif (($pos = strpos($_SERVER['PHP_SELF'], '/' . $script_name)) !== false) {
- $url = substr($_SERVER['SCRIPT_NAME'], 0, $pos) . '/' . $script_name;
- } elseif (isset($_SERVER['DOCUMENT_ROOT']) && strpos($_SERVER['SCRIPT_FILENAME'], $_SERVER['DOCUMENT_ROOT']) === 0) {
- $url = str_replace('\\', '/', str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_FILENAME']));
- }
- return $url;
- }
- /**
- * 获取当前完整URL
- */
- public function url(){
- $url='';
- if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
- $url = $_SERVER['HTTP_X_REWRITE_URL'];
- } elseif (isset($_SERVER['REQUEST_URI'])) {
- $url = $_SERVER['REQUEST_URI'];
- } elseif (isset($_SERVER['ORIG_PATH_INFO'])) {
- $url = $_SERVER['ORIG_PATH_INFO'] . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '');
- } else {
- $url = '';
- }
- return $url;
- }
- /**
- * 获取应用根目录
- * @return string
- */
- public function root(){
- $file = $this->baseFile();
- if ($file && 0 !== strpos($this->url(), $file)) {
- $file = str_replace('\\', '/', dirname($file));
- }
- return rtrim($file, '/');
- }
- /**
- * 判断蓝天采集器是否管理员登录
- * @param string $jump 是否跳转至登录界面
- * @return boolean
- */
- public function isAdmin($jump=false){
- if(session_status()!==2){
- session_start();
- }
- if(isset($_SESSION['skycaiji'])&&!empty($_SESSION['skycaiji']['is_admin'])){
- return true;
- }else{
- if($jump){
- //跳转至登录页面
- $url=$this->url();
- $url=$this->systemUrl.'/index.php?s=admin&_referer='.rawurlencode($url);
-
- $html='请登录管理员账号';
- exit($html);
- }else{
- return false;
- }
- }
- }
- /**
- * 输出json格式状态信息
- * @param init $status 状态 1:成功 ,0:失败
- * @param string $info 提示内容
- * @param string $url 跳转网址
- */
- public function status($status=0,$info='',$url=''){
- $data=array('status'=>$status,'info'=>$info,'url'=>$url);
- $data=json_encode($data);
- header('content-type:application/json;charset=utf-8');
- exit($data);
- }
-}
-
-/**
- * 获取当前app实例化对象
- * 所有skycaiji类及子类中的方法都应该通过该函数来调用
- */
-if(!defined('skycaiji_app')){
- function skycaiji_app(){
- return \skycaiji::app();
- }
-}
+app=get_class($this);
+ $this->systemPath=dirname(dirname(__DIR__));
+ $this->appPath=$this->systemPath.$ds.'app'.$ds.$this->app;
+ $this->appUrl=$this->root();
+ $this->systemUrl=preg_replace('/[\/\\\]app[\/\\\]'.$this->app.'[\/\\\]*$/i', '', $this->appUrl);
+
+ $this->install=ltrim($this->install,'/');
+ $this->uninstall=ltrim($this->uninstall,'/');
+ $this->upgrade=ltrim($this->upgrade,'/');
+ }
+
+ /*当前应用的实例*/
+ public static function app(){
+ if(!isset(self::$appInstance)){
+ $appInstance=new static;//实例化
+ //跳过检测的链接
+ $passUrls=array('install'=>$appInstance->install,'uninstall'=>$appInstance->uninstall,'upgrade'=>$appInstance->upgrade);
+ foreach ($passUrls as $k=>$v){
+ if(empty($v)||$v=='1'){
+ //1表示跳过操作
+ unset($passUrls[$k]);
+ }else{
+ $v=$appInstance->appUrl.'/'.$v;
+ $passUrls[$k]=strtolower($v);//必须小写
+ }
+ }
+ $curUrl=$appInstance->url();//当前网址
+ $curUrl=strtolower($curUrl);//必须小写
+
+ $config=array();//已安装配置
+ if(!in_array($curUrl,$passUrls)){
+ //应用必须安装后才能操作
+ $config=__DIR__.'/config/'.$appInstance->app.'.php';//已安装的配置文件
+ if(!file_exists($config)){
+ exit('未安装应用');
+ }
+ $config=include $config;
+ $config=is_array($config)?$config:array();
+ if(empty($config['enable'])){
+ exit('未开启应用');
+ }
+ }
+ //应用配置
+ $appInstance->config=is_array($appInstance->config)?$appInstance->config:array();
+ $appInstance->config=array_merge($appInstance->config,$config);//配置合并
+
+ //蓝天采集系统配置
+ $systemConfig=$appInstance->systemPath.'/data/config.php';
+ if(file_exists($systemConfig)){
+ $systemConfig=include $systemConfig;
+ }
+ $appInstance->system=is_array($systemConfig)?$systemConfig:array();
+
+ self::$appInstance=$appInstance;
+ }
+ return self::$appInstance;
+ }
+ /**
+ * 运行框架
+ * 如果应用使用了其他框架,请在应用文件中重写run方法加载框架
+ */
+ public function run(){
+ if(!empty($this->config['framework'])){
+ //使用框架
+
+ if(empty($this->config['framework_path'])){
+ $frameworkPath=$this->appFrameworkPath();
+ if(is_dir($frameworkPath)){
+ $this->config['framework_path']=$frameworkPath;
+ }
+ }
+ if(empty($this->config['framework_path'])){
+ exit('框架路径错误');
+ }
+
+ $frameworkPath=$this->config['framework_path'];
+
+ if('thinkphp'==$this->config['framework']){
+ $version='';
+ if(file_exists($frameworkPath.'/base.php')&&preg_match('/\bdefine\s*\([\'\"]THINK_VERSION[\'\"],\s*[\'\"](.*?)[\'\"]\);/i', file_get_contents($frameworkPath.'/base.php'),$version)){
+ $version=$version[1];
+ }elseif(file_exists($frameworkPath.'/library/think/App.php')&&preg_match('/\bconst\s+VERSION\s*=\s*[\'\"](.*?)[\'\"]/i', file_get_contents($frameworkPath.'/library/think/App.php'),$version)){
+ $version=$version[1];
+ }elseif(file_exists($frameworkPath.'/src/think/App.php')&&preg_match('/\bconst\s+VERSION\s*=\s*[\'\"](.*?)[\'\"]/i', file_get_contents($frameworkPath.'/src/think/App.php'),$version)){
+ $version=$version[1];
+ }
+
+ if(preg_match('/^5\.0\./', $version)){
+ //5.0
+ define('APP_PATH', $this->appPath . '/application/');
+ require $frameworkPath . '/base.php';
+ \think\App::run()->send();
+ }elseif(preg_match('/^5\.1\./', $version)){
+ //5.1
+ define('APP_PATH', $this->appPath . '/application/');
+ require $frameworkPath . '/base.php';
+ \think\Container::get('app')->path(APP_PATH)->run()->send();
+ }elseif(preg_match('/^6\.0\./', $version)){
+ //6.0
+ require $this->appPath . '/vendor/autoload.php';
+ $http = (new \think\App())->http;
+ $response = $http->run();
+ $response->send();
+ $http->end($response);
+ }
+ }elseif('laravel'==$this->config['framework']){
+ $version='';
+ $frameworkPath.='/src/Illuminate';
+ if(preg_match('/\bconst\s+VERSION\s*=\s*[\'\"](.*?)[\'\"]/i', file_get_contents($frameworkPath.'/Foundation/Application.php'),$version)){
+ $version=$version[1];
+ }else{
+ $version='';
+ }
+ if(preg_match('/^5\.1\./', $version)){
+ //5.1.x
+ require $this->appPath.'/bootstrap/autoload.php';
+ $app = require_once $this->appPath.'/bootstrap/app.php';
+ $kernel = $app->make('Illuminate\Contracts\Http\Kernel');
+ $response = $kernel->handle(
+ $request = \Illuminate\Http\Request::capture()
+ );
+ $response->send();
+ $kernel->terminate($request, $response);
+ }elseif(preg_match('/^5\.5\./', $version)){
+ //5.5.x
+ define('LARAVEL_START', microtime(true));
+ require $this->appPath.'/vendor/autoload.php';
+ $app = require_once $this->appPath.'/bootstrap/app.php';
+ $kernel = $app->make('Illuminate\Contracts\Http\Kernel');
+ $response = $kernel->handle(
+ $request = \Illuminate\Http\Request::capture()
+ );
+ $response->send();
+ $kernel->terminate($request, $response);
+ }
+ }
+ }
+ }
+ /**
+ * 获取内置的框架路径
+ */
+ public function appFrameworkPath(){
+ $frameworkPath='';
+ if(empty($this->config['framework_path'])){
+ //检测框架是否存在
+ switch ($this->config['framework']){
+ case 'thinkphp':
+ $frameworkPath=$this->appPath.'/vendor/topthink/framework';
+ if(!file_exists($frameworkPath)){
+ //不存在目录
+ $frameworkPath=$this->appPath.'/thinkphp';//使用旧形式的框架目录
+ }
+ break;
+ case 'laravel':$frameworkPath=$this->appPath.'/vendor/laravel/framework';break;
+ }
+ }
+ return $frameworkPath;
+ }
+ /**
+ * 获取当前执行的文件
+ */
+ public function baseFile(){
+ $url='';
+ $script_name = basename($_SERVER['SCRIPT_FILENAME']);
+ if (basename($_SERVER['SCRIPT_NAME']) === $script_name) {
+ $url = $_SERVER['SCRIPT_NAME'];
+ } elseif (basename($_SERVER['PHP_SELF']) === $script_name) {
+ $url = $_SERVER['PHP_SELF'];
+ } elseif (isset($_SERVER['ORIG_SCRIPT_NAME']) && basename($_SERVER['ORIG_SCRIPT_NAME']) === $script_name) {
+ $url = $_SERVER['ORIG_SCRIPT_NAME'];
+ } elseif (($pos = strpos($_SERVER['PHP_SELF'], '/' . $script_name)) !== false) {
+ $url = substr($_SERVER['SCRIPT_NAME'], 0, $pos) . '/' . $script_name;
+ } elseif (isset($_SERVER['DOCUMENT_ROOT']) && strpos($_SERVER['SCRIPT_FILENAME'], $_SERVER['DOCUMENT_ROOT']) === 0) {
+ $url = str_replace('\\', '/', str_replace($_SERVER['DOCUMENT_ROOT'], '', $_SERVER['SCRIPT_FILENAME']));
+ }
+ return $url;
+ }
+ /**
+ * 获取当前完整URL
+ */
+ public function url(){
+ $url='';
+ if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
+ $url = $_SERVER['HTTP_X_REWRITE_URL'];
+ } elseif (isset($_SERVER['REQUEST_URI'])) {
+ $url = $_SERVER['REQUEST_URI'];
+ } elseif (isset($_SERVER['ORIG_PATH_INFO'])) {
+ $url = $_SERVER['ORIG_PATH_INFO'] . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '');
+ } else {
+ $url = '';
+ }
+ return $url;
+ }
+ /**
+ * 获取应用根目录
+ * @return string
+ */
+ public function root(){
+ $file = $this->baseFile();
+ if ($file && 0 !== strpos($this->url(), $file)) {
+ $file = str_replace('\\', '/', dirname($file));
+ }
+ return rtrim($file, '/');
+ }
+ /**
+ * 判断蓝天采集器是否管理员登录
+ * @param string $jump 是否跳转至登录界面
+ * @return boolean
+ */
+ public function isAdmin($jump=false){
+ if(session_status()!==2){
+ session_start();
+ }
+ if(isset($_SESSION['skycaiji'])&&!empty($_SESSION['skycaiji']['is_admin'])){
+ return true;
+ }else{
+ if($jump){
+ //跳转至登录页面
+ $url=$this->url();
+ $url=$this->systemUrl.'/index.php?s=admin&_referer='.rawurlencode($url);
+
+ $html='请登录管理员账号';
+ exit($html);
+ }else{
+ return false;
+ }
+ }
+ }
+ /**
+ * 输出json格式状态信息
+ * @param init $status 状态 1:成功 ,0:失败
+ * @param string $info 提示内容
+ * @param string $url 跳转网址
+ */
+ public function status($status=0,$info='',$url=''){
+ $data=array('status'=>$status,'info'=>$info,'url'=>$url);
+ $data=json_encode($data);
+ header('content-type:application/json;charset=utf-8');
+ exit($data);
+ }
+}
+
+/**
+ * 获取当前app实例化对象
+ * 所有skycaiji类及子类中的方法都应该通过该函数来调用
+ */
+if(!defined('skycaiji_app')){
+ function skycaiji_app(){
+ return \skycaiji::app();
+ }
+}
diff --git a/build.php b/build.php
index a12d26c1..d63be3ad 100644
--- a/build.php
+++ b/build.php
@@ -1,25 +1,25 @@
-
-// +----------------------------------------------------------------------
-
-return [
- // 生成应用公共文件
- '__file__' => ['common.php', 'config.php', 'database.php'],
-
- // 定义demo模块的自动生成 (按照实际定义的文件名生成)
- 'demo' => [
- '__file__' => ['common.php'],
- '__dir__' => ['behavior', 'controller', 'model', 'view'],
- 'controller' => ['Index', 'Test', 'UserType'],
- 'model' => ['User', 'UserType'],
- 'view' => ['index/index'],
- ],
- // 其他更多的模块定义
-];
+
+// +----------------------------------------------------------------------
+
+return [
+ // 生成应用公共文件
+ '__file__' => ['common.php', 'config.php', 'database.php'],
+
+ // 定义demo模块的自动生成 (按照实际定义的文件名生成)
+ 'demo' => [
+ '__file__' => ['common.php'],
+ '__dir__' => ['behavior', 'controller', 'model', 'view'],
+ 'controller' => ['Index', 'Test', 'UserType'],
+ 'model' => ['User', 'UserType'],
+ 'view' => ['index/index'],
+ ],
+ // 其他更多的模块定义
+];
diff --git a/nginx.conf b/nginx.conf
index 456a5491..a980f6cf 100644
--- a/nginx.conf
+++ b/nginx.conf
@@ -1,4 +1,4 @@
-if (!-e $request_filename) {
- rewrite ^/app/(\w+)/(.*)$ /app/$1/index.php?s=/$2 last;
- rewrite ^/(.*)$ /index.php?s=/$1 last;
+if (!-e $request_filename) {
+ rewrite ^/app/(\w+)/(.*)$ /app/$1/index.php?s=/$2 last;
+ rewrite ^/(.*)$ /index.php?s=/$1 last;
}
\ No newline at end of file
diff --git a/public/static/css/app.css b/public/static/css/app.css
index 0d63bc6b..55cf1fbf 100644
--- a/public/static/css/app.css
+++ b/public/static/css/app.css
@@ -1,25 +1,25 @@
-@CHARSET "UTF-8";
-.content-wrapper .content-header{display:none;}
-.content-wrapper .content{padding:0;height:100%;overflow:hidden;position:relative;}
-.content-wrapper{background:#fdfdfd;}
-
-.manage-nav{margin:0;padding:0px;overflow:hidden;list-style:none;border-bottom:1px solid #ddd;background:#ecf0f5;}
-.manage-nav li{padding:8px 0px 8px 15px;margin:0;float:left;}
-.manage-nav .active{font-weight:bold;}
-.manage-nav .glyphicon-list{margin-top:1px;}
-
-.dl-info{}
-.dl-info dt{float:left;clear:left;width:60px;padding-top:10px;}
-.dl-info dd{margin-left:60px;padding-top:10px;}
-
-.iframe-main{
- width: 100%;
- height: 100%;
- display:none;
- border-top-width: 0px;
- border-right-width: 0px;
- border-bottom-width: 0px;
- border-left-width: 0px;
-}
-.iframe-loading{position:absolute;left:20px;top:60px;line-height:32px;text-align:center;}
+@CHARSET "UTF-8";
+.content-wrapper .content-header{display:none;}
+.content-wrapper .content{padding:0;height:100%;overflow:hidden;position:relative;}
+.content-wrapper{background:#fdfdfd;}
+
+.manage-nav{margin:0;padding:0px;overflow:hidden;list-style:none;border-bottom:1px solid #ddd;background:#ecf0f5;}
+.manage-nav li{padding:8px 0px 8px 15px;margin:0;float:left;}
+.manage-nav .active{font-weight:bold;}
+.manage-nav .glyphicon-list{margin-top:1px;}
+
+.dl-info{}
+.dl-info dt{float:left;clear:left;width:60px;padding-top:10px;}
+.dl-info dd{margin-left:60px;padding-top:10px;}
+
+.iframe-main{
+ width: 100%;
+ height: 100%;
+ display:none;
+ border-top-width: 0px;
+ border-right-width: 0px;
+ border-bottom-width: 0px;
+ border-left-width: 0px;
+}
+.iframe-loading{position:absolute;left:20px;top:60px;line-height:32px;text-align:center;}
.iframe-loading .loading{float:left;margin-right:5px;}
\ No newline at end of file
diff --git a/public/static/js/admin/app.js b/public/static/js/admin/app.js
index 4a038fb6..3bdf43ec 100644
--- a/public/static/js/admin/app.js
+++ b/public/static/js/admin/app.js
@@ -1,12 +1,12 @@
-/*
- |--------------------------------------------------------------------------
- | SkyCaiji (蓝天采集器)
- |--------------------------------------------------------------------------
- | Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
- |--------------------------------------------------------------------------
- | 使用协议 https://www.skycaiji.com/licenses
- |--------------------------------------------------------------------------
- */
+/*
+ |--------------------------------------------------------------------------
+ | SkyCaiji (蓝天采集器)
+ |--------------------------------------------------------------------------
+ | Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
+ |--------------------------------------------------------------------------
+ | 使用协议 https://www.skycaiji.com/licenses
+ |--------------------------------------------------------------------------
+ */
'use strict';function AppClass(){}
AppClass.prototype={constructor:AppClass,init_list:function(){var $_o=this;$(document).ready(function(){$('#app_list').on('click','.install',function(){var obj=$(this);var parent=obj.parents('tr[data-app]');var app=parent.attr('data-app');if(parent.attr('data-agreement')){windowModal('协议',ulink('Admin/App/agreement?app=_app_',{'_app_':app}))}else{confirmRight('是否安装?',function(){windowModal('正在安装...',ulink('Admin/App/install?app=_app_',{'_app_':app}))})}});$('#app_list').on('click','.uninstall',function(){var obj=$(this);confirmRight('卸载会清理相关数据,确定卸载?',function(){var app=obj.parents('tr[data-app]').attr('data-app');windowModal('正在卸载...',ulink('Admin/App/uninstall?app=_app_',{'_app_':app}))})});$('#app_list').on('click','.upgrade',function(){var obj=$(this);confirmRight('确定升级至新版本?',function(){var app=obj.parents('tr[data-app]').attr('data-app');windowModal('正在升级...',ulink('Admin/App/upgrade?app=_app_',{'_app_':app}))})});$('#app_list').on('click','.enable',function(){var app=$(this).parents('tr[data-app]').attr('data-app');var enable=$(this).attr('data-enable');enable=parseInt(enable);enable=enable>0?0:1;windowModal((enable?'开启':'关闭')+'应用',ulink('Admin/App/enable?app=_app_&enable=_enable_',{'_app_':app,'_enable_':enable}))});$("[data-toggle='popover']").popover();if($('#auto_check').is(':checked')){$_o.check_update()}
$('#auto_check').bind('click',function(){var auto=$(this).is(':checked')?1:0;$.ajax({type:"GET",url:ulink('Mystore/appOp?op=auto_check&auto='+auto),dataType:"json",success:function(data){data.code==1?toastr.success(data.msg):toastr.error(data.msg)}})});$('#btn_check').bind('click',function(){$_o.check_update()})})},init_manage:function(){$('#app_manage .nav-tabs a').bind('click',function(){if($(this).attr('target')=='_blank'){window.open($(this).attr('data-url'),'_blank');return!1}});$('#newest_version').bind('click',function(){var obj=$(this);confirmRight('确定升级至新版本?',function(){var app=obj.attr('data-app');windowModal('正在升级...',ulink('Admin/App/upgrade?app=_app_',{'_app_':app}))})});$('#enable').bind('click',function(){var app=$(this).attr('data-app');var enable=$(this).attr('data-enable');enable=parseInt(enable);enable=enable>0?0:1;windowModal((enable?'开启':'关闭')+'应用',ulink('Admin/App/enable?app=_app_&enable=_enable_',{'_app_':app,'_enable_':enable}))});if(document.getElementById('iframe_main')){var boxHeight=$(window).height()-$('.main-header').height();$('.content').height(boxHeight+'px');boxHeight=boxHeight-$('.content .manage-nav').height();$('.content .manage-wrap').height(boxHeight);$('#iframe_main').on('load',function(){$('.iframe-loading').remove();$(this).show()})}},check_update:function(){var apps=new Array();$('#app_list').find('tr[data-app]').each(function(){apps.push($(this).attr('data-app'))});if(apps.length>0){$('#btn_check').html('检测更新 ');$('.app-store-info').find('.has-update').remove();$.ajax({type:"get",url:ulink('Mystore/appOp?op=check_store_update'),dataType:"json",async:!0,data:{apps:apps},success:function(data){if(data.code==1&&data.data){for(var i in data.data){var app=data.data[i];var storeInfo=$('tr[data-app="'+app.app+'"]').find('.app-store-info');var html='有更新
';storeInfo.append(html)}}else{ajaxDataMsg(data)}},complete:function(){$('#btn_check').html('检测更新')}})}},};var appClass=new AppClass();$(document).ready(function(){storeClass.init_my()})
\ No newline at end of file
diff --git a/public/static/js/admin/provider.js b/public/static/js/admin/provider.js
index 7fe0123f..45c2d2e1 100644
--- a/public/static/js/admin/provider.js
+++ b/public/static/js/admin/provider.js
@@ -1,12 +1,12 @@
-/*
- |--------------------------------------------------------------------------
- | SkyCaiji (蓝天采集器)
- |--------------------------------------------------------------------------
- | Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
- |--------------------------------------------------------------------------
- | 使用协议 https://www.skycaiji.com/licenses
- |--------------------------------------------------------------------------
- */
+/*
+ |--------------------------------------------------------------------------
+ | SkyCaiji (蓝天采集器)
+ |--------------------------------------------------------------------------
+ | Copyright (c) 2018 https://www.skycaiji.com All rights reserved.
+ |--------------------------------------------------------------------------
+ | 使用协议 https://www.skycaiji.com/licenses
+ |--------------------------------------------------------------------------
+ */
'use strict';function ProviderClass(){}
ProviderClass.prototype={constructor:ProviderClass,list_init:function(){$('#form_list').on('click','.delete',function(){var tr=$(this).parents('tr[data-id]');var id=tr.attr('data-id');confirmRight('确定删除?',function(){$.ajax({type:'GET',url:ulink('Provider/delete?id='+id),dataType:'json',success:function(data){if(data.code){tr.remove();toastr.success('删除成功')}else{toastr.error(data.msg)}}})})});$('#form_list').on('click','.comment',function(){var url=$(this).parents('tr[data-url]').attr('data-url');url='https://www.skycaiji.com/provider?url='+encodeURIComponent(url);windowStore('评价',url,{lg:1});return!1});$('#form_list').on('click','.edit',function(){var id=$(this).parents('tr[data-id]').attr('data-id');windowModal('编辑',ulink('provider/save?id='+id));return!1});$('#form_list').on('click','.store',function(){var url=$(this).parents('tr[data-url]').attr('data-url');window.location.href=ulink('Store/index?url='+encodeURIComponent(url));return!1});$('#form_list').on('click','.enable',function(){var obj=$(this);var id=$(this).parents('tr[data-id]').attr('data-id');var enable=($(this).text()=='允许')?0:1;$.ajax({type:'GET',url:ulink('Provider/enable?id='+id+'&enable='+enable),dataType:'json',success:function(data){if(data.code){obj.text(enable?'允许':'拒绝');obj.css('color',(enable?'green':'red'))}else{toastr.error(data.msg)}}})});$('#btn_add').bind('click',function(){windowModal('添加',ulink('provider/save'));return!1})},load:function(data){var fid='#win_form_provider';if(data){$(fid).find('[name="url"]').val(data.url);$(fid).find('[name="title"]').val(data.title);$(fid).find('[name="sort"]').val(data.sort);$(fid).find('[name="enable"][value="'+data.enable+'"]').prop('checked','checked')}}}
var providerClass=new ProviderClass()
\ No newline at end of file