作者 赵彬吉
... ... @@ -94,11 +94,20 @@ class HtmlCollect extends Command
//采集html页面,下载资源到本地并替换
try {
$html = file_get_contents('https://' . $collect_info->domain . $collect_info->route);
$opts = [
'http' => [
'header' => 'User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0'
],
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
]
];
$html = file_get_contents('https://' . $collect_info->domain . $collect_info->route, false, stream_context_create($opts));
$source_list = $this->html_preg($html, $project_id, $collect_info->domain, $web_url_domain, $home_url);
if ($source_list) {
$html = $this->upload_source($html, $source_list, $project_id);
$html = $this->upload_source($html, $source_list, $project_id, $opts);
}
} catch (\Exception $e) {
$collect_info->status = CollectTask::STATUS_FAIL;
... ... @@ -271,7 +280,7 @@ class HtmlCollect extends Command
}
//下载并替换资源
protected function upload_source($html, $source, $project_id)
protected function upload_source($html, $source, $project_id, $opts)
{
foreach ($source as $vs) {
... ... @@ -289,7 +298,7 @@ class HtmlCollect extends Command
if (substr($new_source, -3, 3) == 'css') {
// 下载css文件中的资源
$css_html = file_get_contents($vs['url_complete']);
$css_html = file_get_contents($vs['url_complete'], false, stream_context_create($opts));
preg_match_all("/url\(['\"](\s*[^>]+?)['\"]\)/i", $css_html, $result_css_source);
$css_source = $result_css_source[1] ?? [];
... ...
... ... @@ -93,11 +93,20 @@ class HtmlLanguageCollect extends Command
//采集html页面,下载资源到本地并替换
try {
$html = file_get_contents('https://' . $collect_info->domain . $collect_info->route);
$opts = [
'http' => [
'header' => 'User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0'
],
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
]
];
$html = file_get_contents('https://' . $collect_info->domain . $collect_info->route, false, stream_context_create($opts));
$source_list = $this->html_preg($html, $project_id, $collect_info->domain, $web_url_domain, $home_url);
if ($source_list) {
$html = $this->upload_source($html, $source_list, $project_id);
$html = $this->upload_source($html, $source_list, $project_id, $opts);
}
} catch (\Exception $e) {
$collect_info->status = CollectTask::STATUS_FAIL;
... ... @@ -270,7 +279,7 @@ class HtmlLanguageCollect extends Command
}
//下载并替换资源
protected function upload_source($html, $source, $project_id)
protected function upload_source($html, $source, $project_id, $opts)
{
foreach ($source as $vs) {
... ... @@ -288,7 +297,7 @@ class HtmlLanguageCollect extends Command
if (substr($new_source, -3, 3) == 'css') {
// 下载css文件中的资源
$css_html = file_get_contents($vs['url_complete']);
$css_html = file_get_contents($vs['url_complete'], false, stream_context_create($opts));
preg_match_all("/url\(['\"](\s*[^>]+?)['\"]\)/i", $css_html, $result_css_source);
$css_source = $result_css_source[1] ?? [];
... ...
... ... @@ -83,17 +83,11 @@ class IndexController extends BaseController
$this->request->validate([
'data' => 'required|array',
'identifying'=>'required',
'code'=>'required'
], [
'data.required' => '自定义询盘数据不为空',
'data.array' => '必须为数组',
'identifying.required' => '唯一标识不为空',
'code'=>'加密串不能为空'
]);
$code = base64_encode(md5($this->param['identifying']));
if($code != $this->param['code']){
$this->response('签名错误',Code::SYSTEM_ERROR);
}
$inquiryModel = new InquiryData();
$rs = $inquiryModel->add($this->param);
if($rs === false){
... ... @@ -101,5 +95,5 @@ class IndexController extends BaseController
}
$this->response('success');
}
}
... ...
... ... @@ -817,11 +817,41 @@ class ProjectController extends BaseController
* @time :2023/11/17 15:23
*/
public function saveOtherProject(ProjectLogic $logic){
$this->request->validate([
'id'=>'required',
'aicc'=>'required',
'hagro'=>'required',
'exclusive_aicc_day'=>'required',
'exclusive_hagro_day'=>'required',
],[
'id.required' => 'id不能为空',
'aicc.required' => 'aicc是否开启不能为空',
'hagro.required' => 'hagro是否开启不能为空',
'exclusive_aicc_day.required' => '服务天数不能为空',
'exclusive_hagro_day.required' => '服务天数不能为空',
]);
$logic->saveOtherProject();
$this->response('success');
}
/**
* @remark :获取其他项目配置
* @name :getOtherProject
* @author :lyh
* @method :post
* @time :2023/11/17 15:23
*/
public function getOtherProject(ProjectLogic $logic){
$this->request->validate([
'id'=>'required',
],[
'id.required' => 'id不能为空',
]);
$info = $logic->getOtherProject();
$this->response('success',Code::SUCCESS,$info);
}
/**
* @remark :获取渠道信息
* @name :getChannel
* @author :lyh
... ...
... ... @@ -110,4 +110,13 @@ class NavController extends BaseController
$navLogic->navSort();
$this->response('success');
}
/**
* 一键导入子菜单
* @author zbj
* @date 2023/11/21
*/
public function import(){
}
}
... ...
... ... @@ -710,4 +710,16 @@ class ProjectLogic extends BaseLogic
return $this->success($this->param);
}
/**
* @remark :获取其他配置
* @name :getOtherProject
* @author :lyh
* @method :post
* @time :2023/11/21 15:45
*/
public function getOtherProject(){
$info = $this->model->read(['id'=>$this->param['id']],['aicc','hagro','exclusive_aicc_day','exclusive_hagro_day']);
return $this->success($info);
}
}
... ...
... ... @@ -21,6 +21,7 @@ class BNav extends Base
use SoftDeletes;
public $hidden = ['deleted_at'];
public $appends = ['able_import'];
/**
... ... @@ -74,4 +75,19 @@ class BNav extends Base
$value = getImageUrl($value);
return $value;
}
/**
* 是否支持一键导入
* @param $value
* @return int
* @author zbj
* @date 2023/11/21
*/
public function getAbleImportAttribute($value)
{
if(in_array($this->url, ['products','news','blogs'])){
return 1;
}
return 0;
}
}
... ...
... ... @@ -6,6 +6,7 @@ use App\Helper\Translate;
use App\Http\Logic\Aside\Project\ProjectLogic;
use App\Models\Base;
use App\Models\Project\Project;
use App\Models\Template\BTemplate;
/**
* 路由映射表
... ... @@ -55,9 +56,17 @@ class RouteMap extends Base
$i=1;
$sign = generateRoute($title);
$route = $sign;
if($source == BTemplate::SOURCE_PRODUCT){
$route = $sign.'-product';
}elseif ($source == 5){
$route = $sign.'-tag';
}
while(self::isExist($route, $source, $source_id, $project_id)){
$route = $sign .'-'.$i;
$i++;
if($source == BTemplate::SOURCE_PRODUCT){
$route = $sign .'-'.$i.'-product';
}elseif ($source == 5){
$route = $sign .'-'.$i.'-tag';
}
}
return $route;
}
... ... @@ -119,11 +128,6 @@ class RouteMap extends Base
if(!$route_map){
$route_map = new self();
$route_map->source = $source;
if ($source == self::SOURCE_PRODUCT_KEYWORD){
$route = $route.'-tag';
}elseif ($source == self::SOURCE_PRODUCT){
$route = $route.'-product';
}
$route_map->source_id = $source_id;
$route_map->project_id = $project_id;
}
... ...
... ... @@ -172,6 +172,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/copyProject', [Aside\Project\ProjectController::class, 'copyProject'])->name('admin.project_copyProject');
Route::any('/site_token', [Aside\Project\ProjectController::class, 'site_token'])->name('admin.project_site_token');
Route::any('/saveOtherProject', [Aside\Project\ProjectController::class, 'saveOtherProject'])->name('admin.project_saveOtherProject');//其他项目设置
Route::any('/getOtherProject', [Aside\Project\ProjectController::class, 'getOtherProject'])->name('admin.project_getOtherProject');//获取其他项目设置
Route::any('/getChannel', [Aside\Project\ProjectController::class, 'getChannel'])->name('admin.project_getChannel');//其他项目设置
//获取关键词前缀和后缀
Route::prefix('keyword')->group(function () {
... ...