65 lines
2.1 KiB
PHP
Executable file
65 lines
2.1 KiB
PHP
Executable file
<?php
|
|
/**
|
|
* Test download functionality
|
|
*/
|
|
require_once 'config.php';
|
|
|
|
// Require authentication
|
|
requireAuth();
|
|
|
|
$user = getCurrentUser();
|
|
|
|
echo "<h2>Download Test</h2>";
|
|
echo "<p>Logged in as: <strong>" . htmlspecialchars($user['name']) . "</strong> (" . htmlspecialchars($user['email']) . ")</p>";
|
|
|
|
// Show user's accessible files
|
|
echo "<h3>Your Files (accessible for download):</h3>";
|
|
if (isset($_SESSION['user_files']) && count($_SESSION['user_files']) > 0) {
|
|
echo "<ul>";
|
|
foreach ($_SESSION['user_files'] as $file) {
|
|
echo "<li>";
|
|
echo "<strong>" . htmlspecialchars($file) . "</strong><br>";
|
|
echo "<a href='download.php?file=" . urlencode($file) . "' target='_blank'>Download</a>";
|
|
echo "</li><br>";
|
|
}
|
|
echo "</ul>";
|
|
} else {
|
|
echo "<p>No files uploaded yet in this session.</p>";
|
|
}
|
|
|
|
// List all files in outputs directory
|
|
$outputDir = __DIR__ . '/outputs/';
|
|
echo "<h2>All Files in outputs directory:</h2>";
|
|
echo "<ul>";
|
|
|
|
if (is_dir($outputDir)) {
|
|
$files = scandir($outputDir);
|
|
foreach ($files as $file) {
|
|
if ($file !== '.' && $file !== '..' && $file !== '.DS_Store') {
|
|
$filepath = $outputDir . $file;
|
|
$size = filesize($filepath);
|
|
$readable = is_readable($filepath) ? 'Yes' : 'No';
|
|
$extension = pathinfo($file, PATHINFO_EXTENSION);
|
|
|
|
echo "<li>";
|
|
echo "<strong>$file</strong><br>";
|
|
echo "Size: " . number_format($size) . " bytes<br>";
|
|
echo "Readable: $readable<br>";
|
|
echo "Extension: $extension<br>";
|
|
echo "<a href='download.php?file=" . urlencode($file) . "' target='_blank'>Test Download</a>";
|
|
echo "</li><br>";
|
|
}
|
|
}
|
|
} else {
|
|
echo "<li>Directory not found</li>";
|
|
}
|
|
|
|
echo "</ul>";
|
|
|
|
// Test file operations
|
|
echo "<h2>Directory permissions:</h2>";
|
|
echo "Directory: $outputDir<br>";
|
|
echo "Exists: " . (is_dir($outputDir) ? 'Yes' : 'No') . "<br>";
|
|
echo "Readable: " . (is_readable($outputDir) ? 'Yes' : 'No') . "<br>";
|
|
echo "Writable: " . (is_writable($outputDir) ? 'Yes' : 'No') . "<br>";
|
|
?>
|