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/"); } $_SESSION["email"] = urldecode($_SESSION["email"]); $resultset = pg_query($CONN, " select payload, filename from payload where payload.id='" . pg_escape_string($_SESSION["id"]) . "' and payload.email='" . pg_escape_string(strtolower($_SESSION["email"])) . "' "); if (pg_num_rows($resultset) != 1) { print("Error"); exit(0); } $result = pg_fetch_object($resultset, 0); $fingerprint = preg_replace("/\s+/", "", file_get_contents("../../gpg.fingerprint")); $res = gnupg_init(); 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($CONN, " insert into download ( payload_id ) values ( '" . pg_escape_string($_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); ?>