コード例 #1
0
ファイル: loginhandler.py プロジェクト: winjia/Thanos
 def post(self):
     username = self.get_argument("username")
     passwd = self.get_argument("password")
     usertype = self.get_argument("usertype")
     print(usertype)
     if username == "" or passwd == "":
         self.write("用户名或者密码为空")
         return
     md5passwd = hashlib.md5()
     #md5passwd.update(passwd)
     #passwd = md5passwd.hexdigest()
     handle = Mysql("sass")
     sqlstr = "SELECT * FROM user_info WHERE username='******' and isdelete!=1" % (
         username)
     res = handle.query(sqlstr)
     res = res[0]
     print(res)
     print("-=-=-=-=")
     if res is None:
         self.redirect("/login")
     if res[3] == passwd:
         print("aa:", username)
         self.set_secure_cookie("username", username)
         if res[4] == 0:
             print("admin======")
             self.redirect("/usermanage")
         elif res[4] == 1:
             print("org======")
             self.redirect("/patent/0")
         elif res[4] == 2:
             print("staff======")
             self.redirect("/staff")
     else:
         self.write("login error")
         self.redirect("/login")
コード例 #2
0
 def get(self):
     handle = Mysql("sass")
     sqlstr = "SELECT orgname,username FROM user_info WHERE identity=1 and isdelete=0"
     res = handle.query(sqlstr)
     print(res)
     data = []
     for i, elem in enumerate(res):
         data.append({"idx": i, "orgname": elem[0], "username": elem[1]})
     self.render("manage_admin.html", userdata=data)
コード例 #3
0
class QueryItems():
    def __init__(self):
        self.__dbhandle = Mysql()

    def query(self, word):
        sqlstr = "SELECT * FROM items_info WHERE title LIKE \"%" + word + "%\" limit 1"
        loghandle.write_log("sql:" + sqlstr)
        loghandle.write_log("safsaf1")
        res = self.__dbhandle.query(sqlstr)
        loghandle.write_log("safsaf2")
        if len(res) == 0:
            return None
        return res[0]

    def query_iid(self, iid):
        sqlstr = "SELECT * FROM items_info WHERE iid=" + str(iid)
        res = self.__dbhandle.query(sqlstr)
        if len(res) == 0:
            return None
        return res[0]
コード例 #4
0
ファイル: loginhandler.py プロジェクト: winjia/Thanos
 def wrapper(self, *args, **kwargs):
     user = self.current_user
     handle = Mysql("sass")
     user = tornado.escape.xhtml_escape(user)
     sqlstr = "SELECT * FROM user_info WHERE username='******' and isdelete!=1" % (
         user)
     res = handle.query(sqlstr)
     if res is None:
         raise Exception("404")
     else:
         res = res[0]
         print("info", res)
         if res[3] in rolelist:
             func(self, *args, **kwargs)
         else:
             raise Exception("404")