Update index.php
Browse files
index.php
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
<?php
|
| 2 |
session_start();
|
|
|
|
| 3 |
// Check if this is a shared link
|
| 4 |
if (isset($_GET['share']) && !empty($_GET['share'])) {
|
| 5 |
$shareId = $_GET['share'];
|
|
@@ -12,122 +13,27 @@ if (isset($_GET['share']) && !empty($_GET['share'])) {
|
|
| 12 |
foreach ($metadata['files'] as $file) {
|
| 13 |
if ($file['id'] === $shareId) {
|
| 14 |
|
| 15 |
-
//
|
| 16 |
-
if (isset($file['shared']) &&
|
| 17 |
-
$file['shared']['enabled'] &&
|
| 18 |
-
$file['shared']['linkSharing']) {
|
| 19 |
-
|
| 20 |
-
// File is PUBLICLY SHARED - show viewer
|
| 21 |
-
$fileName = $file['name'];
|
| 22 |
-
$filePath = $file['path'];
|
| 23 |
-
$mimeType = $file['type'];
|
| 24 |
-
$fileSize = $file['size'];
|
| 25 |
-
$modifiedTime = $file['modified'];
|
| 26 |
-
|
| 27 |
-
// Check if file physically exists
|
| 28 |
-
if (file_exists($filePath)) {
|
| 29 |
-
// Include the viewer template
|
| 30 |
-
if (file_exists('view_shared.php')) {
|
| 31 |
-
include 'view_shared.php';
|
| 32 |
-
exit;
|
| 33 |
-
} else {
|
| 34 |
-
die('<html><body style="padding: 40px; font-family: Arial; text-align: center;">
|
| 35 |
-
<h1>❌ Viewer Not Found</h1>
|
| 36 |
-
<p>The file viewer (view_shared.php) is missing.</p>
|
| 37 |
-
<p>Please add view_shared.php to your Space.</p>
|
| 38 |
-
</body></html>');
|
| 39 |
-
}
|
| 40 |
-
} else {
|
| 41 |
-
die('<html><body style="padding: 40px; font-family: Arial; text-align: center;">
|
| 42 |
-
<h1>❌ File Not Found</h1>
|
| 43 |
-
<p>The file has been deleted or moved.</p>
|
| 44 |
-
<p><small>Path: ' . htmlspecialchars($filePath) . '</small></p>
|
| 45 |
-
</body></html>');
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
} else {
|
| 49 |
-
// File is RESTRICTED (not shared)
|
| 50 |
-
die('<html><body style="padding: 40px; font-family: Arial; text-align: center;">
|
| 51 |
-
<h1>🔒 Access Denied</h1>
|
| 52 |
-
<p><strong>This file is not publicly accessible.</strong></p>
|
| 53 |
-
<p>The file owner has set this file to "Restricted".</p>
|
| 54 |
-
<hr style="margin: 30px 0;">
|
| 55 |
-
<p style="color: #666; font-size: 14px;">
|
| 56 |
-
To access this file, the owner needs to:<br>
|
| 57 |
-
1. Right-click the file<br>
|
| 58 |
-
2. Click "Share"<br>
|
| 59 |
-
3. Select "Anyone with the link"<br>
|
| 60 |
-
4. Click "Done"
|
| 61 |
-
</p>
|
| 62 |
-
</body></html>');
|
| 63 |
-
}
|
| 64 |
-
}
|
| 65 |
-
}
|
| 66 |
-
|
| 67 |
-
// File ID not found in database
|
| 68 |
-
die('<html><body style="padding: 40px; font-family: Arial; text-align: center;">
|
| 69 |
-
<h1>❌ File Not Found</h1>
|
| 70 |
-
<p>No file exists with this share ID.</p>
|
| 71 |
-
<p><small>Share ID: ' . htmlspecialchars($shareId) . '</small></p>
|
| 72 |
-
<hr style="margin: 30px 0;">
|
| 73 |
-
<p style="color: #666; font-size: 14px;">
|
| 74 |
-
Possible reasons:<br>
|
| 75 |
-
• The file was deleted<br>
|
| 76 |
-
• The share link is incorrect<br>
|
| 77 |
-
• The container was restarted (Hugging Face ephemeral storage)
|
| 78 |
-
</p>
|
| 79 |
-
</body></html>');
|
| 80 |
-
}
|
| 81 |
-
}
|
| 82 |
-
|
| 83 |
-
die('<html><body style="padding: 40px; font-family: Arial; text-align: center;">
|
| 84 |
-
<h1>❌ Database Error</h1>
|
| 85 |
-
<p>Unable to load file database.</p>
|
| 86 |
-
<p>The data/files.json file may be missing or corrupted.</p>
|
| 87 |
-
</body></html>');
|
| 88 |
-
}
|
| 89 |
-
// Check if this is a shared link
|
| 90 |
-
if (isset($_GET['share']) && !empty($_GET['share'])) {
|
| 91 |
-
$shareId = $_GET['share'];
|
| 92 |
-
|
| 93 |
-
// Load metadata
|
| 94 |
-
$metadataFile = 'data/files.json';
|
| 95 |
-
if (file_exists($metadataFile)) {
|
| 96 |
-
$metadata = json_decode(file_get_contents($metadataFile), true);
|
| 97 |
-
|
| 98 |
-
// Find the shared file
|
| 99 |
-
foreach ($metadata['files'] as $file) {
|
| 100 |
-
if ($file['id'] === $shareId) {
|
| 101 |
-
// Check if file is shared
|
| 102 |
-
if (isset($file['shared']) && $file['shared']['enabled'] && $file['shared']['linkSharing']) {
|
| 103 |
-
// File is shared - show viewer
|
| 104 |
$fileName = $file['name'];
|
| 105 |
$filePath = $file['path'];
|
| 106 |
$mimeType = $file['type'];
|
| 107 |
$fileSize = $file['size'];
|
| 108 |
$modifiedTime = $file['modified'];
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
|
|
|
|
|
|
| 113 |
}
|
| 114 |
-
|
| 115 |
-
// Include the viewer template
|
| 116 |
-
include 'view_shared.php';
|
| 117 |
-
exit;
|
| 118 |
-
} else {
|
| 119 |
-
// File not shared or link sharing disabled
|
| 120 |
-
die('This file is not publicly accessible');
|
| 121 |
}
|
| 122 |
}
|
| 123 |
}
|
| 124 |
-
|
| 125 |
-
// File not found
|
| 126 |
-
die('File not found');
|
| 127 |
}
|
| 128 |
-
|
| 129 |
-
die('Unable to load file information');
|
| 130 |
}
|
|
|
|
| 131 |
// Create necessary directories
|
| 132 |
$dirs = ['uploads', 'data', 'trash'];
|
| 133 |
foreach ($dirs as $dir) {
|
|
@@ -912,38 +818,21 @@ function timeAgo($timestamp) {
|
|
| 912 |
</button>
|
| 913 |
</div>
|
| 914 |
<div class="modal-body" style="padding: 24px;">
|
| 915 |
-
<!--
|
| 916 |
-
|
| 917 |
-
|
| 918 |
-
|
| 919 |
-
|
| 920 |
-
|
| 921 |
-
|
| 922 |
-
|
| 923 |
-
|
| 924 |
-
|
| 925 |
-
|
| 926 |
-
|
| 927 |
-
|
| 928 |
-
|
| 929 |
-
|
| 930 |
-
</div>
|
| 931 |
-
</label>
|
| 932 |
-
|
| 933 |
-
<label style="flex: 1; padding: 16px; border: 2px solid #dadce0; border-radius: 8px; cursor: pointer; transition: all 0.2s;" id="linkOption">
|
| 934 |
-
<input type="radio" name="shareAccess" value="link" onchange="updateShareAccess('link')" style="margin-right: 12px;">
|
| 935 |
-
<div style="display: inline-block; vertical-align: middle;">
|
| 936 |
-
<div style="font-weight: 500; font-size: 14px; color: #202124;">
|
| 937 |
-
<span class="material-icons" style="vertical-align: middle; font-size: 18px; margin-right: 4px;">link</span>
|
| 938 |
-
Anyone with the link
|
| 939 |
-
</div>
|
| 940 |
-
<div style="font-size: 12px; color: #5f6368; margin-top: 4px;">Anyone can view</div>
|
| 941 |
-
</div>
|
| 942 |
-
</label>
|
| 943 |
-
</div>
|
| 944 |
-
</div>
|
| 945 |
-
|
| 946 |
-
<!-- Link sharing box -->
|
| 947 |
<div id="linkSharingBox" style="display: none; padding: 16px; background: #f1f3f4; border-radius: 8px;">
|
| 948 |
<div style="font-size: 13px; color: #5f6368; margin-bottom: 8px;">
|
| 949 |
<span class="material-icons" style="vertical-align: middle; font-size: 16px; color: #1a73e8;">info</span>
|
|
|
|
| 1 |
<?php
|
| 2 |
session_start();
|
| 3 |
+
|
| 4 |
// Check if this is a shared link
|
| 5 |
if (isset($_GET['share']) && !empty($_GET['share'])) {
|
| 6 |
$shareId = $_GET['share'];
|
|
|
|
| 13 |
foreach ($metadata['files'] as $file) {
|
| 14 |
if ($file['id'] === $shareId) {
|
| 15 |
|
| 16 |
+
// ALL FILES ARE PUBLIC - No checks!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
$fileName = $file['name'];
|
| 18 |
$filePath = $file['path'];
|
| 19 |
$mimeType = $file['type'];
|
| 20 |
$fileSize = $file['size'];
|
| 21 |
$modifiedTime = $file['modified'];
|
| 22 |
+
|
| 23 |
+
if (file_exists($filePath)) {
|
| 24 |
+
if (file_exists('view_shared.php')) {
|
| 25 |
+
include 'view_shared.php';
|
| 26 |
+
exit;
|
| 27 |
+
}
|
| 28 |
}
|
| 29 |
+
die('File not found');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
}
|
| 31 |
}
|
| 32 |
}
|
|
|
|
|
|
|
|
|
|
| 33 |
}
|
| 34 |
+
die('File not found in database');
|
|
|
|
| 35 |
}
|
| 36 |
+
?>
|
| 37 |
// Create necessary directories
|
| 38 |
$dirs = ['uploads', 'data', 'trash'];
|
| 39 |
foreach ($dirs as $dir) {
|
|
|
|
| 818 |
</button>
|
| 819 |
</div>
|
| 820 |
<div class="modal-body" style="padding: 24px;">
|
| 821 |
+
<!-- Simple share info -->
|
| 822 |
+
<div style="margin-bottom: 20px;">
|
| 823 |
+
<div style="padding: 16px; background: #e8f4fd; border-radius: 8px; border-left: 4px solid #1a73e8;">
|
| 824 |
+
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;">
|
| 825 |
+
<span class="material-icons" style="color: #1a73e8; font-size: 20px;">info</span>
|
| 826 |
+
<span style="font-weight: 500; color: #1a73e8; font-size: 14px;">Public File</span>
|
| 827 |
+
</div>
|
| 828 |
+
<p style="margin: 0; color: #5f6368; font-size: 13px; line-height: 1.5;">
|
| 829 |
+
This file is publicly shareable. Anyone with the link can view and download it.
|
| 830 |
+
</p>
|
| 831 |
+
</div>
|
| 832 |
+
</div>
|
| 833 |
+
|
| 834 |
+
|
| 835 |
+
<!-- Link sharing box -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 836 |
<div id="linkSharingBox" style="display: none; padding: 16px; background: #f1f3f4; border-radius: 8px;">
|
| 837 |
<div style="font-size: 13px; color: #5f6368; margin-bottom: 8px;">
|
| 838 |
<span class="material-icons" style="vertical-align: middle; font-size: 16px; color: #1a73e8;">info</span>
|