From 040df943c0a84de9e3e8e182bde202d9a0105d07 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Thu, 25 Mar 2010 02:56:45 +0000 Subject: [PATCH] integrate spam check --- index.cgi | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/index.cgi b/index.cgi index c6aed7c..6209b0f 100755 --- a/index.cgi +++ b/index.cgi @@ -99,15 +99,33 @@ function do_upload { fi output="$(mktemp db/XXXXX)" uri="$url$(basename "$output")${QUERY_STRING:+"?"}" - (get_modeline - echo "Date: $(date -R)" - echo "From: $REMOTE_ADDR" - echo - echo "$text") > "$output" - echo "Status: 302 Found" - echo "Location: $uri" - header text/plain - echo "$uri" + + # Format, spam check, and save message + ( + get_modeline + echo "Date: $(date -R)" + echo "From: $REMOTE_ADDR" + echo + echo "$text" + ) | HOME=/home/vpaste spamc -E > "$output" + + # Test for spam + if [ "$?" -ne 0 ]; then + # Report spam + header text/plain + echo "Your post has been marked as spam!" + echo "Spam test results are as folllows.. " + echo + cat "$output" + mv "$output" spam + else + # Redirect user + echo "Status: 302 Found" + echo "Location: $uri" + header text/plain + echo "$uri" + fi + } # Default index page -- 2.43.2