作者 李小龙

a

@@ -141,33 +141,6 @@ public function uploadAmpVerifyFile(Request $request): string @@ -141,33 +141,6 @@ public function uploadAmpVerifyFile(Request $request): string
141 return $this->success(); 141 return $this->success();
142 } 142 }
143 143
144 - /**  
145 - * 压缩文件夹  
146 - */  
147 - public function createZipFile(){  
148 - $folderPath = public_path("target");  
149 - $zipFilePath = public_path().'/target.zip';  
150 - $zip = new ZipArchive();  
151 - if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) {  
152 - // 递归添加文件夹下的所有文件和子文件夹  
153 - $files = new RecursiveIteratorIterator(  
154 - new RecursiveDirectoryIterator($folderPath),  
155 - RecursiveIteratorIterator::LEAVES_ONLY  
156 - );  
157 - foreach ($files as $name => $file) {  
158 - if (!$file->isDir()) {  
159 - $filePath = $file->getRealPath();  
160 - $relativePath = substr($filePath, strlen($folderPath) + 1);  
161 - $zip->addFile($filePath, $relativePath);  
162 - }  
163 - }  
164 -  
165 - $zip->close();  
166 - echo '文件夹压缩成功';  
167 - } else {  
168 - echo '无法打开或创建压缩文件';  
169 - }  
170 - }  
171 144
172 /** 145 /**
173 * 获取需要下载的文件url 146 * 获取需要下载的文件url
@@ -181,6 +154,8 @@ public function websiteHtml(Request $request){ @@ -181,6 +154,8 @@ public function websiteHtml(Request $request){
181 $token = env("WEB_SITE_TOKEN"); 154 $token = env("WEB_SITE_TOKEN");
182 $apiUrl = env("API_URL"); 155 $apiUrl = env("API_URL");
183 $requestUrl = $apiUrl."?domain=".$domain."&token=".$token; 156 $requestUrl = $apiUrl."?domain=".$domain."&token=".$token;
  157 + @file_put_contents(storage_path('logs/notify_get_url.log'), date('Y-m-d H:i:s') . "接收到通知:". $requestUrl . PHP_EOL, FILE_APPEND);
  158 +
184 159
185 try { 160 try {
186 $res = $this->curlGet($requestUrl); 161 $res = $this->curlGet($requestUrl);
@@ -192,44 +167,44 @@ public function websiteHtml(Request $request){ @@ -192,44 +167,44 @@ public function websiteHtml(Request $request){
192 } catch (\Exception $e) { 167 } catch (\Exception $e) {
193 return $this->error($e->getMessage()); 168 return $this->error($e->getMessage());
194 } 169 }
195 - return $this->websiteHtmlHandle($url); 170 + return $this->websiteHtmlHandle($url,$domain);
196 } 171 }
197 172
198 - /**  
199 - * 网站html解压  
200 - * @param $url  
201 - * @return string  
202 - */  
203 - public function websiteHtmlHandle($url)  
204 - {  
205 - $pathInfo = pathinfo($url);  
206 - $extension = $pathInfo['extension'];  
207 - //只允许解压zip格式文件  
208 - if (in_array($extension, ["zip"])) {  
209 - try {  
210 - $targetFile = $this->downLoadFile($url);  
211 - $zip = new ZipArchive();  
212 - if ($zip->open($targetFile) === TRUE) {  
213 - $outputFolder = public_path();  
214 - if (!is_dir($outputFolder)) {  
215 - mkdir($outputFolder, 0777, true);  
216 - }  
217 - // 解压缩文件,保留原文件结构  
218 - $zip->extractTo($outputFolder);  
219 - $zip->close();  
220 - $this->deleteDirectory($targetFile);  
221 - } else {  
222 - return $this->error('解压失败!');  
223 - // 处理打开压缩文件失败的情况 173 +/**
  174 + * 网站html解压
  175 + * @param $url
  176 + * @return string
  177 + */
  178 +public function websiteHtmlHandle($url,$domain)
  179 +{
  180 + $pathInfo = pathinfo($url);
  181 + $extension = $pathInfo['extension'];
  182 + //只允许解压zip格式文件
  183 + if (in_array($extension, ["zip"])) {
  184 + try {
  185 + $targetFile = $this->downLoadFile($url);
  186 + $zip = new ZipArchive();
  187 + if ($zip->open($targetFile) === TRUE) {
  188 + $outputFolder = public_path($domain);
  189 + if (!is_dir($outputFolder)) {
  190 + mkdir($outputFolder, 0777, true);
224 } 191 }
225 - } catch (\Exception $e) {  
226 - return $this->error($e->getMessage()); 192 + // 解压缩文件,保留原文件结构
  193 + $zip->extractTo($outputFolder);
  194 + $zip->close();
  195 + $this->deleteDirectory($targetFile);
  196 + } else {
  197 + return $this->error('解压失败!');
  198 + // 处理打开压缩文件失败的情况
227 } 199 }
228 - }else{  
229 - return $this->error('不允许解压改格式压缩包!'); 200 + } catch (\Exception $e) {
  201 + return $this->error($e->getMessage());
230 } 202 }
231 - return $this->success(); 203 + }else{
  204 + return $this->error('不允许解压改格式压缩包!');
232 } 205 }
  206 + return $this->success();
  207 +}
233 208
234 /** 209 /**
235 * 下载文件(下载到public目录下) 210 * 下载文件(下载到public目录下)