<?php
echo "<h1>服务器信息检查</h1>";

echo "<h2>当前服务器</h2>";
echo "<p>Server Software: " . $_SERVER['SERVER_SOFTWARE'] . "</p>";

echo "<h2>PHP上传配置</h2>";
echo "<table border='1' cellpadding='10'>";
echo "<tr><th>配置项</th><th>当前值</th><th>建议值</th></tr>";
echo "<tr><td>upload_max_filesize</td><td>" . ini_get('upload_max_filesize') . "</td><td>1G</td></tr>";
echo "<tr><td>post_max_size</td><td>" . ini_get('post_max_size') . "</td><td>1G</td></tr>";
echo "<tr><td>max_execution_time</td><td>" . ini_get('max_execution_time') . "</td><td>300</td></tr>";
echo "<tr><td>max_input_time</td><td>" . ini_get('max_input_time') . "</td><td>300</td></tr>";
echo "<tr><td>memory_limit</td><td>" . ini_get('memory_limit') . "</td><td>512M</td></tr>";
echo "</table>";

echo "<h2>视频文件大小统计</h2>";
$videosDir = __DIR__ . '/videos/opening/';
if (is_dir($videosDir)) {
    $files = scandir($videosDir);
    $totalSize = 0;
    $count = 0;
    foreach ($files as $file) {
        if ($file === '.' || $file === '..') continue;
        $path = $videosDir . $file;
        if (is_file($path)) {
            $size = filesize($path);
            $totalSize += $size;
            $count++;
            echo "<p>" . $file . ": " . round($size / 1024 / 1024, 1) . "MB</p>";
        }
    }
    echo "<p><strong>总计: " . $count . "个文件，" . round($totalSize / 1024 / 1024, 1) . "MB</strong></p>";
} else {
    echo "<p>视频目录不存在</p>";
}

echo "<h2>服务器限制分析</h2>";
echo "<ul>";
echo "<li><strong>Nginx限制</strong>: client_max_body_size = 50MB（如果使用Nginx）</li>";
echo "<li><strong>Apache限制</strong>: FcgidMaxRequestLen = 512MB（如果使用Apache）</li>";
echo "<li><strong>PHP限制</strong>: upload_max_filesize = " . ini_get('upload_max_filesize') . "</li>";
echo "</ul>";

echo "<h2>问题分析</h2>";
if (strpos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false) {
    echo "<p style='color:red; font-weight:bold;'>当前使用Nginx，上传限制为50MB！大视频无法上传！</p>";
} elseif (strpos($_SERVER['SERVER_SOFTWARE'], 'apache') !== false) {
    echo "<p style='color:green;'>当前使用Apache，上传限制为512MB，可以上传大视频</p>";
} else {
    echo "<p>无法确定服务器类型</p>";
}
?>
