forked from D3V1L1805/FauxShield
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
322 lines (294 loc) · 10.5 KB
/
index.php
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Deepfake Detection</title>
<!-- <link rel="stylesheet" href="style.css" /> -->
<style>
body, html {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
.nav {
width: 100%;
height: 8%;
background: #333;
color: #fff;
padding: 4px 0;
position: fixed;
top: 0;
left: 0;
display: flex;
align-items: center;
justify-content: space-between;
z-index: 10;
}
.nav img {
alignment: center;
margin-left: 40px;
margin-right: 40px /* Add margin to the left for spacing */
}
.nav .navbar-text {
display: block;
font-size: x-large;
margin: 0 auto; /* Center the text */
}
.nav ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
}
.nav ul li {
margin: 0 10px;
font-size: 20px;
cursor: pointer;
}
.nav a {
color: white;
text-decoration: none;
}
.nav a:visited {
color: white;
}
footer {
width: 100%;
height: 10%;
color: #fff;
padding: 4px 0;
position: fixed;
left: 0;
bottom: 0;
display: flex;
align-items: center;
justify-content: space-between;
z-index: 10;
text-align: center;
overflow: auto;
}
.hero {
width: 100%;
height: 100vh;
background: linear-gradient(rgba(127, 2, 54, 0.7),rgba(20, 2, 112, 0.7)), url('src/assets/hero.jpg');
background-repeat: no-repeat;
background-size: cover;
color: white;
display: flex;
align-items: center;
justify-content: center;
}
.hero-text {
text-align: center;
max-width: 800px;
margin-bottom: 20%;
}
.hero-text h1 {
font-size: 50px;
font-weight: 600;
}
.hero-text p {
max-width: 700px;
margin: 0 auto 20px;
line-height: 1.5;
text-align: center;
font-size: 18px;
font-family: "Playfair Display", serif;
}
.form {
width: 400px;
margin-left: 23%;
}
.progress-bar {
width: 100%;
background-color: #f3f3f3;
border-radius: 10px;
overflow: hidden;
margin-top: 20px;
display: none;
}
.progress-bar-fill {
height: 20px;
width: 100%;
background: linear-gradient(to right, #24C6DC, #7f4a9d);
background-size: 200% 100%;
animation: loading 2s infinite;
}
@keyframes loading {
0% {
background-position: 100% 0;
}
100% {
background-position: -100% 0;
}
}
.text-block {
background-color: black;
color: white;
padding: 10px 20px;
border-radius: 5px;
text-align: center;
margin-top: 10px;
}
.container {
text-align: center;
margin-top: 20px;
}
#result {
display: none;
margin-top: 20px;
max-width: 100%;
max-height: 80vh; /* Adjust max-height as needed */
overflow: auto; /* Enable scrolling if content exceeds max-height */
}
img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
display: block;
margin: 0 auto;
}
.remain{
padding-top: 8%;
}
</style>
</head>
<body class="hero">
<div class="nav">
<img src='src/assets/logo-no-background.png' alt="">
<ul>
<li><a href="index.php">Home</a></li>
<!-- <li>Deepfake Detector</li> -->
<li><a href="source.php">About us</a></li>
<li><a href="contact.php">Contact us</a></li>
</ul>
</div>
<div class = "remain">
<div class="hero-text">
<div id="text">
<h1>Upload ∙ Process ∙ Detect</h1>
<p>An All-in-one integrated platform to identify and detect DeepFake videos, images and audios.</p>
</div>
<form id="uploadForm" enctype="multipart/form-data" method="POST">
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Submit" name="submit">
</form>
<div class="progress-bar" id="progressBar">
<div class="progress-bar-fill" id="progressBarFill">Processing...</div>
</div>
<div id="result"></div>
</div>
</div>
<script>
document.getElementById('uploadForm').addEventListener('submit', function(event) {
event.preventDefault(); // Prevent the form from submitting the default way
let progressBar = document.getElementById('progressBar');
let resultDiv = document.getElementById('result');
let progressBarFill = document.getElementById('progressBarFill');
progressBar.style.display = 'block';
resultDiv.style.display = 'none';
let formData = new FormData(this);
fetch('upload.php', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.status === 'success') {
checkStatus(); // Start checking the status
} else {
progressBar.style.display = 'none';
resultDiv.style.display = 'block';
resultDiv.innerHTML = '<p>' + data.message + '</p>';
}
})
.catch(error => {
progressBar.style.display = 'none';
resultDiv.style.display = 'block';
resultDiv.innerHTML = '<p>There was an error processing your request.</p>';
});
});
function displayResult(filePath, pred) {
let resultDiv = document.getElementById('result');
resultDiv.style.display = 'block';
document.getElementById('uploadForm').style.display = 'none'; // Hide the form
document.getElementById('text').style.display = 'none';
let fileType = filePath.split('.').pop().toLowerCase();
fetch('uploads/pred.txt')
.then(response => response.text())
.then(prediction => {
let content;
if (['mp4', 'webm', 'ogg'].includes(fileType)) {
content = `<video controls style="max-width: 100%; max-height: 100%;" onerror="handleMediaError(event)">
<source src="${filePath}" type="video/${fileType}">
Your browser does not support the video tag.
</video>
<div class="text-block">
<p>${prediction}</p>
</div>`;
} else if (['jpg', 'jpeg', 'png', 'gif'].includes(fileType)) {
content = `<div class="container">
<img src="${filePath}" alt="Uploaded Image">
<div class="text-block">
<p>${prediction}</p>
</div>
</div>`;
} else if (['mp3', 'wav', 'ogg'].includes(fileType)) {
content = `<audio controls style="max-width: 100%; max-height: 100%;" onerror="handleMediaError(event)">
<source src="${filePath}" type="audio/${fileType}">
Your browser does not support the audio tag.
</audio>
<div class="text-block">
<p>${prediction}</p>
</div>`;
} else {
content = 'Unsupported file type';
}
resultDiv.innerHTML = content;
})
.catch(error => {
console.error('Error fetching prediction:', error);
resultDiv.innerHTML = 'Error loading prediction';
});
}
function checkStatus() {
fetch('status.txt')
.then(response => response.text())
.then(status => {
if (status.trim() === '0') {
fetch('file.txt')
.then(response => response.text())
.then(filePath => {
fetch('pred.txt')
.then(response => response.text())
.then(pred => {
displayResult(filePath.trim(), pred.trim());
// Perform any cleanup or additional actions after displaying result
document.getElementById('progressBar').style.display = 'none';
})
})
.catch(error => {
console.error('Error fetching file.txt:', error);
document.getElementById('progressBar').style.display = 'none';
document.getElementById('result').style.display = 'block';
document.getElementById('result').innerHTML = '<p>Error fetching result.</p>';
});
} else {
setTimeout(checkStatus, 1000); // Check again after 1 second
}
})
.catch(error => {
console.error('Error checking status:', error);
document.getElementById('progressBar').style.display = 'none';
document.getElementById('result').style.display = 'block';
document.getElementById('result').innerHTML = '<p>Error checking status.</p>';
});
}
</script>
</body>
<footer>
Copyright © Tech Maniacs | All Rights Reserved
</footer>
</html>