Browse Source

PDF awards (work in progress)

master
Fabian Kurz 2 years ago
parent
commit
53cdaa31d5
  1. 14
      api.php
  2. 13
      functions.php

14
api.php

@ -85,6 +85,9 @@
case 'update_account':
update_account();
break;
case 'award_pdf':
award_pdf();
break;
}
function upload($ign) {
@ -371,4 +374,15 @@
}
}
function award_pdf () {
$callsign = validate_get('callsign');
$type = validate_get('type');
header("Content-type: application/pdf");
header("Content-Disposition: attachment; filename=\"$callsign-$type.pdf\"");
echo create_award ($callsign, $type, 1000, "2019-01-01");
}
?>

13
functions.php

@ -923,6 +923,7 @@ function validate ($type, $value) {
case 'callsign':
case 'hiscall':
case 'mycall':
case 'type':
$value = strtoupper($value);
if (preg_match('/^[A-Z0-9\/]+$/', $value)) {
return $value;
@ -1037,10 +1038,14 @@ function get_joindate($callsign) {
}
#import(file_get_contents("dj1yfk.adi"), "DJ1YFK");
#$time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
#echo "time: $time\n";
function create_award ($callsign, $type, $score, $date) {
$type = strtolower($type);
$fdf = sprintf(file_get_contents("pdf/cwops-$type.fdf"), $callsign, date("Y"), 1234, $date, $score);
$filename = "/tmp/award-".$_SESSION['id']."-$type";
file_put_contents("$filename.fdf", $fdf);
system("pdftk pdf/cwops-$type.pdf fill_form $filename.fdf output $filename.pdf");
return file_get_contents("$filename.pdf");
}
?>

Loading…
Cancel
Save