Download update_share.php from Urban-Guy/Drive: direct link, hf CLI and curl.
- Browser
- Download file 2.16 kB
-
https://huggingface.co/spaces/Urban-Guy/Drive/resolve/main/update_share.php
- Command line
-
hf download hf://spaces/Urban-Guy/Drive/update_share.php
-
curl -L -o update_share.php https://huggingface.co/spaces/Urban-Guy/Drive/resolve/main/update_share.php
2.16 kB
| session_start(); | |
| $metadataFile = 'data/files.json'; | |
| function loadMetadata() { | |
| global $metadataFile; | |
| if (!file_exists($metadataFile)) return ['files' => []]; | |
| return json_decode(file_get_contents($metadataFile), true); | |
| } | |
| function saveMetadata($metadata) { | |
| global $metadataFile; | |
| file_put_contents($metadataFile, json_encode($metadata, JSON_PRETTY_PRINT)); | |
| } | |
| if ($_SERVER['REQUEST_METHOD'] === 'POST') { | |
| $fileId = isset($_POST['fileId']) ? $_POST['fileId'] : ''; | |
| $action = isset($_POST['action']) ? $_POST['action'] : ''; | |
| if (empty($fileId) || empty($action)) { | |
| echo json_encode(['success' => false, 'error' => 'Missing parameters']); | |
| exit; | |
| } | |
| $metadata = loadMetadata(); | |
| $fileFound = false; | |
| foreach ($metadata['files'] as &$file) { | |
| if ($file['id'] === $fileId) { | |
| $fileFound = true; | |
| // Initialize share data if not exists | |
| if (!isset($file['shared'])) { | |
| $file['shared'] = [ | |
| 'enabled' => false, | |
| 'linkSharing' => false | |
| ]; | |
| } | |
| switch ($action) { | |
| case 'enable_link': | |
| $file['shared']['enabled'] = true; | |
| $file['shared']['linkSharing'] = true; | |
| saveMetadata($metadata); | |
| echo json_encode(['success' => true, 'message' => 'Link sharing enabled']); | |
| break; | |
| case 'disable_link': | |
| $file['shared']['linkSharing'] = false; | |
| $file['shared']['enabled'] = false; | |
| saveMetadata($metadata); | |
| echo json_encode(['success' => true, 'message' => 'Link sharing disabled']); | |
| break; | |
| default: | |
| echo json_encode(['success' => false, 'error' => 'Invalid action']); | |
| } | |
| break; | |
| } | |
| } | |
| if (!$fileFound) { | |
| echo json_encode(['success' => false, 'error' => 'File not found']); | |
| } | |
| exit; | |
| } | |
| echo json_encode(['success' => false, 'error' => 'Invalid request method']); | |