feat(版本管理): 添加应用版本列表功能
- 在GUI中添加查看全部版本按钮和版本列表窗口 - 实现API接口获取应用版本列表数据 - 优化文件下载路径处理,解决open_basedir限制问题 - 重构分页控件布局,增加弹性空间
This commit is contained in:
@@ -145,31 +145,25 @@ while ($row = $result->fetch_assoc()) {
|
||||
</div>
|
||||
<div class="card-footer bg-transparent d-flex justify-content-between align-items-center">
|
||||
<?php
|
||||
// 简化路径处理以避免open_basedir限制问题
|
||||
$originalFilePath = trim($version['file_path']);
|
||||
// 安全地处理文件大小和路径,避免open_basedir限制问题
|
||||
$fileName = trim($version['file_path']);
|
||||
$fileSize = false;
|
||||
|
||||
// 使用__DIR__构建安全的绝对路径,与version_control.php保持一致
|
||||
$uploadDir = __DIR__ . '/../files/';
|
||||
$absoluteFilePath = $uploadDir . $fileName;
|
||||
|
||||
// 尝试安全地获取文件大小,处理open_basedir限制
|
||||
try {
|
||||
// 首先尝试使用原始路径(相对路径通常在web环境中更安全)
|
||||
if (file_exists($originalFilePath)) {
|
||||
$fileSize = filesize($originalFilePath);
|
||||
}
|
||||
// 尝试相对于当前脚本的路径
|
||||
else {
|
||||
$relativePath = dirname(__FILE__) . DIRECTORY_SEPARATOR . $originalFilePath;
|
||||
if (file_exists($relativePath)) {
|
||||
$fileSize = filesize($relativePath);
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
// 如果遇到open_basedir限制或其他安全限制,优雅地处理
|
||||
$fileSize = false;
|
||||
if (file_exists($absoluteFilePath)) {
|
||||
$fileSize = filesize($absoluteFilePath);
|
||||
}
|
||||
|
||||
$sizeText = formatFileSize($fileSize);
|
||||
|
||||
// 构建安全的下载链接
|
||||
$downloadUrl = '/files/' . $fileName;
|
||||
?>
|
||||
<a href="<?php echo htmlspecialchars($version['file_path']); ?>" class="btn btn-primary" download>下载(大小:<?php echo $sizeText; ?>)</a>
|
||||
<a href="<?php echo htmlspecialchars($downloadUrl); ?>" class="btn btn-primary" download>下载(大小:<?php echo $sizeText; ?>)</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
Reference in New Issue
Block a user