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_once("../include/functions.html"); $payload = $_POST["payload"]; $filesize = strlen($payload); if (strlen($payload) > 4096) { header("HTTP/1.0 413 Request Entity Too Large"); exit; } if (preg_match('/[^\x00-\x7F]/S', $payload) ) { header("HTTP/1.0 400 Bad Request"); exit; } $fingerprint = preg_replace("/\s+/", "", file_get_contents("../gpg.fingerprint")); $res = gnupg_init(); if (! gnupg_adddecryptkey($res, $fingerprint, "")) { header("HTTP/1.0 400 Bad Request"); print("Server side key error"); exit; } if (! $cleartext = gnupg_decrypt($res, $_POST["payload"])) { header("HTTP/1.0 400 Bad Request"); print("Server side decryption error"); exit; } $md5 = md5($cleartext); $sha1 = sha1($cleartext); $filename = "ecryptfs.tar.gz"; $resultset = pg_query($CONN, " insert into payload ( filename, filesize, md5, sha1, payload ) values ( '" . pg_escape_string($filename) . "', '" . pg_escape_string($filesize) . "', '" . pg_escape_string($md5) . "', '" . pg_escape_string($sha1) . "', '" . pg_escape_string($payload) . "' ) returning id, auth "); if (pg_num_rows($resultset) == 1) { $result = pg_fetch_object($resultset, 0); $auth = $result->auth; if ($result->id > 0) { print($URL . "?u=$md5-$auth"); } } ?>