cgi fix
This commit is contained in:
parent
6a7fe86063
commit
00080c28c0
1 changed files with 0 additions and 0 deletions
36
web/nfc-theme/static/cgi/track.cgi
Normal file
36
web/nfc-theme/static/cgi/track.cgi
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/python3
|
||||
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')
|
||||
Loading…
Add table
Add a link
Reference in a new issue