This commit is contained in:
randogoth 2023-05-21 22:55:22 +03:00
parent 23948442cb
commit 12e3fe43d2
2 changed files with 1 additions and 38 deletions

View file

@ -1,37 +0,0 @@
#!/usr/bin/python3
print("Content-type:text/html\r\n\r\n")
import cgi
import json
import os
args = cgi.FieldStorage()
def track():
if args['hash']:
hash = str(args['hash'])
ua = str(args['ua'])
url = str(args['url'] or os.getenv('HTTP_REFERER'))
if os.path.exists('db.json'):
with open('db.json', 'r') as db:
db = json.loads(db.read())
else:
db = {}
if hash in db.keys():
visits = db[hash]['visits']
else:
visits = list()
visits.append(url)
visits = list(set(visits))
db.update({
hash : {
'visits' : visits,
'agent' : ua
}
})
with open('db.json', 'w+') as dbw:
dbw.write(json.dumps(db, indent=4))
print(str(len(db[hash])))
else:
print('hash missing')