-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfirmation.py
More file actions
79 lines (72 loc) · 2.6 KB
/
confirmation.py
File metadata and controls
79 lines (72 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/python3
import os
import sys
restricted = "restricted"
sys.path.append(os.path.abspath(restricted))
from cgi import FieldStorage
import pymysql as db
import passwords
from html import escape
form_data = FieldStorage()
confirm = form_data.getfirst("confirmUrl")
if not confirm:
confirm = ""
confirm = escape(confirm, quote=False)
def check_confirmation(confirm):
connection = db.connect(passwords.serverip, passwords.servername, passwords.serverpass, passwords.db_name)
cursor = connection.cursor(db.cursors.DictCursor)
cursor.execute("""SELECT confirmUrl
FROM users
WHERE confirmUrl = %s""", (confirm))
for row in cursor.fetchall():
if confirm == row["confirmUrl"]:
connection.commit()
cursor.close()
connection.close()
return True
connection.commit()
cursor.close()
connection.close()
return False
if check_confirmation(confirm):
connection = db.connect(passwords.serverip, passwords.servername, passwords.serverpass, passwords.db_name)
cursor = connection.cursor(db.cursors.DictCursor)
cursor.execute("""UPDATE users
SET confirm = 1, confirmUrl = NULL
WHERE confirmUrl = %s""", (confirm))
connection.commit()
cursor.close()
connection.close()
print("Content-Type: text/html")
print()
print("""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Confirmed</title>
<link rel="stylesheet" href="index.css" />
<script src="js/redirect.js" type="module"></script>
</head>
<body>
<section class="confirmation">
<p>Your account has been validated you can login now, redirecting in 5 seconds.</p>
</section>
</body>
</html>""")
else:
print("Content-Type: text/html")
print()
print("""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Confirmed</title>
<link rel="stylesheet" href="css/index.css" />
<script src="js/redirect.js" type="module"></script>
</head>
<body>
<section class="confirmation">
<p>Woah you aren't supposed to be here, getting rid of you from this premise in 5 seconds</p>
</section>
</body>
</html>""")