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")
def post(self): orgname = self.get_argument("orgname") username = self.get_argument("username") passwd = self.get_argument("passwd") handle = Mysql("sass") sqlstr = "INSERT INTO user_info (orgname,username,password,identity,createtime,updatetime) VALUES ('%s','%s','%s',1,%d,%d)" % ( orgname, username, passwd, time.time(), time.time()) handle.insert(sqlstr)
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)
def post(self): name = self.get_argument("compname") phone = self.get_argument("phonenum") if len(name)==0: self.write("error") if len(phone)==0: self.write("error") handle = Mysql("sass") sqlstr = "INSERT INTO wechat_bind_info (wechatid,companyname,cellphone,createtime,updatetime) VALUES ('aaaaa','%s','%s',%d,%d)"%(name,phone,time.time(),time.time()) handle.insert(sqlstr)
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")
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]
import tornado.web from dbmysql import Mysql from queryitems import QueryItems dbhandle = Mysql() queryhandle = QueryItems() class IndexHandler(tornado.web.RequestHandler): def get(self): iid = self.get_argument("iid", "") res = queryhandle.query_iid(iid) print(res) self.render("index.html", imgurl=res[15], title=res[2], coupons=res[9], price=res[7], reason=res[13], sale_num=res[10]) #self.render("index.html")
def post(self): appid = self.get_argument("appid") appsecret = self.get_argument("appsecret") if appid == "" or appsecret == "": self.write("appid or appsecret is null!") return button1 = [] menu1name = self.get_argument("menu1") menu1type = self.get_argument("menu1_type") menu1value = self.get_argument("menu1_") menu11name = self.get_argument("menu11") menu11type = self.get_argument("menu11_type") menu11value = self.get_argument("menu11_") menu12name = self.get_argument("menu12") menu12type = self.get_argument("menu12_type") menu12value = self.get_argument("menu12_") menu13name = self.get_argument("menu13") menu13type = self.get_argument("menu13_type") menu13value = self.get_argument("menu13_") button1.append((menu1name, menu1type, menu1value)) button1.append((menu11name, menu11type, menu11value)) button1.append((menu12name, menu12type, menu12value)) button1.append((menu13name, menu13type, menu13value)) #print(button1) btn1 = self.get_button_info(button1) #print(btn1) # button2 = [] menu2name = self.get_argument("menu2") menu2type = self.get_argument("menu2_type") menu21name = self.get_argument("menu21") menu21type = self.get_argument("menu21_type") menu22name = self.get_argument("menu22") menu22type = self.get_argument("menu22_type") menu23name = self.get_argument("menu23") menu23type = self.get_argument("menu23_type") menu2value = self.get_argument("menu2_") menu21value = self.get_argument("menu21_") menu22value = self.get_argument("menu22_") menu23value = self.get_argument("menu23_") button2.append((menu2name, menu2type, menu2value)) button2.append((menu21name, menu21type, menu21value)) button2.append((menu22name, menu22type, menu22value)) button2.append((menu23name, menu23type, menu23value)) btn2 = self.get_button_info(button2) #print(btn2) # button3 = [] menu3name = self.get_argument("menu3") menu3type = self.get_argument("menu3_type") menu31name = self.get_argument("menu31") menu31type = self.get_argument("menu31_type") menu32name = self.get_argument("menu32") menu32type = self.get_argument("menu32_type") menu33name = self.get_argument("menu33") menu33type = self.get_argument("menu33_type") menu3value = self.get_argument("menu3_") menu31value = self.get_argument("menu31_") menu32value = self.get_argument("menu32_") menu33value = self.get_argument("menu33_") button3.append((menu3name, menu3type, menu3value)) button3.append((menu31name, menu31type, menu31value)) button3.append((menu32name, menu32type, menu32value)) button3.append((menu33name, menu33type, menu33value)) btn3 = self.get_button_info(button3) #print(btn3) btnlist = [] if btn1 is not None: btnlist.append(btn1) if btn2 is not None: btnlist.append(btn2) if btn3 is not None: btnlist.append(btn3) menu = {"button": btnlist} menustr = json.dumps(menu) #print(json.dumps(menu)) handle = Mysql("sass") sqlstr = "INSERT INTO wechat_menu (appid,appsecret,menujson,createtime,updatetime) VALUES ('%s','%s','%s',%d,%d)" % ( appid, appsecret, menustr, time.time(), time.time()) handle.insert(sqlstr)
def __init__(self): self.__dbhandle = Mysql()