From 21f2c45d892910f0818236d9afe5e3a40a49354a Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Sun, 12 Jun 2022 21:22:58 +0000 Subject: [PATCH] Add Captcha to t0url --- t0url.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/t0url.py b/t0url.py index ddac78a..9cc5a3f 100644 --- a/t0url.py +++ b/t0url.py @@ -19,7 +19,9 @@ def help(): form = ( '
' '' - '' + '' + '
URL: ' + '
CAPTCHA: Who owns this site? ' '
'.format(URL, POST) ) return """ @@ -51,7 +53,6 @@ SOURCE CODE SEE ALSO https://txt.t0.vc - https://pic.t0.vc """.format(POST, URL, form) def new_id(): @@ -66,6 +67,20 @@ def index(): @flask_app.route('/', methods=['POST']) def new(): try: + is_web = 'web' in request.form + + name = request.form.get('name', None) + if name: + # TODO: fail if name field is filled out + print('Name filled out:', name) + + captcha = request.form.get('captcha', None) + if is_web and 'tanner' not in captcha.lower() and 'collin' not in captcha.lower(): + print('Captcha failed:', captcha) + return redirect('https://txt.t0.vc/LPPZ') + else: + print('Captcha passed:', captcha) + with shelve.open(DB) as db: nid = new_id() while nid in db: