Files
anpdf/app/routes/price.php

74 lines
1.7 KiB
PHP
Raw Normal View History

2020-04-07 17:39:07 +03:00
<?php
function priceid_kuri($id){
$price = db_get("SELECT `pricename` FROM price WHERE `price_id` = $id");
if (is_array($price))
return $price;
}
2020-04-07 18:13:53 +03:00
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;
}
2020-04-07 17:39:07 +03:00
function addhash_kuri(){
2020-04-07 17:41:02 +03:00
$ssql = "SELECT `price_id`, `BeginDate` FROM `price` WHERE `pricehash` = ''";
2020-04-07 17:39:07 +03:00
$items = dbl_get($ssql);
foreach ($items as $item) {
$id = $item['price_id'];
$date = $item['BeginDate'];
$hash = md5("$id$date");
$usql = "UPDATE `price` SET `pricehash` = '$hash' WHERE `price_id` = '$id'";
dbl_get($usql, 'reader');
echo $usql."\n";
}
2020-04-07 18:13:53 +03:00
}