-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabasekentel.py
174 lines (146 loc) · 5.13 KB
/
databasekentel.py
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
'''
K7 KENTEL DATABASE AND AUTH MODULE BY EFE AKARÖZ
2022
JULY
13TH
WITH PYTHON AND C
EDITOR:VIM
'''
import subprocess
import os
class db:
def __init__(self,project_name):
self.projname = project_name
def createuser(self,username,password,fullname=None,city=None,birthyear=None,talents=None):
if username == None:
return {"SCC":False,"err":"USERNAME CAN'T BE NONE!","project":self.projname}
if password == None:
return {"SCC":False,"err":"YOU NEED TO SPECIFY PASSWORD!","project":self.projname}
try:
os.listdir("users")
except:
os.system("mkdir users")
try:
open(f"users/{username}.K7USERFILE","r")
return {"SCC":False,"err":"USER EXISTS","project":self.projname}
except:
checkout = str(subprocess.check_output(f"./auth-module login {username} {password}",shell=True))
try:
checkout.split("200")[1]
return {"SCC":False,"err":"USER EXISTS","project":self.projname}
except:
userfile = open(f"users/{username}.K7USERFILE","a")
if fullname == None:
fullname = "EMPTY"
if city == None:
city="EMPTY"
if birthyear ==None:
birthyear = "EMPTY"
if talents == None:
talents = "EMPTY"
userfile.write("PROJECT={};--;\n".format(self.projname))
userfile.write("USERNAME={};--;\n".format(username))
userfile.write("PASSWORD={};--;\n".format(password))
userfile.write("FULLNAME={};--;\n".format(fullname))
userfile.write("CITY={};--;\n".format(city))
userfile.write("BIRTHYEAR={};--;\n".format(birthyear))
userfile.write("TALENTS={}".format(talents))
userfile.write(";--;")
userfile.close()
theout = str(subprocess.check_output(f"./auth-module register {username} {password}",shell=True))
try:
theout.split("200")[1]
return {"SCC":True,"err":"","project":self.projname}
except:
return {"SCC":False,"err":"C MODULE FAILED!","project":self.projname}
def login(self,username,password):
try:
out = str(subprocess.check_output(f"./auth-module login {username} {password}",shell=True))
except Exception as e:
return {"SCC":False,"err":"MODULE ERR","porject":self.projname}
try:
out.split("200")[1]
return {"SCC":True,"err":"","project":self.projname}
except Exception as e:
try:
out.split("403p")[1]
return {"SCC":False,"err":"WRONG PASSWORD","project":self.projname}
except:
return {"SCC":False,"err":"USER NOT EXISTS","project":self.projname}
def getuser(self,username):
try:
profilefile = open(f"users/{username}.K7USERFILE","r").read()
except:
return {"SCC":False,"err":"USER DOES NOT EXIST","platform":self.projname}
information = profilefile.split(";--;")
talents = str(profilefile.split("TALENTS=")[1]).replace(";--;","")
for i in information:
try:
i.split("TALENTS=")[1]
break
except:
try:
projectname = i.split("PROJECT=")[1]
except:
try:
username = i.split("USERNAME=")[1]
except:
try:
password = i.split("PASSWORD=")[1]
except:
try:
fullname = i.split("FULLNAME=")[1]
except:
try:
city = i.split("CITY=")[1]
except:
try:
birthyear = i.split("BIRTHYEAR")[1]
except:
pass
return {"SCC":True,"projectname":projectname,"username":username,"password":password,"fullname":fullname,"city":city,"birthyear":birthyear,"talents":talents}
def changepassword(self,username,password,newpassword):
outcheck = str(subprocess.check_output(f"./auth-module login {username} {password}",shell=True))
try:
outcheck.split("200")[1]
authfileopen = open("auth.txt","r")
data = authfileopen.readlines()
for a in data:
if str(a.split("🇹🇷")[0]) == username:
print("a")
if str(a.split("🇹🇷")[1].replace("\n","")) == password:
print("b")
data[data.index(a)] =f"{username}🇹🇷{newpassword}\n"
break
else:
pass
else:
pass
with open('auth.txt', 'w') as outauth:
outauth.writelines(data)
userfilepasswordchange = open(f"users/{username}.K7USERFILE","r")
userfilepasswordchangedata = userfilepasswordchange.readlines()
userfilepasswordchangedata[2] = f"PASSWORD={newpassword};--;\n"
with open(f"users/{username}.K7USERFILE", 'w') as outauth2:
outauth2.writelines(userfilepasswordchangedata)
return {"SCC":True,"err":"","project":self.projname}
except Exception as e:
print(e)
return {"SCC":False,"err":"PASSWORD OR USERNAME IS NOT CORRECT","project":self.projname}
def removeuser(self,username,password):
checkout = str(subprocess.check_output(f"./auth-module login {username} {password}",shell=True))
try:
checkout.split("200")[1]
os.system(f"rm users/{username}.K7USERFILE")
allusers = open("auth.txt","r")
allusersdata = allusers.readlines()
for a in allusersdata:
if a.split("🇹🇷")[1] == password and a.split("🇹🇷")[0] == username:
allusersdata[allusersdata.index(a)]=""
break
with open('auth.txt', 'w') as thedata:
thedata.writelines(allusersdata)
return {"SCC":True,"err":"","project":self.projname}
except Exception as e:
#print(e)
return {"SCC":False,"err":"INVALID EMAIL OR PASSWORD","project":self.projname}