forked from TrinsyCa/File-Bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
86 lines (83 loc) · 3.07 KB
/
index.php
File metadata and controls
86 lines (83 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="asset/img/icon.png">
<link rel="stylesheet" href="asset/css/style.css">
<title>File Bridge</title>
</head>
<body>
<?php
$url = $_SERVER['REQUEST_URI'];
$href = basename($url);
$href = htmlspecialchars($href);
try {
include_once "asset/php/connection.php";
$stmt = $db->prepare("SELECT * FROM files WHERE href = :href");
$stmt->bindParam(":href", $href);
$stmt->execute();
$fileData = $stmt->fetch(PDO::FETCH_ASSOC);
if ($fileData) {
$path = $fileData['path'];
if (file_exists($path)) {
$mimeType = mime_content_type($path);
ob_clean();
header('Content-Type: ' . $mimeType);
header('Content-Disposition: inline; filename="' . basename($path) . '"');
header('Cache-Control: public, max-age=86400'); // 1 Day Cache
$file = fopen($path, 'rb');
if ($file) {
fpassthru($file);
fclose($file);
exit;
} else {
echo "Dosya okunamadı.";
}
}
}
} catch (Exception $e) {
echo "Bir hata oluştu: " . $e->getMessage();
}
?>
<section class="href-section">
<div class="href-container">
<div class="titleBox">
<h1>Dosya Adresi Oluşturuldu</h1>
</div>
<div class="hrefBox">
<span>
<?php
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$host = $_SERVER['HTTP_HOST'];
$baseUrl = $protocol . $host . "/";
echo $baseUrl;
?>
</span>
<p></p>
</div>
</div>
</section>
<section class="file-container">
<div class="titleBox">
<h1>File Bridge</h1>
</div>
<div class="descriptionBox">
Make a bridge with your file.
</div>
<label class="uploadBox" for="uploadInput">
<input type="file" id="uploadInput" name="file">
<img src="asset/img/upload.png">
<div class="text">
<p>Drag and drop or click here<br>to upload file</p>
<span>Upload any file from desktop</span>
</div>
</label>
<div class="suffix">
<p>Created by <a href="https://trinsyca.com" target="_blank">TrinsyCa</a></p>
</div>
</section>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="asset/script/upload.js"></script>
</body>
</html>