aboutsummaryrefslogtreecommitdiff
path: root/preview/index.php
blob: 38856af6b41410c00e323a228dc7269dd320967b (plain)
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
<?php

session_start();

if ($_SERVER['SERVER_NAME'] !== "viewer.familine.minteck.org") {
    header("Location: /");
    die();
}

if (isset($_GET['i'])) {
    $id = $_GET['i'];
} else {
    header("Location: https://share.familine.minteck.org");
    die();
}

if ($id !== $_SESSION["pvid"]) {
    die();
}

$file = $_SERVER['DOCUMENT_ROOT'] . "/private/shares/" . $_SESSION['filename'];

header('Content-Description: File Transfer');
header('Content-Type: ' . mime_content_type($file));
header('Content-Disposition: filename="' . str_replace("\"", "''", $_SESSION['name']) . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
ob_clean();
flush();
readfile($file);
exit;