<commit_before><?php
/*

    keyescrow: web application for securely escrowing keys
    - deposit/go/index.html: make a deposit

    Copyright (C) 2008-2011 Scot-Irish Lads, LLC
    Author: <NAME> <<EMAIL>>

    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 <http://www.gnu.org/licenses/>.

*/

session_start();
$email = strtolower($_REQUEST["email"]);
if ($_SESSION["sum"] != $_REQUEST["captcha"] || $_REQUEST["terms"] != "on") {
        $_SESSION["sum"] = -1;
        $_SESSION["email"] = $email;
        $_SESSION["note"] = $_REQUEST["note"];
        print("<meta http-equiv='refresh' content='0;url=/deposit'>");
        exit(0);
}

include("../../include/above.html");

$email = strtolower($_REQUEST["email"]);
$note = $_REQUEST["note"];
$contents = file_get_contents($_FILES["payload"]["tmp_name"]);
$payload = base64_encode($contents);
if (strlen($payload) > 15000) {
	error("Your deposit is too big");
}
$filesize = strlen($contents);
$md5 = md5($contents);
$sha1 = sha1($contents);
$filename = $_FILES["payload"]["name"];

$resultset = pg_query($CONN, "
	insert into
		payload
	(
		email,
		note,
		filename,
		filesize,
		md5,
		sha1,
		payload
	)
	values
	(
		'" . pg_escape_string($email) . "',
		'" . pg_escape_string($note) . "',
		'" . pg_escape_string($filename) . "',
		'" . pg_escape_string($filesize) . "',
		'" . pg_escape_string($md5) . "',
		'" . pg_escape_string($sha1) . "',
		'" . pg_escape_string($payload) . "'
	)
	returning
		id
");
if (pg_num_rows($resultset) == 1) {
	$result = pg_fetch_object($resultset, 0);
	if ($result->id > 0) {
		print("<p>The following deposit has been received.</p><br>");
?>
<table>
<tr> <th>File name</th> <td><?php echo $filename ?></td> </tr>
<tr> <th>File size</th> <td><?php echo "$filesize bytes" ?></td> </tr>
<tr> <th>md5</th> <td><?php echo $md5 ?></td> </tr>
<tr> <th>sha1</th> <td><?php echo $sha1 ?></td> </tr>
</table>
<br>
<?php
		print("<p>It is your responsibility to ensure that the deposit we have matches your intended upload.</p>");
		print("<p>You may <a href='/retrieve'>securely retrieve</a> it at any time.</p>");
	} else {
		error("An error has occurred");
	}
} else {
	error("An error has occurred");
}
include("../../include/below.html");<commit_msg>drop display of the sha1 sum;  md5sum is sufficient and less confusing<commit_after><?php
/*

    keyescrow: web application for securely escrowing keys
    - deposit/go/index.html: make a deposit

    Copyright (C) 2008-2011 Scot-Irish Lads, LLC
    Author: <NAME> <<EMAIL>>

    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 <http://www.gnu.org/licenses/>.

*/

session_start();
$email = strtolower($_REQUEST["email"]);
if ($_SESSION["sum"] != $_REQUEST["captcha"] || $_REQUEST["terms"] != "on") {
        $_SESSION["sum"] = -1;
        $_SESSION["email"] = $email;
        $_SESSION["note"] = $_REQUEST["note"];
        print("<meta http-equiv='refresh' content='0;url=/deposit'>");
        exit(0);
}

include("../../include/above.html");

$email = strtolower($_REQUEST["email"]);
$note = $_REQUEST["note"];
$contents = file_get_contents($_FILES["payload"]["tmp_name"]);
$payload = base64_encode($contents);
if (strlen($payload) > 15000) {
	error("Your deposit is too big");
}
$filesize = strlen($contents);
$md5 = md5($contents);
$sha1 = sha1($contents);
$filename = $_FILES["payload"]["name"];

$resultset = pg_query($CONN, "
	insert into
		payload
	(
		email,
		note,
		filename,
		filesize,
		md5,
		sha1,
		payload
	)
	values
	(
		'" . pg_escape_string($email) . "',
		'" . pg_escape_string($note) . "',
		'" . pg_escape_string($filename) . "',
		'" . pg_escape_string($filesize) . "',
		'" . pg_escape_string($md5) . "',
		'" . pg_escape_string($sha1) . "',
		'" . pg_escape_string($payload) . "'
	)
	returning
		id
");
if (pg_num_rows($resultset) == 1) {
	$result = pg_fetch_object($resultset, 0);
	if ($result->id > 0) {
		print("<p>The following deposit has been received.</p><br>");
?>
<table>
<tr> <th>File name</th> <td><?php echo $filename ?></td> </tr>
<tr> <th>File size</th> <td><?php echo "$filesize bytes" ?></td> </tr>
<tr> <th>md5</th> <td><?php echo $md5 ?></td> </tr>
</table>
<br>
<?php
		print("<p>It is your responsibility to ensure that the deposit we have matches your intended upload.</p>");
		print("<p>You may <a href='/retrieve'>securely retrieve</a> it at any time.</p>");
	} else {
		error("An error has occurred");
	}
} else {
	error("An error has occurred");
}
include("../../include/below.html");
{'fraction_non_alphanumeric': 0.17826947292678538, 'fraction_numerical': 0.012232415902140673, 'mean_word_length': 3.8643919510061244, 'pattern_counts': {'":': 0, '<': 90, '<?xml version=': 0, '>': 94, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7429405', 'n_tokens_mistral': 1911, 'n_tokens_neox': 1832, 'n_words': 533}