From 1b23943dfacb8e0e16b3b5033d63f147e3aa4b9b Mon Sep 17 00:00:00 2001 From: Andrey Kuvshinov Date: Tue, 7 Apr 2020 18:13:53 +0300 Subject: [PATCH] add file pdf --- app/routes/price.php | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/app/routes/price.php b/app/routes/price.php index a5dbea0..d0c00bc 100644 --- a/app/routes/price.php +++ b/app/routes/price.php @@ -11,6 +11,44 @@ function priceid_kuri($id){ } +function file_kuri($hash) { + + + // $price = db_get("SELECT `pricename` FROM price WHERE `pricehash` = $hash LIMIT 1"); + // $id = $price['price_id']; + + // $pdffile = "/vhosts/an/httpdocs/files/pdf/pdf/$id.pdf"; + + $pdfile = '/vhosts/anpdf/app/pub/files/promo.pdf'; + + + $request = $_SERVER['REQUEST_URI']; + $filename = basename($request); + + if (file_exists($pdfile)) { + + if (ob_get_level()) { + ob_end_clean(); + } + + header("Content-Type: application/pdf; charset=UTF-8"); + header("Content-Length: ".filesize($pdfile)); + header("Content-Disposition: attachment; filename=\"{$filename}\""); + header("Content-Transfer-Encoding: binary"); + header("Cache-Control: must-revalidate"); + header("Pragma: no-cache"); + header("Expires: 0"); + readfile($pdfile); + + } + + + return; + + +} + + function addhash_kuri(){ @@ -30,4 +68,6 @@ function addhash_kuri(){ echo $usql."\n"; } -} \ No newline at end of file +} + +