作者 lyh

gx

... ... @@ -8,6 +8,7 @@ use App\Helper\OaGlobalsoApi;
use App\Models\Channel\Channel;
use App\Models\Com\NoticeLog;
use App\Models\Com\UpdateLog;
use App\Models\Com\UpdateVisit;
use App\Models\Project\After;
use App\Models\Project\DeployBuild;
use App\Models\Project\DeployOptimize;
... ... @@ -244,6 +245,7 @@ class SyncProject extends Command
foreach ($task_list as $task){
UpdateLog::createLog($id,$task,$param['get_data_url']);
}
UpdateVisit::createLog($id,$param['get_data_url']);
}
DB::commit();
}catch (\Exception $e){
... ...
... ... @@ -5,6 +5,7 @@ namespace App\Console\Commands\Test;
use App\Helper\Arr;
use App\Models\Collect\CollectTask;
use App\Models\Com\UpdateLog;
use App\Models\Com\UpdateVisit;
use App\Models\Product\Product;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
... ... @@ -29,31 +30,12 @@ class Temp extends Command
public function handle()
{
$data_project = [162];
foreach ($data_project as $project_id) {
$project = ProjectServer::useProject($project_id);
if ($project) {
$list = Product::get();
foreach ($list as $item) {
$seo = $item->seo_mate;
if ($seo) {
$seo['title'] = substr(strip_tags($seo['title']??''), 0, 70);
$seo['keyword'] = substr(strip_tags($seo['keyword']??''), 0, 255);
$seo['description'] = substr(strip_tags($seo['description']??''), 0, 200);
$item->seo_mate = Arr::a2s($seo);
try {
$item->save();
}catch (\Exception $e){
continue;
}
}
}
}
//关闭数据库
DB::disconnect('custom_mysql');
echo $project_id . '成功, product' . PHP_EOL;
$data = UpdateLog::where('api_type','website_info')->get();
foreach ($data as $item) {
UpdateVisit::createLog($item->project_id,$item->api_url);
echo $item->project_id . '成功' . PHP_EOL;
}
}
}
... ...
... ... @@ -197,7 +197,9 @@ class HtmlCollect extends Command
$img = $result_img[2] ?? [];
foreach ($img as $vi) {
$check_vi = $this->url_check($vi, $project_id, $domain, $web_url_domain, $home_url);
$check_vi && $source[] = $check_vi;
if ($check_vi && (!in_array($check_vi, $source))) {
$check_vi && $source[] = $check_vi;
}
}
//js
... ... @@ -205,7 +207,9 @@ class HtmlCollect extends Command
$js = $result_js[2] ?? [];
foreach ($js as $vj) {
$check_vj = $this->url_check($vj, $project_id, $domain, $web_url_domain, $home_url);
$check_vj && $source[] = $check_vj;
if ($check_vj && (!in_array($check_vj, $source))) {
$check_vj && $source[] = $check_vj;
}
}
//video
... ... @@ -213,7 +217,9 @@ class HtmlCollect extends Command
$video = $result_video[2] ?? [];
foreach ($video as $vv) {
$check_vv = $this->url_check($vv, $project_id, $domain, $web_url_domain, $home_url);
$check_vv && $source[] = $check_vv;
if ($check_vv && (!in_array($check_vv, $source))) {
$check_vv && $source[] = $check_vv;
}
}
//css
... ... @@ -221,7 +227,9 @@ class HtmlCollect extends Command
$css = $result_css[2] ?? [];
foreach ($css as $vc) {
$check_vc = $this->url_check($vc, $project_id, $domain, $web_url_domain, $home_url);
$check_vc && $source[] = $check_vc;
if ($check_vc && (!in_array($check_vc, $source))) {
$check_vc && $source[] = $check_vc;
}
}
//css background
... ... @@ -229,7 +237,9 @@ class HtmlCollect extends Command
$css_b = $result_css_b[1] ?? [];
foreach ($css_b as $vc_b) {
$check_vc_b = $this->url_check($vc_b, $project_id, $domain, $web_url_domain, $home_url);
$check_vc_b && $source[] = $check_vc_b;
if ($check_vc_b && (!in_array($check_vc_b, $source))) {
$check_vc_b && $source[] = $check_vc_b;
}
}
//a标签下载资源
... ... @@ -237,7 +247,9 @@ class HtmlCollect extends Command
$down = $result_a[2] ?? [];
foreach ($down as $vd) {
$check_vd = $this->url_check($vd, $project_id, $domain, $web_url_domain, $home_url);
$check_vd && $source[] = $check_vd;
if ($check_vd && (!in_array($check_vd, $source))) {
$check_vd && $source[] = $check_vd;
}
}
return $source;
... ...
... ... @@ -10,6 +10,7 @@ use App\Models\RouteMap\RouteMap;
use App\Services\CosService;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
... ... @@ -78,7 +79,8 @@ class HtmlLanguageCollect extends Command
$collect_info->save();
//获取站点正式和测试域名
$old_info = UpdateOldInfo::getOldDomain($project_id, $collect_info->domain);
$domain_en = $this->get_domain_en($project_id);
$old_info = UpdateOldInfo::getOldDomain($project_id, $domain_en);
//采集html页面,下载资源到本地并替换
try {
... ... @@ -99,10 +101,10 @@ class HtmlLanguageCollect extends Command
$new_html = str_replace($v64, '', $new_html);
}
$source_list = $this->html_preg($new_html, $project_id, $collect_info->domain, $old_info['web_url_domain'], $old_info['home_url']);
$source_list = $this->html_preg($new_html, $project_id, $domain_en, $old_info['web_url_domain'], $old_info['home_url']);
if ($source_list) {
$html = $this->upload_source($html, $source_list, $project_id, $collect_info->domain, $old_info['web_url_domain'], $old_info['home_url']);
$html = $this->upload_source($html, $source_list, $project_id, $domain_en, $old_info['web_url_domain'], $old_info['home_url']);
}
} catch (\Exception $e) {
$collect_info->status = CollectTask::STATUS_FAIL;
... ... @@ -183,6 +185,20 @@ class HtmlLanguageCollect extends Command
return $task_id;
}
//获取英文站域名
protected function get_domain_en($project_id)
{
$key = 'console_html_language_domain_en';
$domain = Cache::get($key);
if (!$domain) {
$domain = CollectTask::where('project_id', $project_id)->where('language', '')->value('domain');
Cache::add($key, $domain, 3600);
}
return $domain;
}
//正则匹配html资源
protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url)
{
... ... @@ -197,7 +213,9 @@ class HtmlLanguageCollect extends Command
$img = $result_img[2] ?? [];
foreach ($img as $vi) {
$check_vi = $this->url_check($vi, $project_id, $domain, $web_url_domain, $home_url);
$check_vi && $source[] = $check_vi;
if ($check_vi && (!in_array($check_vi, $source))) {
$check_vi && $source[] = $check_vi;
}
}
//js
... ... @@ -205,7 +223,9 @@ class HtmlLanguageCollect extends Command
$js = $result_js[2] ?? [];
foreach ($js as $vj) {
$check_vj = $this->url_check($vj, $project_id, $domain, $web_url_domain, $home_url);
$check_vj && $source[] = $check_vj;
if ($check_vj && (!in_array($check_vj, $source))) {
$check_vj && $source[] = $check_vj;
}
}
//video
... ... @@ -213,7 +233,9 @@ class HtmlLanguageCollect extends Command
$video = $result_video[2] ?? [];
foreach ($video as $vv) {
$check_vv = $this->url_check($vv, $project_id, $domain, $web_url_domain, $home_url);
$check_vv && $source[] = $check_vv;
if ($check_vv && (!in_array($check_vv, $source))) {
$check_vv && $source[] = $check_vv;
}
}
//css
... ... @@ -221,7 +243,9 @@ class HtmlLanguageCollect extends Command
$css = $result_css[2] ?? [];
foreach ($css as $vc) {
$check_vc = $this->url_check($vc, $project_id, $domain, $web_url_domain, $home_url);
$check_vc && $source[] = $check_vc;
if ($check_vc && (!in_array($check_vc, $source))) {
$check_vc && $source[] = $check_vc;
}
}
//css background
... ... @@ -229,7 +253,9 @@ class HtmlLanguageCollect extends Command
$css_b = $result_css_b[1] ?? [];
foreach ($css_b as $vc_b) {
$check_vc_b = $this->url_check($vc_b, $project_id, $domain, $web_url_domain, $home_url);
$check_vc_b && $source[] = $check_vc_b;
if ($check_vc_b && (!in_array($check_vc_b, $source))) {
$check_vc_b && $source[] = $check_vc_b;
}
}
//a标签下载资源
... ... @@ -237,7 +263,9 @@ class HtmlLanguageCollect extends Command
$down = $result_a[2] ?? [];
foreach ($down as $vd) {
$check_vd = $this->url_check($vd, $project_id, $domain, $web_url_domain, $home_url);
$check_vd && $source[] = $check_vd;
if ($check_vd && (!in_array($check_vd, $source))) {
$check_vd && $source[] = $check_vd;
}
}
return $source;
... ...
... ... @@ -94,6 +94,10 @@ class ProjectVisit extends Command
if (isset($item['id']) && $item['id']) {
if ($item['id'] > $task->max_id) {
$url_arr = parse_url($item['request'] ?? '');
$domain = $url_arr['host'] ?? '';
if(strlen($domain) > 50){
continue;
}
$insert[] = [
'url' => $item['request'] ?? '',
'referrer_url' => $item['referrer'] ?? '',
... ... @@ -101,7 +105,7 @@ class ProjectVisit extends Command
'country' => $item['ip_area'] ?? '',
'ip' => $item['ip'] ?? '',
'depth' => $item['pv'],
'domain' => $url_arr['host'] ?? '',
'domain' => $domain,
'is_inquiry' => $item['is_cf'] ?? 0,
'created_at' => date('Y-m-d H:i:s', isset($item['update']) && $item['update'] ? $item['update'] : time()),
'updated_at' => date('Y-m-d H:i:s', isset($item['update']) && $item['update'] ? $item['update'] : time()),
... ...
... ... @@ -14,7 +14,10 @@ use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Bside\CustomModule\CustomModuleExtendLogic;
use App\Models\CustomModule\CustomModuleExtend;
use App\Models\CustomModule\CustomModuleExtentContent;
<<<<<<< HEAD
use App\Models\Product\Extend;
=======
>>>>>>> 8cd12bff1a9683bab5e510abdf95218a42999a27
class CustomModuleExtentController extends BaseController
{
... ... @@ -84,6 +87,7 @@ class CustomModuleExtentController extends BaseController
}
/**
<<<<<<< HEAD
* @remark :获取扩展模块的扩展字段
* @name :lists
* @author :lyh
... ... @@ -100,4 +104,17 @@ class CustomModuleExtentController extends BaseController
$this->response('success',Code::SUCCESS,$lists);
}
=======
* @remark :
* @name :getExtendContentList
* @author :lyh
* @method :post
* @time :2023/12/20 15:21
*/
public function getExtendContentList(){
$extendContentModel = new CustomModuleExtentContent();
$lists = $extend->list($this->map);
$this->response('success',Code::SUCCESS,$lists);
}
>>>>>>> 8cd12bff1a9683bab5e510abdf95218a42999a27
}
... ...
... ... @@ -81,6 +81,7 @@ class CollectLogic extends Logic
$data =[];
foreach ($list['list'] as $item){
//关键词标签 没有就取seo 键词
$keyword = '';
if($item['keyword_id']){
$keyword = Keyword::whereIn('id', $item['keyword_id'])->pluck('title')->toArray();
if($keyword){
... ...
... ... @@ -36,12 +36,12 @@ class UpdateOldInfo extends Model
$web_url_arr = parse_url($data_config['web_url_domain'] ?? '');
$old_domain_online = $web_url_arr['host'] ?? '';
if ($link_type && $old_domain_test && $old_domain_online) {
if ($old_domain_test || $old_domain_online) {
$info = new self();
$info->project_id = $project_id;
$info->link_type = $link_type;
$info->old_domain_test = $old_domain_test;
$info->old_domain_online = $old_domain_online;
$info->old_domain_test = $old_domain_test ?: $domain;
$info->old_domain_online = $old_domain_online ?: $domain;
$info->save();
}
... ...
... ... @@ -12,4 +12,39 @@ class UpdateVisit extends Model
const STATUS_UN = 0;//未开始
const STATUS_ING = 1;//导入中
const STATUS_COM = 2;//导入完成
/**
* 创建更新日志
* @param $project_id
* @param $url
* @return mixed
*/
public static function createLog($project_id, $url)
{
$count = self::where('project_id', $project_id)->count('id');
if (!$count) {
$time = date('Y-m-d H:i:s');
$data = [
[
'project_id' => $project_id,
'api_type' => 'visit_list',
'api_url' => str_replace('update_v6.php?w=website_info&page=1&pagesize=20', 'extend_api.php', $url),
'sort' => 0,
'created_at' => $time,
'updated_at' => $time
],
[
'project_id' => $project_id,
'api_type' => 'visit_detail_list',
'api_url' => str_replace('update_v6.php?w=website_info&page=1&pagesize=20', 'extend_api.php', $url),
'sort' => 1,
'created_at' => $time,
'updated_at' => $time
]
];
return self::insert($data);
}
return true;
}
}
... ...