Commit bc399c5f by vuj

2018-01-17 v0.1.10 Mail Info

2 parents df3746f7 315d06fc
2018-01-17 v0.1.8 Mail Info
2018-01-17 v0.1.10 Mail Info
2018-01-19 v0.1.9 Cookie 1 Tag
2018-01-19 v0.1.8 small fixes
2018-01-17 v0.1.7 Posttools Monitoring 2018-01-17 v0.1.7 Posttools Monitoring
2018-01-16 v0.1.6 Posttools Fix 2018-01-16 v0.1.6 Posttools Fix
2018-01-16 v0.1.5 Posttools 2018-01-16 v0.1.5 Posttools
......
...@@ -112,13 +112,13 @@ class mailcnf_domain(ncauth_base): ...@@ -112,13 +112,13 @@ class mailcnf_domain(ncauth_base):
def update_virtual_domains(self, id,name,active,group_id): def update_virtual_domains(self, id,name,active,group_id):
query = "UPDATE virtual_domains SET name='"+str(name)+"' ,active='"+str(active)+"' ,group_id='"+str(group_id)+"' WHERE id="+str(id)+" " query = "UPDATE virtual_domains SET name='"+str(name)+"' ,active='"+str(active)+"' ,group_id='"+str(group_id)+"' WHERE id="+str(id)+" "
try: try:
self.write(query) # self.write(query)
db_config = read_db_config() db_config = read_db_config()
conn = MySQLConnection(**db_config) conn = MySQLConnection(**db_config)
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute(query) cursor.execute(query)
conn.commit() conn.commit()
self.write(query) # self.write(query)
except Error as error: except Error as error:
print(error) print(error)
finally: finally:
...@@ -129,7 +129,7 @@ class mailcnf_domain(ncauth_base): ...@@ -129,7 +129,7 @@ class mailcnf_domain(ncauth_base):
def insert_virtual_domain(self,name,active,group_id=0): def insert_virtual_domain(self,name,active,group_id=0):
query = "INSERT INTO virtual_domains(name,active,group_id) VALUE('"+name+"','"+str(active)+"','"+str(group_id)+"');" query = "INSERT INTO virtual_domains(name,active,group_id) VALUE('"+name+"','"+str(active)+"','"+str(group_id)+"');"
self.write(query) # self.write(query)
# args = (domain_id,password,email,sent_mail,active) # args = (domain_id,password,email,sent_mail,active)
insert_id = '' insert_id = ''
try: try:
...@@ -167,7 +167,7 @@ class mailcnf_domain(ncauth_base): ...@@ -167,7 +167,7 @@ class mailcnf_domain(ncauth_base):
else: else:
query = " SELECT id,name,description,transport,modified,active,deleted,group_id FROM `virtual_domains`" query = " SELECT id,name,description,transport,modified,active,deleted,group_id FROM `virtual_domains`"
try: try:
print(query) #print(query)
db_config = read_db_config() db_config = read_db_config()
conn = MySQLConnection(**db_config) conn = MySQLConnection(**db_config)
cursor = conn.cursor() cursor = conn.cursor()
...@@ -193,7 +193,7 @@ class mailcnf_domain(ncauth_base): ...@@ -193,7 +193,7 @@ class mailcnf_domain(ncauth_base):
def edit_virtual_domains_by_id(self, id,uid): def edit_virtual_domains_by_id(self, id,uid):
query = " SELECT * FROM `virtual_domains` WHERE `id`='"+str(id)+"'" query = " SELECT id,name,description,transport,modified,active,deleted,group_id FROM `virtual_domains` WHERE `id`='"+str(id)+"'"
dictdata =[] dictdata =[]
# self.write(query) # self.write(query)
counter=0 counter=0
......
...@@ -184,7 +184,7 @@ class mailcnf_user(ncauth_base): ...@@ -184,7 +184,7 @@ class mailcnf_user(ncauth_base):
password=crypt.crypt(pw1,'$1$1x87mPvWg') password=crypt.crypt(pw1,'$1$1x87mPvWg')
query = "INSERT INTO virtual_users(domain_id,password,email,sent_mail,active,quota,group_id) VALUES('"+domain_id+"','"+password+"','"+email+"','"+sent_mail+"','"+active+"','"+quota+"','"+group_id+"')" query = "INSERT INTO virtual_users(domain_id,password,email,sent_mail,active,quota,group_id) VALUES('"+domain_id+"','"+password+"','"+email+"','"+sent_mail+"','"+active+"','"+quota+"','"+group_id+"')"
self.write(query) #self.write(query)
# args = (domain_id,password,email,sent_mail,active) # args = (domain_id,password,email,sent_mail,active)
insert_id = '' insert_id = ''
try: try:
......
import tornado import tornado
import tornado.web
from tornado.web import RequestHandler
#import tornado.web
#import tornado.websocket.WebSocketHandler
#import tornado.web.RequestHandler
class ncauth_base(tornado.web.RequestHandler): class ncauth_base(tornado.web.RequestHandler):
def get_current_user(self): def get_current_user(self):
return self.get_secure_cookie("user") #test=RequestHandler.get_secure_cookie_key_version("user");
#self.write(test)
for cookie_key in self.request.cookies.keys():
cookie = self.request.cookies[cookie_key]
print(cookie_key, cookie['expires'], cookie.output())
return self.get_secure_cookie("user",min_version=2,max_age_days=1)
...@@ -14,19 +14,21 @@ class ncauth_user(ncauth_base): ...@@ -14,19 +14,21 @@ class ncauth_user(ncauth_base):
# '</form></body></html>') # '</form></body></html>')
def post(self): def post(self):
self.set_secure_cookie("user", self.get_argument("name")) self.set_secure_cookie("user", self.get_argument("name"),expires_days=1,secure=True)
# self.set_secure_cookie("expires_days", "1")
pw=self.get_argument("password") pw=self.get_argument("password")
username=self.get_argument("name") username=self.get_argument("name")
salt='xy4$rt' salt='xy4$rt'
#hashlib.sha512(pw.encode('utf-8') + salt.encode('utf-8')).hexdigest() #hashlib.sha512(pw.encode('utf-8') + salt.encode('utf-8')).hexdigest()
if hashlib.md5(pw.encode('utf-8')).hexdigest() == self.getuserpw(username): if hashlib.md5(pw.encode('utf-8')).hexdigest() == self.getuserpw(username):
self.set_secure_cookie("user", self.get_argument("name")) self.set_secure_cookie("user", self.get_argument("name"),expires_days=1,secure=True)
self.set_secure_cookie("incorrect", "0") self.set_secure_cookie("incorrect", "0",expires_days=1,secure=True)
self.write("Jo")
# self.write("Jo")
self.redirect("/") self.redirect("/")
else: else:
self.write("Hello, world"+self.get_argument("name")+' '+self.get_argument("password")+ ' /// '+hashlib.md5(pw.encode('utf-8')).hexdigest() +' vs. '+self.getuserpw(username)) # self.write("Hello, world"+self.get_argument("name")+' '+self.get_argument("password")+ ' /// '+hashlib.md5(pw.encode('utf-8')).hexdigest() +' vs. '+self.getuserpw(username))
self.set_secure_cookie("incorrect", "1") self.set_secure_cookie("incorrect", "1",expires_days=1,secure=True)
self.redirect("/login") self.redirect("/login")
......
...@@ -64,7 +64,7 @@ def make_app(): ...@@ -64,7 +64,7 @@ def make_app():
template_path=os.path.join(os.path.dirname(__file__), "templates"), template_path=os.path.join(os.path.dirname(__file__), "templates"),
static_path=os.path.join(os.path.dirname(__file__), "static"), static_path=os.path.join(os.path.dirname(__file__), "static"),
debug=True, debug=True,
cookie_secret='ancsrvcnf2' cookie_secret='axcermnogtlehdded12334'
) )
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<tr> <tr>
<td>Aktiv: </td> <td>Aktiv: </td>
<td><input type="checkbox" size="40" name="active" {% if list[5] == 1 %} value="1" checked {% else %} value="0" {% end %}></td> <td><input type="checkbox" size="40" name="active" {% if list[5] == 1 %} value="1" checked {% else %} value="1" {% end %}></td>
</tr> </tr>
<input type="hidden" size="70" name="fnc" value="submitedit"> <input type="hidden" size="70" name="fnc" value="submitedit">
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
</tr> </tr>
<tr> <tr>
<td>Aktiv: </td> <td>Aktiv: </td>
<td><input type="checkbox" size="40" name="active" {% if list[5] == 1 %} value="1" checked {% else %} value="0" {% end %}></td> <td><input type="checkbox" size="40" name="active" {% if list[5] == 1 %} value="1" checked {% else %} value="1" {% end %}></td>
</tr> </tr>
<input type="hidden" size="70" name="fnc" value="submitedit"> <input type="hidden" size="70" name="fnc" value="submitedit">
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<tr> <tr>
<td>Aktiv: </td> <td>Aktiv: </td>
<td><input type="checkbox" size="40" name="active" {% if list[5] == 1 %} value="1" checked {% else %} value="0" {% end %}></td> <td><input type="checkbox" size="40" name="active" {% if list[5] == 1 %} value="1" checked {% else %} value="1" {% end %}></td>
</tr> </tr>
<input type="hidden" size="70" name="fnc" value="submitedit"> <input type="hidden" size="70" name="fnc" value="submitedit">
......
...@@ -45,11 +45,11 @@ ...@@ -45,11 +45,11 @@
<tr> <tr>
<td>Sent Mail:</td> <td>Sent Mail:</td>
<td><input type="checkbox" size="40" name="sent_mail" {% if list[6] == 1 %} value="1" checked {% else %} value="0" {% end %} ></td> <td><input type="checkbox" size="40" name="sent_mail" {% if list[6] == 1 %} value="1" checked {% else %} value="1" {% end %} ></td>
</tr> </tr>
<tr> <tr>
<td>Aktiv: </td> <td>Aktiv: </td>
<td><input type="checkbox" size="40" name="active" {% if list[9] == 1 %} value="1" checked {% else %} value="0" {% end %}></td> <td><input type="checkbox" size="40" name="active" {% if list[9] == 1 %} value="1" checked {% else %} value="1" {% end %}></td>
</tr> </tr>
<input type="hidden" size="70" name="fnc" value="submitedit"> <input type="hidden" size="70" name="fnc" value="submitedit">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!