Files
anpdf/app/routes/price.php
Andrey Kuvshinov c01b7ab374 newf echo
2020-04-08 23:31:50 +03:00

97 lines
2.1 KiB
PHP

<?php
function priceid_kuri($id){
$price = db_get("SELECT `pricename` FROM price WHERE `price_id` = $id");
if (is_array($price))
return $price;
}
function anfilename($id){
return "/vhosts/an/httpdocs/pub/files/pdf/pdf/$id.pdf";
}
function file_kuri($hash) {
$price = db_get("SELECT `price_id`, `pricename` FROM `price` WHERE `pricehash` = '$hash' LIMIT 1");
if (!isset($price['price_id'])){
header("HTTP/1.0 404 Not Found");
echo "file not found";
return False;
}
$id = $price['price_id'];
$pdfile = anfilename($id);
$newF = PDFDIR.$hash.'.pdf';
echo $newF;
if (!file_exists($newF))
copy($pdfile, $newF);
$request = $_SERVER['REQUEST_URI'];
$filename = basename($request);
if (!file_exists($pdfile)) {
header("HTTP/1.0 404 Not Found");
echo "file not found";
return false;
}
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(){
$ssql = "SELECT `price_id`, `BeginDate` FROM `price` WHERE `pricehash` = ''";
$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";
}
}