Browse Source

fix #1244 致命错误

magicblack 6 months ago
parent
commit
778801f0ae
1 changed files with 13 additions and 3 deletions
  1. 13 3
      application/admin/controller/Index.php

+ 13 - 3
application/admin/controller/Index.php

@@ -276,8 +276,13 @@ class Index extends Base
             $os_data['os_name'] = strtoupper($os_name);
             
             // 获取磁盘信息
-            $totalSpace = @\disk_total_space('/');
-            $freeSpace = @\disk_free_space('/');
+            $totalSpace = 0;
+            $freeSpace = 0;
+            
+            if (function_exists('disk_total_space') && function_exists('disk_free_space')) {
+                $totalSpace = @disk_total_space('/');
+                $freeSpace = @disk_free_space('/');
+            }
             
             if ($totalSpace > 0) {
                 $totalSpaceGB = round($totalSpace / (1024 * 1024 * 1024), 2);
@@ -321,7 +326,12 @@ class Index extends Base
 
     private function get_disk_space($letter)
     {
-        //获取磁盘信息
+        // 添加函数存在性检查
+        if (!function_exists('disk_total_space') || !function_exists('disk_free_space')) {
+            return [];
+        }
+
+        // 获取磁盘信息
         $diskct = 0;
         $disk = array();