From 16a2da6372adc9dc2b5cd7027529227af6e0704c Mon Sep 17 00:00:00 2001 From: Brad Greenlee Date: Thu, 29 Mar 2012 11:54:26 -0700 Subject: [PATCH] Add an access key so that random people don't start using my server to host their porn. --- recv.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/recv.php b/recv.php index fb776af..b78f5ad 100644 --- a/recv.php +++ b/recv.php @@ -4,6 +4,7 @@ # Install by putting this file on your web server and give the web server # user write permissions to the directory in which you put this script. # +$KEY = 'secret_access_key_please_change'; # pass key via 'key' query parameter $MAXLENGTH = 4096000; # 4 MB function rsperr($msg='', $st='400 Bad Request') { header('HTTP/1.1 '.$st); @@ -12,6 +13,11 @@ function rsperr($msg='', $st='400 Bad Request') { function pathfromid($id, $suffix='') { return substr($id,0,2).'/'.substr($id,2).$suffix; } + +# Check key +if ($_GET['key'] != $KEY) + rsperr('','401 Unauthorized'); + # Build path and url if (!isset($_GET['name']) || !trim($_GET['name'])) $_GET['name'] = strval(time());