...
|
...
|
@@ -215,6 +215,7 @@ public function websiteHtml(Request $request) |
|
|
{
|
|
|
$domain = $request->getHost();
|
|
|
$site_token = $request->input('site_token');
|
|
|
$zip_count = $request->input('zip_count');
|
|
|
$token = env("SECRET_TOKEN");
|
|
|
$pid = env("MERCHANT_NUMBER");
|
|
|
$apiUrl = env("API_URL");
|
...
|
...
|
@@ -232,8 +233,7 @@ public function websiteHtml(Request $request) |
|
|
|
|
|
try {
|
|
|
$res = $this->curlGet($requestUrl);
|
|
|
$url = isset($res["data"]["url"]) && !empty($res["data"]["url"]) ? urldecode($res["data"]["url"]) : "";
|
|
|
if ($res["status"] != self::SUCCESS || $url == "") {
|
|
|
if ($res["status"] != self::SUCCESS) {
|
|
|
$msg = isset($res["message"]) && !empty($res["message"]) ? $res["message"] : "请求失败!";
|
|
|
return $this->error($msg);
|
|
|
}
|
...
|
...
|
@@ -242,32 +242,28 @@ public function websiteHtml(Request $request) |
|
|
}
|
|
|
|
|
|
$info = [
|
|
|
"url" => $url,
|
|
|
"domain" => $domain,
|
|
|
"num"=>0,
|
|
|
"zip_count" => $zip_count
|
|
|
];
|
|
|
$info = json_encode($info);
|
|
|
Redis::set('handle_html',$info);
|
|
|
Redis::set('handle_html', $info);
|
|
|
return $this->success();
|
|
|
//return $this->websiteHtmlHandle($url, $domain);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 网站html解压
|
|
|
* @param $url
|
|
|
* @param $zip_count
|
|
|
* @param $domain
|
|
|
* @return string
|
|
|
*/
|
|
|
public function websiteHtmlHandle($url, $domain)
|
|
|
public function websiteHtmlHandle($zip_count, $domain)
|
|
|
{
|
|
|
$pathInfo = pathinfo($url);
|
|
|
$extension = $pathInfo['extension'];
|
|
|
//只允许解压zip格式文件
|
|
|
if (in_array($extension, ["zip"])) {
|
|
|
try {
|
|
|
$targetFile = $this->downLoadFile($url);
|
|
|
if ($targetFile == ""){
|
|
|
return false;
|
|
|
$api_url = env('API_URL');
|
|
|
|
|
|
for ($i = 0; $i <= $zip_count; $i++) {
|
|
|
$targetFile = $this->downLoadFile($api_url . $domain . '_part' . $i . '.zip');
|
|
|
if ($targetFile == "") {
|
|
|
$this->output('文件 ' . $targetFile . ' 不存在');
|
|
|
continue;
|
|
|
}
|
|
|
$zip = new ZipArchive();
|
|
|
if ($zip->open($targetFile) === TRUE) {
|
...
|
...
|
@@ -279,23 +275,15 @@ public function websiteHtmlHandle($url, $domain) |
|
|
$zip->extractTo($outputFolder);
|
|
|
$zip->close();
|
|
|
$this->deleteDirectory($targetFile);
|
|
|
|
|
|
$transmitUrl = env("TRANSMIT_URL");
|
|
|
$this->httpPost($transmitUrl . "api/selfSiteNotify/", json_encode(['domain' => $domain]));
|
|
|
} else {
|
|
|
// 处理打开压缩文件失败的情况
|
|
|
$this->output("解压失败!");
|
|
|
return false;
|
|
|
$this->output('解压文件 ' . $targetFile . ' 失败');
|
|
|
continue;
|
|
|
}
|
|
|
} catch (\Exception $e) {
|
|
|
$this->output($this->error($e->getMessage()));
|
|
|
return false;
|
|
|
}
|
|
|
} else {
|
|
|
$this->output("不允许解压改格式压缩包!");
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
|
|
|
$transmitUrl = env("TRANSMIT_URL");
|
|
|
$this->httpPost($transmitUrl . "api/selfSiteNotify/", json_encode(['domain' => $domain]));
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -310,7 +298,7 @@ public function downLoadFile($url) |
|
|
mkdir($savePath, 0777, true);
|
|
|
}
|
|
|
$targetFile = $savePath . '/' . basename($url);
|
|
|
if(!file_exists($targetFile)){
|
|
|
if (!file_exists($targetFile)) {
|
|
|
$file = fopen($targetFile, 'w');
|
|
|
fclose($file);
|
|
|
chmod($targetFile, 0755);
|
...
|
...
|
|