<?php

$filename = $_GET['f'];
$dir = '/';
$filepath = getcwd() . $dir . $filename;

if ( !is_file($filepath) ) {
	echo 'file not found';
	exit();
}

$time = filemtime($filepath);

if ( empty($_GET['v']) ) {
	$url = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]&v=$time"; 
	header('Location: '.$url);
}

header('Last-Modified: '.$time);
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="'.$filename.'"');
header('Cache-Control: no-cache, no-store, must-revalidate'); // HTTP 1.1
header('Pragma: no-cache'); // HTTP 1.0
header('Expires: 0'); // Proxies
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($filepath));
header('Accept-Ranges: bytes');


readfile($filepath);
exit();
