diff options
author | Chris Xiong <chirs241097@gmail.com> | 2019-09-04 01:05:18 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2019-09-04 01:07:26 +0800 |
commit | 3778fbfebf1cecda4036cd2a50e3b8239c80f1eb (patch) | |
tree | 25fb837d668b51c6558c7f28bc89ccc00e581a0c /cgi | |
parent | c207bdceb32deac33b4a3018c22eae45673642e4 (diff) | |
download | web-3778fbfebf1cecda4036cd2a50e3b8239c80f1eb.tar.xz |
Privacy Revamp.
Removed recaptcha.
New privacy policy page (aka. blog post).
Links updates.
Banner updates.
Diffstat (limited to 'cgi')
-rwxr-xr-x | cgi/gb_newentry.cgi | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/cgi/gb_newentry.cgi b/cgi/gb_newentry.cgi index 9e8c4dd..14cfb91 100755 --- a/cgi/gb_newentry.cgi +++ b/cgi/gb_newentry.cgi @@ -1,14 +1,15 @@ #!/usr/bin/python3 import os,sys,html,json,datetime -import urllib.parse,urllib.request +import urllib.parse +import requests -if os.environ['SERVER_NAME']!='chrisoft.org': - import socks,socket - socks.set_default_proxy(socks.SOCKS5,"127.0.0.1",1080) - socket.socket=socks.socksocket - def getaddrinfo(*args): - return [(socket.AF_INET,socket.SOCK_STREAM,6,'',(args[0],args[1]))] - socket.getaddrinfo=getaddrinfo +#if os.environ['SERVER_NAME']!='chrisoft.org': +# import socks,socket +# socks.set_default_proxy(socks.SOCKS5,"127.0.0.1",1080) +# socket.socket=socks.socksocket +# def getaddrinfo(*args): +# return [(socket.AF_INET,socket.SOCK_STREAM,6,'',(args[0],args[1]))] +# socket.getaddrinfo=getaddrinfo def fail(x=None): print('Status: 400 Bad Request',end='\r\n') @@ -38,13 +39,11 @@ if len(mname)+len(mcontent)>16384: fail(x=':)') try: - with open(os.environ['DOCUMENT_ROOT']+'/grecaptcha_key',mode='r',encoding='utf-8') as gr_secret_f: - gr_secret=gr_secret_f.read() - req={'secret':gr_secret,'response':f['gr_ret'],'remoteip':os.environ['REMOTE_ADDR']} - r=urllib.request.Request('https://www.google.com/recaptcha/api/siteverify',data=urllib.parse.urlencode(req).encode('utf-8'),method='POST') - rr=urllib.request.urlopen(r,timeout=5) - rsp=json.loads(str(rr.read(),'utf-8')) - if not rsp['success'] or rsp['score']<0.6: + with open(os.environ['DOCUMENT_ROOT']+'/abuseipdb_key',mode='r',encoding='utf-8') as apikey_f: + apikey=apikey_f.read() + rsp=requests.get('https://api.abuseipdb.com/api/v2/check',params={'ipAddress':urllib.parse.quote(os.environ['REMOTE_ADDR']),'maxAgeInDays':'120','verbose':'','key':apikey.strip()}) + rspj=rsp.json()['data'] + if rspj['totalReports']>0: fail(x=':)') except Exception as e: fail(x=e) @@ -67,3 +66,5 @@ with open(archivp,mode='a',encoding='utf-8') as f: f.write(f'author: {mname}\n') f.write(f'time: {mtime}\n') f.write(f'IP: {os.environ["REMOTE_ADDR"]}\n\n') + +# vim: set noexpandtab : |