78 lines
1.8 KiB
PHP
78 lines
1.8 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 file_kuri($hash) {
|
|
|
|
|
|
$price = db_get("SELECT `pricename` FROM price WHERE `pricehash` = $hash LIMIT 1");
|
|
|
|
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";
|
|
|
|
$request = $_SERVER['REQUEST_URI'];
|
|
$filename = basename($request);
|
|
|
|
if (!file_exists($pdfile)) {
|
|
header("HTTP/1.0 404 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";
|
|
}
|
|
|
|
}
|
|
|
|
|