cgi shenanigans
This commit is contained in:
parent
380505695e
commit
6a7fe86063
4 changed files with 79 additions and 1982 deletions
1981
package-lock.json
generated
1981
package-lock.json
generated
File diff suppressed because it is too large
Load diff
39
userdb/db.py
Normal file
39
userdb/db.py
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import json
|
||||
import os
|
||||
from flask import Flask, request
|
||||
from functools import reduce
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route("/track", methods = ['GET'])
|
||||
def track():
|
||||
if request.method == 'GET' and request.args.get('hash'):
|
||||
hash = str(request.args.get('hash'))
|
||||
ua = str(request.args.get('ua'))
|
||||
url = str(request.values.get("url") or request.headers.get("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))
|
||||
|
||||
return str(len(db[hash]))
|
||||
else:
|
||||
return 'hash missing'
|
||||
|
||||
app.run()
|
||||
|
|
@ -90,4 +90,7 @@ function getFingerprint() {
|
|||
return hash;
|
||||
};
|
||||
|
||||
console.log(getFingerprint());
|
||||
fetch('https://nmns.place/track.py?' + new URLSearchParams({
|
||||
hash: getFingerprint(),
|
||||
ua: ua,
|
||||
}));
|
||||
36
web/nfc-theme/static/track.py
Normal file
36
web/nfc-theme/static/track.py
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