connect_error) { $response = [ "success" => "false", "response" => "Unable to access the database", ]; http_response_code(500); header("Content-Type: application/json"); die(json_encode($response)); } $file = rtrim(str_replace("/files/", "", htmlspecialchars($_GET["url"])), "/"); $storage = new StorageClient([ 'projectId' => $googleProjectId, 'keyFilePath' => $googleKeyFilePath, ]); $bucket = $storage->bucket($googleBucketName); $stmt = $conn->prepare("SELECT id, uid, uploaded, original_name, filetype FROM uploads WHERE id = ?"); $stmt->bind_param("s", $file); $stmt->execute(); $stmt->bind_result($id, $uid, $uploaded, $original_filename, $fileType); if (!$stmt->fetch()) { ?> Xytriza's Uploading Service - File not found prepare("SELECT role FROM users WHERE session = ?"); $stmt->bind_param("s", $_COOKIE["session"]); $stmt->execute(); $role = $stmt->get_result()->fetch_assoc()["role"]; ?>
close(); $conn->close(); http_response_code(404); die(); } $stmt->close(); $fileUrl = "https://files.upload.xytriza.com/{$file}"; $stmt = $conn->prepare("SELECT username FROM users WHERE uid = ?"); $stmt->bind_param("s", $uid); $stmt->execute(); $stmt->bind_result($username); $stmt->fetch(); $stmt->close(); $username = htmlspecialchars($username, ENT_QUOTES, 'UTF-8'); $date = new DateTime("@{$uploaded}"); $date->setTimezone(new DateTimeZone("America/Phoenix")); //temp $utcOffset = $date->getOffset() / 3600; $utcOffsetFormatted = $utcOffset > 0 ? "+{$utcOffset}" : $utcOffset; $formattedDate = $date->format("m/d/Y, g:i:s A") . " UTC{$utcOffsetFormatted}"; $now = new DateTime(); $uploadedDate = DateTime::createFromFormat("U", $uploaded); $interval = $now->diff($uploadedDate); $timeDiff = "Uploaded by {$username} "; $timeUnits = ['year', 'month', 'day', 'hour', 'minute', 'second']; $timeValues = [$interval->y, $interval->m, $interval->d, $interval->h, $interval->i, $interval->s]; for ($i = 0; $i < count($timeUnits); $i++) { if ($timeValues[$i] > 0) { $timeDiff .= $timeValues[$i] . " " . $timeUnits[$i] . ($timeValues[$i] > 1 ? 's' : '') . ' ago'; break; } } try { $object = $bucket->object($id); $objectData = $object->downloadAsString(); } catch (Exception $e) { die("Error searching for file."); } if (in_array($fileType, ["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml"])) { $objectInfo = getimagesizefromstring($objectData); $width = $objectInfo[0]; $height = $objectInfo[1]; } $original_filename = base64_decode($original_filename); ?> <?php echo $original_filename . ' - ' . $username;?> '; } ?> prepare("SELECT role FROM users WHERE session = ?"); $stmt->bind_param("s", $_COOKIE["session"]); $stmt->execute(); $role = $stmt->get_result()->fetch_assoc()["role"]; ?>

'; } elseif (in_array($fileType, ["video/mp4", "video/webm", "video/ogg"])) { echo ''; } elseif (in_array($fileType, ["audio/mpeg", "audio/wav", "audio/ogg"])) { echo ''; } elseif (in_array($fileType, ["text/plain"])) { $fileContent = $object['Body']->getContents(); if (strlen($fileContent) > 100000) { $fileContent = substr($fileContent, 0, 100000) . "... Preview too long. Download the file to view the full content."; } echo ''; } else { echo '

Unable to display file "' . $fileType . '". Suggest support for this type in our Discord.

'; } ?>
Copy'; } if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], "/dashboard/gallery.php") !== false) { echo ''; } ?>
close(); ?>