Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
5 个修改的文件
包含
77 行增加
和
103 行删除
| @@ -9,7 +9,6 @@ use App\Models\RouteMap\RouteMap; | @@ -9,7 +9,6 @@ use App\Models\RouteMap\RouteMap; | ||
| 9 | use App\Services\CosService; | 9 | use App\Services\CosService; |
| 10 | use App\Services\ProjectServer; | 10 | use App\Services\ProjectServer; |
| 11 | use Illuminate\Console\Command; | 11 | use Illuminate\Console\Command; |
| 12 | -use Illuminate\Support\Facades\Cache; | ||
| 13 | use Illuminate\Support\Facades\DB; | 12 | use Illuminate\Support\Facades\DB; |
| 14 | use Illuminate\Support\Facades\Redis; | 13 | use Illuminate\Support\Facades\Redis; |
| 15 | 14 | ||
| @@ -77,8 +76,8 @@ class HtmlCollect extends Command | @@ -77,8 +76,8 @@ class HtmlCollect extends Command | ||
| 77 | $collect_info->status = CollectTask::STATUS_ING; | 76 | $collect_info->status = CollectTask::STATUS_ING; |
| 78 | $collect_info->save(); | 77 | $collect_info->save(); |
| 79 | 78 | ||
| 80 | - //获取站点正式和测试域名 | ||
| 81 | - $old_info = $this->getOldDomain($project_id, $collect_info->domain); | 79 | + //获取站点原始域名信息 |
| 80 | + $old_info = getOldDomain($project_id, $collect_info->domain); | ||
| 82 | 81 | ||
| 83 | //采集html页面,下载资源到本地并替换 | 82 | //采集html页面,下载资源到本地并替换 |
| 84 | try { | 83 | try { |
| @@ -183,42 +182,6 @@ class HtmlCollect extends Command | @@ -183,42 +182,6 @@ class HtmlCollect extends Command | ||
| 183 | return $task_id; | 182 | return $task_id; |
| 184 | } | 183 | } |
| 185 | 184 | ||
| 186 | - //获取站点老域名 | ||
| 187 | - protected function getOldDomain($project_id, $domain) | ||
| 188 | - { | ||
| 189 | - $key = 'project_collect_domain_' . $project_id; | ||
| 190 | - | ||
| 191 | - $data = Cache::get($key); | ||
| 192 | - | ||
| 193 | - if (!$data) { | ||
| 194 | - $web_url_domain = $domain; | ||
| 195 | - $home_url = $domain; | ||
| 196 | - | ||
| 197 | - $url_web_config = 'https://' . $domain . '/wp-content/cache/user_config.text'; | ||
| 198 | - $data_config = curl_c($url_web_config); | ||
| 199 | - if ($data_config) { | ||
| 200 | - $web_url_arr = parse_url($data_config['web_url_domain'] ?? ''); | ||
| 201 | - if (isset($web_url_arr['host'])) { | ||
| 202 | - $web_url_domain = $web_url_arr['host']; | ||
| 203 | - } | ||
| 204 | - | ||
| 205 | - $home_url_arr = parse_url($data_config['home_url'] ?? ''); | ||
| 206 | - if (isset($home_url_arr['host'])) { | ||
| 207 | - $home_url = $home_url_arr['host']; | ||
| 208 | - } | ||
| 209 | - } | ||
| 210 | - | ||
| 211 | - $data = [ | ||
| 212 | - 'web_url_domain' => $web_url_domain, | ||
| 213 | - 'home_url' => $home_url, | ||
| 214 | - ]; | ||
| 215 | - | ||
| 216 | - Cache::add($key, $data, 3600);//缓存1小时 | ||
| 217 | - } | ||
| 218 | - | ||
| 219 | - return $data; | ||
| 220 | - } | ||
| 221 | - | ||
| 222 | //正则匹配html资源 | 185 | //正则匹配html资源 |
| 223 | protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url) | 186 | protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url) |
| 224 | { | 187 | { |
| @@ -9,7 +9,6 @@ use App\Models\RouteMap\RouteMap; | @@ -9,7 +9,6 @@ use App\Models\RouteMap\RouteMap; | ||
| 9 | use App\Services\CosService; | 9 | use App\Services\CosService; |
| 10 | use App\Services\ProjectServer; | 10 | use App\Services\ProjectServer; |
| 11 | use Illuminate\Console\Command; | 11 | use Illuminate\Console\Command; |
| 12 | -use Illuminate\Support\Facades\Cache; | ||
| 13 | use Illuminate\Support\Facades\DB; | 12 | use Illuminate\Support\Facades\DB; |
| 14 | use Illuminate\Support\Facades\Redis; | 13 | use Illuminate\Support\Facades\Redis; |
| 15 | 14 | ||
| @@ -78,7 +77,7 @@ class HtmlLanguageCollect extends Command | @@ -78,7 +77,7 @@ class HtmlLanguageCollect extends Command | ||
| 78 | $collect_info->save(); | 77 | $collect_info->save(); |
| 79 | 78 | ||
| 80 | //获取站点正式和测试域名 | 79 | //获取站点正式和测试域名 |
| 81 | - $old_info = $this->getOldDomain($project_id, $collect_info->domain); | 80 | + $old_info = getOldDomain($project_id, $collect_info->domain); |
| 82 | 81 | ||
| 83 | //采集html页面,下载资源到本地并替换 | 82 | //采集html页面,下载资源到本地并替换 |
| 84 | try { | 83 | try { |
| @@ -183,42 +182,6 @@ class HtmlLanguageCollect extends Command | @@ -183,42 +182,6 @@ class HtmlLanguageCollect extends Command | ||
| 183 | return $task_id; | 182 | return $task_id; |
| 184 | } | 183 | } |
| 185 | 184 | ||
| 186 | - //获取站点老域名 | ||
| 187 | - protected function getOldDomain($project_id, $domain) | ||
| 188 | - { | ||
| 189 | - $key = 'project_collect_lan_domain_' . $project_id; | ||
| 190 | - | ||
| 191 | - $data = Cache::get($key); | ||
| 192 | - | ||
| 193 | - if (!$data) { | ||
| 194 | - $web_url_domain = $domain; | ||
| 195 | - $home_url = $domain; | ||
| 196 | - | ||
| 197 | - $url_web_config = 'https://' . $domain . '/wp-content/cache/user_config.text'; | ||
| 198 | - $data_config = curl_c($url_web_config); | ||
| 199 | - if ($data_config) { | ||
| 200 | - $web_url_arr = parse_url($data_config['web_url_domain'] ?? ''); | ||
| 201 | - if (isset($web_url_arr['host'])) { | ||
| 202 | - $web_url_domain = $web_url_arr['host']; | ||
| 203 | - } | ||
| 204 | - | ||
| 205 | - $home_url_arr = parse_url($data_config['home_url'] ?? ''); | ||
| 206 | - if (isset($home_url_arr['host'])) { | ||
| 207 | - $home_url = $home_url_arr['host']; | ||
| 208 | - } | ||
| 209 | - } | ||
| 210 | - | ||
| 211 | - $data = [ | ||
| 212 | - 'web_url_domain' => $web_url_domain, | ||
| 213 | - 'home_url' => $home_url, | ||
| 214 | - ]; | ||
| 215 | - | ||
| 216 | - Cache::add($key, $data, 3600);//缓存1小时 | ||
| 217 | - } | ||
| 218 | - | ||
| 219 | - return $data; | ||
| 220 | - } | ||
| 221 | - | ||
| 222 | //正则匹配html资源 | 185 | //正则匹配html资源 |
| 223 | protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url) | 186 | protected function html_preg($html, $project_id, $domain, $web_url_domain, $home_url) |
| 224 | { | 187 | { |
| @@ -73,6 +73,7 @@ class ProjectUpdate extends Command | @@ -73,6 +73,7 @@ class ProjectUpdate extends Command | ||
| 73 | $api_type = $task->api_type; | 73 | $api_type = $task->api_type; |
| 74 | $api_url_arr = explode('?', $task->api_url); | 74 | $api_url_arr = explode('?', $task->api_url); |
| 75 | $api_url = $api_url_arr[0]; | 75 | $api_url = $api_url_arr[0]; |
| 76 | + $domain_arr = parse_url($api_url); | ||
| 76 | 77 | ||
| 77 | $page_size = 20; | 78 | $page_size = 20; |
| 78 | 79 | ||
| @@ -81,26 +82,12 @@ class ProjectUpdate extends Command | @@ -81,26 +82,12 @@ class ProjectUpdate extends Command | ||
| 81 | $task->status = UpdateLog::STATUS_ING;//同步中 | 82 | $task->status = UpdateLog::STATUS_ING;//同步中 |
| 82 | $task->save(); | 83 | $task->save(); |
| 83 | 84 | ||
| 84 | - $domain_arr = parse_url($api_url); | ||
| 85 | - //获取网站配置 | ||
| 86 | - $link_type = 0; | ||
| 87 | - $web_url_domain = $domain_arr['host']; | ||
| 88 | - $home_url = $domain_arr['host']; | ||
| 89 | - $url_web_config = 'https://' . $domain_arr['host'] . '/wp-content/cache/user_config.text'; | ||
| 90 | - $data_config = curl_c($url_web_config); | ||
| 91 | - if ($data_config) { | ||
| 92 | - $link_type = $data_config['link_type'] ?? 0; | ||
| 93 | - | ||
| 94 | - $web_url_arr = parse_url($data_config['web_url_domain'] ?? ''); | ||
| 95 | - if (isset($web_url_arr['host'])) { | ||
| 96 | - $web_url_domain = $web_url_arr['host']; | ||
| 97 | - } | 85 | + //获取站点原始域名信息 |
| 86 | + $old_info = getOldDomain($project_id, $domain_arr['host']); | ||
| 87 | + $link_type = $old_info['link_type']; | ||
| 88 | + $web_url_domain = $old_info['web_url_domain']; | ||
| 89 | + $home_url = $old_info['home_url']; | ||
| 98 | 90 | ||
| 99 | - $home_url_arr = parse_url($data_config['home_url'] ?? ''); | ||
| 100 | - if (isset($home_url_arr['host'])) { | ||
| 101 | - $home_url = $home_url_arr['host']; | ||
| 102 | - } | ||
| 103 | - } | ||
| 104 | //获取所有语种 | 91 | //获取所有语种 |
| 105 | $language_list = []; | 92 | $language_list = []; |
| 106 | $url_language = 'https://' . $domain_arr['host'] . '/wp-content/plugins/proofreading/json/user_language.json'; | 93 | $url_language = 'https://' . $domain_arr['host'] . '/wp-content/plugins/proofreading/json/user_language.json'; |
| @@ -108,6 +95,7 @@ class ProjectUpdate extends Command | @@ -108,6 +95,7 @@ class ProjectUpdate extends Command | ||
| 108 | if ($data_language) { | 95 | if ($data_language) { |
| 109 | $language_list = array_column($data_language, 'short'); | 96 | $language_list = array_column($data_language, 'short'); |
| 110 | } | 97 | } |
| 98 | + | ||
| 111 | //获取所有页面 | 99 | //获取所有页面 |
| 112 | $page_list = []; | 100 | $page_list = []; |
| 113 | $url_page = 'https://' . $domain_arr['host'] . '/wp-content/cache/pages_list.json'; | 101 | $url_page = 'https://' . $domain_arr['host'] . '/wp-content/cache/pages_list.json'; |
| @@ -480,16 +468,19 @@ class ProjectUpdate extends Command | @@ -480,16 +468,19 @@ class ProjectUpdate extends Command | ||
| 480 | //获取地址路由 | 468 | //获取地址路由 |
| 481 | protected function get_url_route($url) | 469 | protected function get_url_route($url) |
| 482 | { | 470 | { |
| 483 | - $arr = parse_url(urldecode($url)); | 471 | + if (strpos($url, '%ec') !== false) { |
| 472 | + $url = str_replace('%ec', 'v6SpecialStr', $url); | ||
| 473 | + $url = urldecode($url); | ||
| 474 | + $url = str_replace('v6SpecialStr', '%ec', $url); | ||
| 475 | + } else { | ||
| 476 | + $url = urldecode($url); | ||
| 477 | + } | ||
| 478 | + $arr = parse_url($url); | ||
| 484 | if (empty($arr['path'])) { | 479 | if (empty($arr['path'])) { |
| 485 | return ''; | 480 | return ''; |
| 486 | } | 481 | } |
| 487 | $path = $arr['path']; | 482 | $path = $arr['path']; |
| 488 | 483 | ||
| 489 | - if (strpos($path, '.') !== false) { | ||
| 490 | - $path = substr($path, 0, strpos($path, '.')); | ||
| 491 | - } | ||
| 492 | - | ||
| 493 | $path_arr = explode('/', $path); | 484 | $path_arr = explode('/', $path); |
| 494 | 485 | ||
| 495 | return end($path_arr) ? end($path_arr) : $path_arr[count($path_arr) - 2]; | 486 | return end($path_arr) ? end($path_arr) : $path_arr[count($path_arr) - 2]; |
| @@ -623,8 +614,11 @@ class ProjectUpdate extends Command | @@ -623,8 +614,11 @@ class ProjectUpdate extends Command | ||
| 623 | 614 | ||
| 624 | $url_complete = ($scheme ?: 'https') . '://' . ($host ?: $domain) . $path; | 615 | $url_complete = ($scheme ?: 'https') . '://' . ($host ?: $domain) . $path; |
| 625 | 616 | ||
| 626 | - if ((empty($host) || $host == $web_url_domain || $host == $home_url) && $path) { | ||
| 627 | - | 617 | + if ( |
| 618 | + (empty($scheme) || $scheme == 'https' || $scheme == 'http') | ||
| 619 | + && (empty($host) || (strpos($web_url_domain, $host) !== false) || (strpos($home_url, $host) !== false)) | ||
| 620 | + && $path | ||
| 621 | + ) { | ||
| 628 | $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first(); | 622 | $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first(); |
| 629 | if (!$source) { | 623 | if (!$source) { |
| 630 | $new_url = CosService::uploadRemote($project_id, 'image_product', $url_complete); | 624 | $new_url = CosService::uploadRemote($project_id, 'image_product', $url_complete); |
| @@ -9,6 +9,7 @@ use GuzzleHttp\Client; | @@ -9,6 +9,7 @@ use GuzzleHttp\Client; | ||
| 9 | use GuzzleHttp\Exception\GuzzleException; | 9 | use GuzzleHttp\Exception\GuzzleException; |
| 10 | use Illuminate\Support\Carbon; | 10 | use Illuminate\Support\Carbon; |
| 11 | use App\Models\File\File; | 11 | use App\Models\File\File; |
| 12 | +use Illuminate\Support\Facades\Cache; | ||
| 12 | use Illuminate\Support\Facades\Redis; | 13 | use Illuminate\Support\Facades\Redis; |
| 13 | 14 | ||
| 14 | define('HTTP_OPENAI_URL', 'http://openai.waimaoq.com/'); | 15 | define('HTTP_OPENAI_URL', 'http://openai.waimaoq.com/'); |
| @@ -654,6 +655,7 @@ function redis_add($key,$val,$ttl=3600){ | @@ -654,6 +655,7 @@ function redis_add($key,$val,$ttl=3600){ | ||
| 654 | * 判断远程地址是否需要下载 | 655 | * 判断远程地址是否需要下载 |
| 655 | * @param $url | 656 | * @param $url |
| 656 | * @author Akun | 657 | * @author Akun |
| 658 | + * @return bool | ||
| 657 | * @date 2023/12/08 14:17 | 659 | * @date 2023/12/08 14:17 |
| 658 | */ | 660 | */ |
| 659 | function check_remote_url_down($url){ | 661 | function check_remote_url_down($url){ |
| @@ -689,3 +691,50 @@ function check_remote_url_down($url){ | @@ -689,3 +691,50 @@ function check_remote_url_down($url){ | ||
| 689 | 691 | ||
| 690 | return true; | 692 | return true; |
| 691 | } | 693 | } |
| 694 | + | ||
| 695 | +/** | ||
| 696 | + * 获取升级项目原始域名 | ||
| 697 | + * @param $project_id | ||
| 698 | + * @param $domain | ||
| 699 | + * @return array | ||
| 700 | + * @author Akun | ||
| 701 | + * @date 2023/12/12 10:52 | ||
| 702 | + */ | ||
| 703 | +function getOldDomain($project_id, $domain) | ||
| 704 | +{ | ||
| 705 | + $key = 'project_collect_domain_' . $project_id; | ||
| 706 | + | ||
| 707 | + $data = Cache::get($key); | ||
| 708 | + | ||
| 709 | + if (!$data) { | ||
| 710 | + $link_type = 0; | ||
| 711 | + $web_url_domain = $domain; | ||
| 712 | + $home_url = $domain; | ||
| 713 | + | ||
| 714 | + $url_web_config = 'https://' . $domain . '/wp-content/cache/user_config.text'; | ||
| 715 | + $data_config = curl_c($url_web_config); | ||
| 716 | + if ($data_config) { | ||
| 717 | + $link_type = $data_config['link_type'] ?? 0; | ||
| 718 | + | ||
| 719 | + $web_url_arr = parse_url($data_config['web_url_domain'] ?? ''); | ||
| 720 | + if (isset($web_url_arr['host'])) { | ||
| 721 | + $web_url_domain = $web_url_arr['host']; | ||
| 722 | + } | ||
| 723 | + | ||
| 724 | + $home_url_arr = parse_url($data_config['home_url'] ?? ''); | ||
| 725 | + if (isset($home_url_arr['host'])) { | ||
| 726 | + $home_url = $home_url_arr['host']; | ||
| 727 | + } | ||
| 728 | + } | ||
| 729 | + | ||
| 730 | + $data = [ | ||
| 731 | + 'link_type' => $link_type, | ||
| 732 | + 'web_url_domain' => $web_url_domain, | ||
| 733 | + 'home_url' => $home_url, | ||
| 734 | + ]; | ||
| 735 | + | ||
| 736 | + Cache::add($key, $data, 3600);//缓存1小时 | ||
| 737 | + } | ||
| 738 | + | ||
| 739 | + return $data; | ||
| 740 | +} |
| @@ -95,6 +95,11 @@ class InquiryLogic extends BaseLogic | @@ -95,6 +95,11 @@ class InquiryLogic extends BaseLogic | ||
| 95 | ->select($fields)->orderBy('id', 'desc')->paginate($page_size, ['*'], 'page', $page); | 95 | ->select($fields)->orderBy('id', 'desc')->paginate($page_size, ['*'], 'page', $page); |
| 96 | $data = $lists->toArray(); | 96 | $data = $lists->toArray(); |
| 97 | foreach ($data['list'] as &$v){ | 97 | foreach ($data['list'] as &$v){ |
| 98 | + foreach ($v['data'] as &$field){ | ||
| 99 | + if(is_array($field) && !empty($field['path'])){ | ||
| 100 | + $field['path'] = getImageUrl($field['path']); | ||
| 101 | + } | ||
| 102 | + } | ||
| 98 | $v = array_merge($v, $v['data']); | 103 | $v = array_merge($v, $v['data']); |
| 99 | } | 104 | } |
| 100 | return $this->success($data); | 105 | return $this->success($data); |
-
请 注册 或 登录 后发表评论