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 19:05:45 +03:00
|
|
|
function anfilename($id){
|
|
|
|
|
|
|
|
|
|
return "/vhosts/an/httpdocs/pub/files/pdf/pdf/$id.pdf";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-04-08 23:26:46 +03:00
|
|
|
|
2020-04-07 18:13:53 +03:00
|
|
|
function file_kuri($hash) {
|
|
|
|
|
|
2020-04-08 23:26:46 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-04-07 18:13:53 +03:00
|
|
|
|
2020-04-07 18:34:49 +03:00
|
|
|
$price = db_get("SELECT `price_id`, `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");
|
2020-04-07 18:34:49 +03:00
|
|
|
echo "file not found";
|
2020-04-07 18:22:55 +03:00
|
|
|
return False;
|
2020-04-08 23:26:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2020-04-07 18:22:55 +03:00
|
|
|
|
|
|
|
|
$id = $price['price_id'];
|
2020-04-07 19:05:45 +03:00
|
|
|
$pdfile = anfilename($id);
|
2020-04-08 23:26:46 +03:00
|
|
|
$newF = PDFDIR.$hash.'.pdf';
|
|
|
|
|
if (!file_exists($newF))
|
|
|
|
|
copy($pdfile, $newF);
|
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)) {
|
2020-04-07 18:34:49 +03:00
|
|
|
header("HTTP/1.0 404 Not Found");
|
|
|
|
|
echo "file not found";
|
|
|
|
|
return false;
|
2020-04-07 18:22:55 +03:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|