作者 lyh
... ... @@ -102,7 +102,7 @@ class HtmlCollect extends Command
$source_list = $this->html_preg($new_html, $project_id, $collect_info->domain, $old_info['web_url_domain'], $old_info['home_url']);
if ($source_list) {
$html = $this->upload_source($html, $source_list, $project_id);
$html = $this->upload_source($html, $source_list, $project_id, $collect_info->domain, $old_info['web_url_domain'], $old_info['home_url']);
}
} catch (\Exception $e) {
$collect_info->status = CollectTask::STATUS_FAIL;
... ... @@ -321,7 +321,7 @@ class HtmlCollect extends Command
}
//下载并替换资源
protected function upload_source($html, $source, $project_id)
protected function upload_source($html, $source, $project_id, $domain, $web_url_domain, $home_url)
{
foreach ($source as $vs) {
... ... @@ -337,21 +337,17 @@ class HtmlCollect extends Command
]);
$html = str_replace($vs['url'], getImageUrl($new_source), $html);
if (substr($new_source, -3, 3) == 'css' || substr($new_source, -2, 2) == 'js') {
$source_html = curl_c($vs['url_complete'], false);
if (substr($new_source, -3, 3) == 'css') {
preg_match_all("/url\(['\"](\s*[^>]+?)['\"]\)/i", $source_html, $result_source);
} else {
preg_match_all("/[large|thumb]+URL:['\"]+(\s*[^>]+?)['\"]+,/i", $source_html, $result_source);
}
$source_list = $result_source[1] ?? [];
if (substr($new_source, -3, 3) == 'css') {
// 下载css文件中的资源
$css_html = curl_c($vs['url_complete'], false);
preg_match_all("/url\(['\"](\s*[^>]+?)['\"]\)/i", $css_html, $result_css_source);
$css_source = $result_css_source[1] ?? [];
$url_arr = explode('/', $vs['url_complete']);
$target_arr = explode('/', $new_source);
foreach ($source_list as $vcs) {
foreach ($css_source as $vcs) {
$vcs = str_replace('"', '', $vcs);
$vcs_arr = parse_url($vcs);
if (isset($vcs_arr['domain'])) {
//不是相对路径,不下载
continue;
... ... @@ -391,6 +387,34 @@ class HtmlCollect extends Command
]);
}
}
} elseif (substr($new_source, -2, 2) == 'js') {
$js_html = curl_c(getImageUrl($new_source), false);
preg_match_all("/[large|thumb]+URL:['\"]+(\s*[^>]+?)['\"]+,/i", $js_html, $result_js_source);
$js_source = $result_js_source[1] ?? [];
foreach ($js_source as $vjs) {
$vjs_result = $this->url_check($vjs, $project_id, $domain, $web_url_domain, $home_url);
if (!$vjs_result) {
continue;
}
if ($vjs_result['download']) {
$new_vjs = CosService::uploadRemote($project_id, 'source', $vjs_result['url_complete']);
if ($new_vjs) {
CollectSource::insert([
'project_id' => $project_id,
'origin' => $vjs_result['url'],
'target' => $new_vjs,
'created_at' => date('Y-m-d H:i:s'),
'updated_at' => date('Y-m-d H:i:s'),
]);
$js_html = str_replace($vjs, getImageUrl($new_vjs), $js_html);
}
} else {
$js_html = str_replace($vjs, getImageUrl($vjs_result['url_complete']), $js_html);
}
}
CosService::uploadRemote($project_id, 'source', $new_source, $new_source, $js_html);
}
}
} else {
... ...
... ... @@ -544,6 +544,20 @@ class ProjectController extends BaseController
$this->map['entry_position'] = ['in',$this->map['entry_position']];
}
$lists = $hrManagerModel->list($this->map,'id',['id','manage_id','name','entry_position','is_leader']);
//zgj 售后技术排序调整 start
if(isset($this->map['entry_position'][1]) && in_array(45,$this->map['entry_position'][1])){
$ar_sort = ['王娇'=>1,'银蝶'=>2,'胡哲'=>3,'郭婷婷'=>4,'徐庆'=>5,'邓锦康'=>6,'兰波'=>7];
foreach ($lists as $k=>$v){
$lists[$k]['sort'] = 0;
if(in_array($v['name'],array_keys($ar_sort))){
$lists[$k]['sort'] = $ar_sort[$v['name']];
}
}
$sort_arr = array_column($lists, 'sort');
array_multisort($sort_arr,SORT_DESC,$lists);
}
//售后技术排序调整 end
$this->response('success',Code::SUCCESS,$lists);
}
... ...
... ... @@ -69,11 +69,12 @@ class CosService
* @param $image_type
* @param $file_url
* @param $key
* @param $body_str
* @return string
* @author Akun
* @date 2023/09/21 9:39
*/
public static function uploadRemote($project_id,$image_type,$file_url,$key='')
public static function uploadRemote($project_id,$image_type,$file_url,$key='',$body_str='')
{
if(!$key){
$url_arr = parse_url($file_url);
... ... @@ -96,7 +97,7 @@ class CosService
]);
try {
$body = curl_c($file_url,false);
$body = $body_str ?:curl_c($file_url,false);
}catch (\Exception $e){
return '';
}
... ...