Exemplo n.º 1
0
	def get(self):
		uri_list = self.request.uri.split('/')
		roomid = int(uri_list[-1])
	
		self.set_secure_cookie("roomid", str(roomid),1)
		cookie_user = self.get_secure_cookie("username")
		if cookie_user:
			usertype = common.get_usertype(cookie_user)
			roominfo = common.getRoomInfo(roomid)
			if roominfo is None:
				#跳转404
				self.render("404err.html")
			#成功合法跳转某聊天房
			else:
				sql = "select username,msg,created_time from message where roomid = %d order by msgid \
						desc limit 100" % (roomid)
				cursor = conn.execute(sql)
				#最近50条聊天记录
				msginfoList = list(cursor.fetchall())
				msginfoList.reverse()
				
				self.render('chat.html', cookieUser=cookie_user, usertype = usertype,
							roominfo=roominfo, msginfo=msginfoList)
		else:
			self.render('login.html', cookieUser=None, Error = False)
Exemplo n.º 2
0
    def get(self):
        uri_list = self.request.uri.split('/')
        roomid = int(uri_list[-1])

        self.set_secure_cookie("roomid", str(roomid), 1)
        cookie_user = self.get_secure_cookie("username")
        if cookie_user:
            # usertype = common.get_usertype(cookie_user)
            roominfo = common.getRoomInfo(roomid)
            if roominfo is None:
                # jump to 404
                self.render("404err.html")
            # success to room
            else:
                sql = "select username,msg,created_time from message where roomid = %d order by msgid \
						desc limit 100" % (roomid)
                cursor = conn.execute(sql)
                #last 100 msgs
                msginfoList = list(cursor.fetchall())
                msginfoList.reverse()

                self.render('chat.html',
                            cookieUser=cookie_user,
                            roominfo=roominfo,
                            msginfo=msginfoList)
        else:
            self.render('login.html', cookieUser=None, Error=False)
Exemplo n.º 3
0
	def get(self):
		uri_list = self.request.uri.split('/')
		roomid = int(uri_list[-1])

		self.set_secure_cookie("roomid", str(roomid),1)
		cookie_user = self.get_secure_cookie("username")
		if cookie_user:
			# usertype = common.get_usertype(cookie_user)
			roominfo = common.getRoomInfo(roomid)
			if roominfo is None:
				# jump to 404
				self.render("404err.html")
			# success to room
			else:
				sql = "select username,msg,created_time from message where roomid = %d order by msgid \
						desc limit 100" % (roomid)
				cursor = conn.execute(sql)
				#last 100 msgs
				msginfoList = list(cursor.fetchall())
				msginfoList.reverse()
				# for each in msginfoList:
					# each[1] = re.sub("\[em_([0-9]*)\]", '<img src="/static/face/1.gif" border="0" />', each[1])
				
				self.render('chat.html', cookieUser=cookie_user,
							roominfo=roominfo, msginfo=msginfoList)
		else:
			self.render('login.html', cookieUser=None, Error = False)
Exemplo n.º 4
0
	def get(self):
		uri_list = self.request.uri.split('/')
		roomid = int(uri_list[-1])
		#print 'roomid: ',roomid
		self.set_secure_cookie("roomid", str(roomid),1)
		cookie_user = self.get_secure_cookie("username")
		if cookie_user:
			usertype = common.get_usertype(cookie_user)
			roominfo = common.getRoomInfo(roomid)
			print roominfo
			self.render('chat.html', cookieUser=cookie_user, usertype = usertype,
						roominfo=roominfo)
		else:
			self.render('login.html', cookieUser=None, Error = False)
Exemplo n.º 5
0
    def get(self, action=None):
        uri_list = self.request.uri.split('/')
        roomid = int(uri_list[-1])

        self.set_secure_cookie("roomid", str(roomid), 1)
        cookie_user = self.get_secure_cookie("username")
        try:
            cookie_user = cookie_user.decode()
        except:
            cookie_user = cookie_user

        client_id = self.room_handler.add_room(roomid, cookie_user)
        self.set_cookie("ftc_cid", str(client_id))

        if cookie_user:
            usertype = common.get_usertype(cookie_user)
            roominfo = common.getRoomInfo(roomid)
            if roominfo is None:
                #跳转404
                self.render("404err.html")
            #成功合法跳转某聊天房
            else:
                sql = "select username,msg,created_time from message where roomid = %d order by msgid \
						desc limit 100" % (roomid)
                cursor = conn.execute(sql)
                #最近50条聊天记录
                msginfoList = list(cursor.fetchall())
                msginfoList.reverse()
                for msg in msginfoList:
                    if msg.get("username") == cookie_user:
                        msg["userself"] = True
                # render
                self.render('chat.html',
                            cookieUser=cookie_user,
                            usertype=usertype,
                            roominfo=roominfo,
                            msginfo=msginfoList)
        else:
            self.render('login.html', cookieUser=None, Error=False)