...
|
...
|
@@ -12,6 +12,8 @@ |
|
|
use Illuminate\Http\JsonResponse;
|
|
|
use Illuminate\Http\Request;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
use RecursiveDirectoryIterator;
|
|
|
use RecursiveIteratorIterator;
|
|
|
use ZipArchive;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -140,14 +142,42 @@ public function uploadAmpVerifyFile(Request $request): string |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 压缩文件夹
|
|
|
*/
|
|
|
public function createZipFile(){
|
|
|
$folderPath = public_path("target");
|
|
|
$zipFilePath = public_path().'/target.zip';
|
|
|
$zip = new ZipArchive();
|
|
|
if ($zip->open($zipFilePath, ZipArchive::CREATE | ZipArchive::OVERWRITE) === TRUE) {
|
|
|
// 递归添加文件夹下的所有文件和子文件夹
|
|
|
$files = new RecursiveIteratorIterator(
|
|
|
new RecursiveDirectoryIterator($folderPath),
|
|
|
RecursiveIteratorIterator::LEAVES_ONLY
|
|
|
);
|
|
|
foreach ($files as $name => $file) {
|
|
|
if (!$file->isDir()) {
|
|
|
$filePath = $file->getRealPath();
|
|
|
$relativePath = substr($filePath, strlen($folderPath) + 1);
|
|
|
$zip->addFile($filePath, $relativePath);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$zip->close();
|
|
|
echo '文件夹压缩成功';
|
|
|
} else {
|
|
|
echo '无法打开或创建压缩文件';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取需要下载的文件url
|
|
|
* @param Request $request
|
|
|
* @return string
|
|
|
*/
|
|
|
public function websiteHtml(Request $request){
|
|
|
// $domain = $request->getHost();
|
|
|
$domain = $request->getHost();
|
|
|
//临时测试域名
|
|
|
$domain = "v6-1x28w.globalso.site";
|
|
|
// $domain = "v6-1x28w.globalso.site";
|
|
|
$token = env("WEB_SITE_TOKEN");
|
|
|
$apiUrl = env("API_URL");
|
|
|
$requestUrl = $apiUrl."?domain=".$domain."&token=".$token;
|
...
|
...
|
|