View sourcecode

The following files exists in this folder. Click to view.

movie.php

26 lines UTF-8 Unix (LF)
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
<?php
session_start
();
if (!isset(
$_SESSION["userID"]))
    
header("location: login.php");
require_once 
"functions/database.php";

$data $db->query("SELECT f.* FROM allowedIDs a INNER JOIN mediaFiles f ON a.categoryID = f.categoryID WHERE f.mediaID = :mediaID AND a.userID = :userID", array("userID"=> $_SESSION["userID"],"mediaID"=>$_GET["id"]));

if (!
$data)
{
    
http_response_code(403);
    return;
}

$filePath "mediaFiles/{$data['fileURL']}";

#ChatGPT hjälpte mig med detta
$finfo finfo_open(FILEINFO_MIME_TYPE);
$mimeType finfo_file($finfo$filePath);
finfo_close($finfo);


header("Content-Type: {$mimeType}");

echo 
file_get_contents($filePath);
?>