This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ include("../../include/functions.html"); session_start(); $TITLE = "Download a deposit"; $_SESSION["id"] = $_REQUEST["id"]; if (!isset($_SESSION["email"]) || empty($_SESSION["email"])) { $_SESSION["return"] = "/retrieve"; redirect("/openid/"); } $EMAIL = strtolower(urldecode($_SESSION["email"])); assert_email($EMAIL); $resultset = pg_query_params($CONN, " select payload, filename from payload where payload.id=$1 and payload.email=$2 ", array($_SESSION["id"], $EMAIL)); if (pg_num_rows($resultset) != 1) { print("Error"); exit(0); } $result = pg_fetch_object($resultset, 0); $res = gnupg_init(); $gpg = gnupg_keyinfo($res, $CONTACT); $fingerprint = $gpg[0]["subkeys"][0]["fingerprint"]; if (! gnupg_adddecryptkey($res, $fingerprint, "")) { error("Server side key error"); } if (! $payload = gnupg_decrypt($res, $result->payload)) { error("Server side decryption error"); } $filesize = strlen($payload); $filename = $result->filename; $resultset = pg_query_params($CONN, " insert into download (payload_id) values ($1) ", array($_SESSION["id"])); header("Content-type: application/download"); header("Content-length: $filesize"); header("Content-transfer-encodig: binary"); header("Content-disposition: attachment; filename=$filename"); header("Cache-Control: max-age=0, no-cache, must-revalidate"); print($payload); ?>