Files
anpdf/app/routes/price.php

78 lines
1.8 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) {
2020-04-07 18:22:55 +03:00
$price = db_get("SELECT `pricename` FROM price WHERE `pricehash` = $hash LIMIT 1");
2020-04-07 18:13:53 +03:00
2020-04-07 18:22:55 +03:00
if (!isset($price['price_id'])){
header("HTTP/1.0 404 Not Found");
return False;
}
$id = $price['price_id'];
$pdfile = "/vhosts/an/httpdocs/files/pdf/pdf/$id.pdf";
2020-04-07 18:13:53 +03:00
$request = $_SERVER['REQUEST_URI'];
$filename = basename($request);
2020-04-07 18:22:55 +03:00
if (!file_exists($pdfile)) {
header("HTTP/1.0 404 Not Found");
return false;
}
2020-04-07 18:13:53 +03:00
2020-04-07 18:22:55 +03:00
if (ob_get_level()) {
ob_end_clean();
2020-04-07 18:13:53 +03:00
}
2020-04-07 18:22:55 +03:00
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);
2020-04-07 18:13:53 +03:00
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
}