def msg_func(args, u413): if len(args) == 0: u413.donttype( "F**k off. You'll get your fancy schmancy multi-part UI when it's not 1:30 in the morning." ) return u413.type("Retrieving message...") msg = db.query("SELECT * FROM messages WHERE id=%i;" % int(args)) if len(msg) == 0: u413.type("Invalid message ID.") return msg = msg[0] if int(msg["receiver"] ) != u413.user.userid and u413.user.level < user.User.admin: u413.type("You do not have permission to view that message.") return if not bool(ord(msg["seen"])): db.query("UPDATE messages SET seen=TRUE WHERE id=%i;" % int(msg["id"])) sender = db.query("SELECT username FROM users WHERE id=%i;" % int(msg["sender"]))[0]["username"] u413.donttype( '{{<span class="transmit" data-transmit="MESSAGE {0}">{0}</span>}} <span class="inverted">{1}</span><br/><span class="dim">Sent by {2} {3}</span><br/><br/>{4}' .format(args, msg["topic"], sender, util.ago(msg["sent"]), bbcode.bbcodify(msg["msg"]))) u413.clear_screen() u413.set_context("MESSAGE " + args)
def msg_func(args, u413): u413.type("Retrieving messages...") msgs = db.query("SELECT * FROM messages WHERE receiver=%i;" % u413.user.userid) if len(msgs) == 0: u413.type("You have no messages.") return out = '<table>' for msg in msgs: user = db.query("SELECT username FROM users WHERE id=%i;" % int(msg["sender"]))[0]["username"] if bool(ord(msg["seen"])): out += '<tr><td>{%i}</td><td>%s <span class="dim">sent by %s %s</span></td></tr>' % ( int(msg["id"]), msg["topic"], user, util.ago(msg["sent"])) else: out += '<tr><td>{%i}</td><td><b>%s</b> <span class="dim">sent by %s %s</span></td></tr>' % ( int(msg["id"]), msg["topic"], user, util.ago(msg["sent"])) out += '</table>' u413.set_context("MESSAGES") u413.donttype(out) u413.clear_screen()
def boards_func(args, u413): boards = db.query("SELECT * FROM boards WHERE hidden=FALSE;") boardlist = "<br/><table>" for i in boards: topic = db.query( "SELECT id,posted FROM posts WHERE parent=%i AND topic=TRUE ORDER BY posted DESC LIMIT 1;" % int(i['id'])) boardlist += "<tr>" if len(topic) > 0: topic = topic[0] count = int( db.query( "SELECT COUNT(*) FROM posts WHERE parent=%i AND topic=TRUE;" % int(i['id']))[0]["COUNT(*)"]) posted = db.query( "SELECT posted FROM posts WHERE parent=%i ORDER BY posted DESC LIMIT 1;" % int(topic['id'])) if len(posted) > 0: posted = posted[0]["posted"] boardlist += '<td>{{<span class="transmit" data-transmit="BOARD {0}">{0}</span>}}'.format( str(i['id']) ) + '</td><td>' + i[ 'name'] + ' <span class="dim">%s, last reply %s</span></td>' % ( plural(count, 'topic'), util.ago(posted)) else: boardlist += '<td>{{<span class="transmit" data-transmit="BOARD {0}">{0}</span>}}'.format( str(i['id']) ) + '</td><td>' + i[ 'name'] + ' <span class="dim">%s, last reply %s</span></td>' % ( plural(count, 'topic'), util.ago(topic["posted"])) else: boardlist += '<td>{{<span class="transmit" data-transmit="BOARD {0}">{0}</span>}}'.format( str(i['id'])) + '</td><td>' + i[ 'name'] + ' <span class="dim">no topics</span></td>' boardlist += "</tr>" u413.type("Retrieving list of boards...") u413.donttype(boardlist + '</table>') u413.clear_screen() u413.set_context('')
def msg_func(args, u413): if len(args) == 0: u413.donttype("F**k off. You'll get your fancy schmancy multi-part UI when it's not 1:30 in the morning.") return u413.type("Retrieving message...") msg = db.query("SELECT * FROM messages WHERE id=%i;" % int(args)) if len(msg) == 0: u413.type("Invalid message ID.") return msg = msg[0] if int(msg["receiver"]) != u413.user.userid and u413.user.level < user.User.admin: u413.type("You do not have permission to view that message.") return if not bool(ord(msg["seen"])): db.query("UPDATE messages SET seen=TRUE WHERE id=%i;" % int(msg["id"])) sender = db.query("SELECT username FROM users WHERE id=%i;" % int(msg["sender"]))[0]["username"] u413.donttype( '{{<span class="transmit" data-transmit="MESSAGE {0}">{0}</span>}} <span class="inverted">{1}</span><br/><span class="dim">Sent by {2} {3}</span><br/><br/>{4}'.format( args, msg["topic"], sender, util.ago(msg["sent"]), bbcode.bbcodify(msg["msg"]) ) ) u413.clear_screen() u413.set_context("MESSAGE " + args)
def wall_func(args, u413): r = db.query("SELECT * FROM wall ORDER BY posted;") if args.strip() == '': if len(r) == 0: u413.type("There are no notes on the wall.") else: u413.type("Welcome to the wall!") out = '<br/><table style="padding-right:8px;">' for entry in r: u = db.query("SELECT username FROM users WHERE id=%i" % int(entry["user"])) out += '<tr><td>{{<span class="transmit" data-transmit="WHOIS {0}">{0}</span>}}</td><td style="padding-left:1em;">{1} <span class="dim">{2}</span></td></tr>'.format( u[0]["username"], bbcodify(entry["text"]), util.ago(entry["posted"])) u413.donttype(out + '</table>') u413.set_context("WALL") u413.clear_screen() else: if len(r) >= 256: db.query("DELETE FROM wall ORDER BY posted LIMIT 1;") db.query("INSERT INTO wall(user,text) VALUES(%i,'%s');" % (u413.user.userid, db.escape(util.htmlify(args)))) wall_func('', u413)
def get(self, id): p = self.db.get('select id, linkhash, author, title, ' + 'link, summary, tags, posted_at, ' + 'checks, comments ' + 'from posts where id=%s', id) if not p: raise tornado.web.HTTPError(404) self.postfix(p) comments = self.db.query('select user_id, comment, created_at ' + 'from comments where post_id=%s ' + 'order by created_at asc', id) # http://stackoverflow.com/questions/2026041/help-hacking-grubers-liberal-url-regex r = r'''\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%]))(?:[^\s()<>]+|\([^\s()<>]+\))+(?:\([^\s()<>]+\)|[^`!()\[\]{};:'".,<>?«»“”‘’\s]))''' r = re.compile(r, re.I) for c in comments: c['user'] = self.db.get('select display_name from users ' + 'where id=%s', c.user_id).display_name c['ago'] = util.ago(c.created_at) # don't mess with HTML comments if '<' not in c.comment or '>' not in c.comment: c.comment = re.sub(r, r'<a href="\1">\1</a>', c.comment) c.comment = c.comment.replace('\n', '<br>') self.render('post.html', p = p, comments = comments)
def user_func(args, u413): db.query("DELETE FROM sessions WHERE expire<NOW();") sessions = db.query( "SELECT username,expire FROM sessions WHERE DATE_SUB(DATE_SUB(expire,INTERVAL 5 HOUR),INTERVAL 50 MINUTE)>NOW() AND username!='Guest';" ) users = int(db.query("SELECT COUNT(*) FROM users;")[0]["COUNT(*)"]) u413.type('User statistics:') out = '<br/><div style="padding-left:2em;">Registered users: %i<br/><br/>Active users:<div style="padding-left:2em;">' % users for u in sessions: out += '%s %s<br/>' % ( u["username"], util.ago( int( time.mktime(time.strptime( u["expire"], '%Y-%m-%d %H:%M:%S'))) - 6 * 60 * 60)) out += '</div><br/>Users logged in:<br/><div style="padding-left:2em;">' sessions = db.query( "SELECT DISTINCT username FROM sessions WHERE username!='Guest';") for u in sessions: out += '%s<br/>' % (u["username"]) out += '</div></div>' u413.donttype(out) u413.clear_screen() u413.set_context("")
def postfix(self, p): p['taglist'] = json.loads(p.tags) p['ago'] = util.ago(p.posted_at) p['didcheck'] = self.user_did_check(p.id)
def output_board(board,page,u413): if board==403: u413.type("Access denied.") return output='' if board==0: u413.type("Retrieving all topics...") c=db.count("posts","topic=TRUE AND PARENT IN (SELECT id FROM boards WHERE onall=TRUE)") if c==0 or page<1: page=1 elif page>math.ceil(c/10.0): page=math.ceil(c/10.0) t=db.query("SELECT *,id AS t FROM posts WHERE topic=TRUE AND parent IN (SELECT id FROM boards WHERE onall=TRUE) ORDER BY (SELECT MAX(posted) FROM posts WHERE topic=FALSE AND parent=t OR topic=TRUE AND id=t) DESC LIMIT %i,10;"%((page-1)*10)) t.reverse() pages=math.ceil(c/10.0) if pages==0: pages=1 output+=header.format(0,'BOARD ALL',page,int(math.ceil(c/10.0))) output+='<table>' for topic in t: r=db.count("posts","parent=%i AND topic=FALSE"%int(topic["id"])) last='' if r!=0: last=db.last_post(topic["id"]) lastu=db.get_username(last["owner"]) last=lastby.format(lastu,util.ago(last["posted"])) u=db.get_username(topic["owner"]) output+=alltopic.format(topic["parent"],topic["id"],topic["title"],u,util.ago(topic["posted"]),r,last) if page==1: u413.set_context("BOARD ALL") else: u413.set_context("BOARD ALL %i"%page) else: b=db.query("SELECT * FROM boards WHERE id=%i;"%board) if len(b)==0: u413.type("Board %i does not exist."%board) return else: b=b[0] c=db.count("posts","topic=TRUE AND parent=%i;"%board) u413.donttype(str(c)+' '+str(board)+' '+str(page)) if c==0 or page<1: page=1 elif page>math.ceil(c/10.0): page=math.ceil(c/10.0) u413.donttype(str(c)+' '+str(board)+' '+str(page)) t=db.query("SELECT *,id as t FROM posts WHERE topic=TRUE AND parent=%i ORDER BY (SELECT MAX(posted) FROM posts WHERE topic=FALSE AND parent=t OR topic=TRUE AND id=t) ASC LIMIT %i,10;"%(board,(page-1)*10)) u413.type("Retrieving board topics...") if c==0: output+=header.format(board,b["name"],page,1) else: output+=header.format(board,b["name"],page,int(math.ceil(c/10.0))) output+='<table>' if board==4: for topic in t: anons=db.anons(topic["id"]) r=db.count_posts(topic["id"]) last='' if r!=0: last=db.last_post(topic["id"]) lastu=util.anoncode(anons,last["owner"],topic["owner"]) last=anonlastby.format(lastu,util.ago(last["posted"])) output+=anontopic.format(int(topic["id"]),topic["title"],util.ago(topic["posted"]),r,last) else: for topic in t: r=db.count_posts(topic["id"]) last='' if r!=0: last=db.last_post(topic["id"]) lastu=db.get_username(last["owner"]) last=lastby.format(lastu,util.ago(last["posted"])) u=db.get_username(topic["owner"]) output+=ftopic.format(int(topic["id"]),topic["title"],u,util.ago(topic["posted"]),r,last) if page==1: u413.set_context("BOARD %i"%board) else: u413.set_context("BOARD %i %i"%(board,page)) u413.donttype(output) if board==666: u413.exec_js('$("#frame").addClass("hell");$(".backgroundImage").attr("src","content/hellbg.png").css("opacity",0.9);','$("#frame").removeClass("hell");$(".backgroundImage").attr("src","content/background.jpg").css("opacity",0.1);') u413.clear_screen()
def output_page(topic, page, u413): t = db.select_topic(topic) if t == None: u413.type("Invalid topic ID.") return b = db.get_boardname(t["parent"]) c = db.count_posts(topic) if page == 0 and page > 1 or page != 0 and page > math.ceil(c / 10.0): page = math.ceil(c / 10.0) if page < 1: page = 1 r = db.query( "SELECT * FROM posts WHERE parent=%i ORDER BY id LIMIT %i,10;" % (topic, (page - 1) * 10)) #replies u413.type("Retrieving topic...") if t["parent"] == '4': u413.donttype( header.format(4, b, topic, t["title"], 'OP', util.ago(t["posted"]))) editor = db.get_username(t["editor"]) e = '' if editor != None: if t["editor"] != t["owner"]: e = edited.format(editor, util.ago(t["edited"])) else: e = edited.format('OP', util.ago(t["edited"])) u413.donttype(bbcode.bbcodify(t["post"]) + '<br/>' + e) else: u = db.get_username(t["owner"]) u413.donttype( header.format(int(t["parent"]), b, topic, t["title"], u, util.ago(t["posted"]))) editor = db.get_username(t["editor"]) e = '' if editor != None: e = edited.format(editor, util.ago(t["edited"])) u413.donttype(bbcode.bbcodify(t["post"]) + '<br/>' + e) if c == 0: u413.donttype('Page 1/1<br/>') else: u413.donttype('Page %i/%i<br/>' % (page, math.ceil(c / 10.0))) if c == 0: u413.type("There are no replies.") else: if t['parent'] == '4': anons = db.anons(topic) for reply in r: owner = util.anoncode(anons, reply["owner"], t["owner"]) editor = db.get_username(reply["editor"]) e = '' if editor != None: if reply["editor"] != reply["owner"]: e = edited.format(editor, util.ago(reply["edited"])) else: e = edited.format(owner, util.ago(reply["edited"])) u413.donttype( post.format(owner, int(reply["id"]), bbcode.bbcodify(reply["post"]), util.ago(reply["posted"]), e)) else: for reply in r: owner = db.get_username(reply["owner"]) editor = db.get_username(reply["editor"]) e = '' if editor != None: e = edited.format(editor, util.ago(reply["edited"])) u413.donttype( post.format(owner, int(reply["id"]), bbcode.bbcodify(reply["post"]), util.ago(reply["posted"]), e)) if c == 0: u413.donttype('Page 1/1<br/>') else: u413.donttype('Page %i/%i<br/>' % (page, math.ceil(c / 10.0))) if page == 1: u413.set_context("TOPIC %i" % topic) else: u413.set_context("TOPIC %i %i" % (topic, page)) u413.clear_screen()
def msg_func(args,u413): u413.type("Retrieving messages...") msgs=db.query("SELECT * FROM messages WHERE receiver=%i;"%u413.user.userid) if len(msgs)==0: u413.type("You have no messages.") return out='<table>' for msg in msgs: user=db.query("SELECT username FROM users WHERE id=%i;"%int(msg["sender"]))[0]["username"] if bool(ord(msg["seen"])): out+='<tr><td>{%i}</td><td>%s <span class="dim">sent by %s %s</span></td></tr>'%(int(msg["id"]),msg["topic"],user,util.ago(msg["sent"])) else: out+='<tr><td>{%i}</td><td><b>%s</b> <span class="dim">sent by %s %s</span></td></tr>'%(int(msg["id"]),msg["topic"],user,util.ago(msg["sent"])) out+='</table>' u413.set_context("MESSAGES") u413.donttype(out) u413.clear_screen()
def output_page(topic,page,u413): t=db.select_topic(topic) if t==None: u413.type("Invalid topic ID.") return b=db.get_boardname(t["parent"]) c=db.count_posts(topic) if page==0 and page>1 or page!=0 and page>math.ceil(c/10.0): page=math.ceil(c/10.0) if page<1: page=1 r=db.query("SELECT * FROM posts WHERE parent=%i ORDER BY id LIMIT %i,10;"%(topic,(page-1)*10))#replies u413.type("Retrieving topic...") if t["parent"]=='4': u413.donttype(header.format(4,b,topic,t["title"],'OP',util.ago(t["posted"]))) editor=db.get_username(t["editor"]) e='' if editor!=None: e=edited.format(editor,util.ago(t["edited"])) u413.donttype(bbcode.bbcodify(t["post"])+'<br/>'+e) else: u=db.get_username(t["owner"]) u413.donttype(header.format(int(t["parent"]),b,topic,t["title"],u,util.ago(t["posted"]))) editor=db.get_username(t["editor"]) e='' if editor!=None: e=edited.format(editor,util.ago(t["edited"])) u413.donttype(bbcode.bbcodify(t["post"])+'<br/>'+e) if c==0: u413.donttype('Page 1/1<br/>') else: u413.donttype('Page %i/%i<br/>'%(page,math.ceil(c/10.0))) if c==0: u413.type("There are no replies.") else: if t['parent']=='4': anons=db.anons(topic) for reply in r: owner=util.anoncode(anons,reply["owner"],t["owner"]) editor=db.get_username(reply["editor"]) e='' if editor!=None: e=edited.format(editor,util.ago(reply["edited"])) u413.donttype(post.format(owner,int(reply["id"]),bbcode.bbcodify(reply["post"]),util.ago(reply["posted"]),e)) else: for reply in r: owner=db.get_username(reply["owner"]) editor=db.get_username(reply["editor"]) e='' if editor!=None: e=edited.format(editor,util.ago(reply["edited"])) u413.donttype(post.format(owner,int(reply["id"]),bbcode.bbcodify(reply["post"]),util.ago(reply["posted"]),e)) if c==0: u413.donttype('Page 1/1<br/>') else: u413.donttype('Page %i/%i<br/>'%(page,math.ceil(c/10.0))) if page==1: u413.set_context("TOPIC %i"%topic) else: u413.set_context("TOPIC %i %i"%(topic,page)) u413.clear_screen()
def quote(match): post=db.query("SELECT owner,post,posted,parent FROM posts WHERE id=%i;"%int(match.group(1))); if len(post)==0: return '<div class="quote">%s</div><br/>'%match.group(1) post=post[0] poster=None op=db.query("SELECT id,owner,parent FROM posts WHERE topic=TRUE and id=%i;"%int(post["parent"]))[0] if op["parent"]=='4': anons=db.query("SELECT DISTINCT owner FROM (SELECT owner,posted FROM posts WHERE parent=%i ORDER BY posted ASC) AS p;"%int(op["id"])) poster=util.anoncode(anons,int(post["owner"]),int(op["owner"])) else: poster=db.query("SELECT username FROM users WHERE id=%i;"%int(post["owner"]))[0]["username"] return '<div class="quote"><span class="dim">Posted by %s %s</span><br/>%s</div><br/>'%(poster,util.ago(post["posted"]),post["post"])
def output_board(board,page,u413): if board==403: u413.type("Access denied.") return output='' if board==0: u413.type("Retrieving all topics...") c=db.count("posts","topic=TRUE AND PARENT IN (SELECT id FROM boards WHERE onall=TRUE)") if c==0 or page<1: page=1 elif page>math.ceil(c/10.0): page=math.ceil(c/10.0) t=db.query("SELECT *,id AS t FROM posts WHERE topic=TRUE AND parent IN (SELECT id FROM boards WHERE onall=TRUE) ORDER BY (SELECT MAX(posted) FROM posts WHERE topic=FALSE AND parent=t OR topic=TRUE AND id=t) DESC LIMIT %i,10;"%((page-1)*10)) t.reverse() pages=math.ceil(c/10.0) if pages==0: pages=1 output+=header.format(0,'BOARD ALL',page,int(math.ceil(c/10.0))) output+='<table>' for topic in t: r=db.count("posts","parent=%i AND topic=FALSE"%int(topic["id"])) last='' if r!=0: last=db.last_post(topic["id"]) lastu=db.get_username(last["owner"]) last=lastby.format(lastu,util.ago(last["posted"])) u=db.get_username(topic["owner"]) output+=alltopic.format(topic["parent"],topic["id"],topic["title"],u,util.ago(topic["posted"]),r,last) if page==1: u413.set_context("BOARD ALL") else: u413.set_context("BOARD ALL %i"%page) else: b=db.query("SELECT * FROM boards WHERE id=%i;"%board) if len(b)==0: u413.type("Board %i does not exist."%board) return else: b=b[0] c=db.count("posts","topic=TRUE AND parent=%i;"%board) if c==0 or page<1: page=1 elif page>math.ceil(c/10.0): page=math.ceil(c/10.0) t=db.query("SELECT *,id as t FROM posts WHERE topic=TRUE AND parent=%i ORDER BY (SELECT MAX(posted) FROM posts WHERE topic=FALSE AND parent=t OR topic=TRUE AND id=t) DESC LIMIT %i,10;"%(board,(page-1)*10)) t.reverse() u413.type("Retrieving board topics...") if c==0: output+=header.format(board,b["name"],page,1) else: output+=header.format(board,b["name"],page,int(math.ceil(c/10.0))) output+='<table>' if board==4: for topic in t: anons=db.anons(topic["id"]) r=db.count_posts(topic["id"]) last='' if r!=0: last=db.last_post(topic["id"]) lastu=util.anoncode(anons,last["owner"],topic["owner"]) last=anonlastby.format(lastu,util.ago(last["posted"])) output+=anontopic.format(int(topic["id"]),topic["title"],util.ago(topic["posted"]),r,last) else: for topic in t: r=db.count_posts(topic["id"]) last='' if r!=0: last=db.last_post(topic["id"]) lastu=db.get_username(last["owner"]) last=lastby.format(lastu,util.ago(last["posted"])) u=db.get_username(topic["owner"]) output+=ftopic.format(int(topic["id"]),topic["title"],u,util.ago(topic["posted"]),r,last) if page==1: u413.set_context("BOARD %i"%board) else: u413.set_context("BOARD %i %i"%(board,page)) u413.donttype(output) if board==666: u413.exec_js('$("#frame").addClass("hell");$(".backgroundImage").attr("src","content/hellbg.png").css("opacity",0.9);','$("#frame").removeClass("hell");$(".backgroundImage").attr("src","content/background.jpg").css("opacity",0.1);') u413.clear_screen()
def boards_func(args,u413): boards=db.query("SELECT * FROM boards WHERE hidden=FALSE;") boardlist="<br/><table>" for i in boards: topic=db.query("SELECT id,posted FROM posts WHERE parent=%i AND topic=TRUE ORDER BY posted DESC LIMIT 1;"%int(i['id'])) boardlist+="<tr>" if len(topic)>0: topic=topic[0] count=int(db.query("SELECT COUNT(*) FROM posts WHERE parent=%i AND topic=TRUE;"%int(i['id']))[0]["COUNT(*)"]) posted=db.query("SELECT posted FROM posts WHERE parent=%i ORDER BY posted DESC LIMIT 1;"%int(topic['id'])) if len(posted)>0: posted=posted[0]["posted"] boardlist+='<td>{{<span class="transmit" data-transmit="BOARD {0}">{0}</span>}}'.format(str(i['id']))+'</td><td>'+i['name']+' <span class="dim">%s, last reply %s</span></td>'%(plural(count,'topic'),util.ago(posted)) else: boardlist+='<td>{{<span class="transmit" data-transmit="BOARD {0}">{0}</span>}}'.format(str(i['id']))+'</td><td>'+i['name']+' <span class="dim">%s, last reply %s</span></td>'%(plural(count,'topic'),util.ago(topic["posted"])) else: boardlist+='<td>{{<span class="transmit" data-transmit="BOARD {0}">{0}</span>}}'.format(str(i['id']))+'</td><td>'+i['name']+' <span class="dim">no topics</span></td>' boardlist+="</tr>" u413.type("Retrieving list of boards...") u413.donttype(boardlist+'</table>') u413.clear_screen() u413.set_context('')
def msg_func(args,u413): if len(args)==0: u413.donttype("F**k off. You'll get your fancy schmancy multi-part UI when it's not 1:30 in the morning.") return u413.type("Retrieving message...") msg=db.query("SELECT * FROM messages WHERE id=%i;"%int(args)) if len(msg)==0: u413.type("Invalid message ID.") return msg=msg[0] sender=db.query("SELECT username FROM users WHERE id=%i;"%int(msg["sender"]))[0]["username"] u413.donttype('{{<span class="transmit" data-transmit="MESSAGE {0}">{0}</span>}} <span class="inverted">{1}</span><br/><span class="dim">Sent by {2} {3}</span><br/><br/>{4}'.format(args,msg["topic"],sender,util.ago(msg["sent"]),bbcode.bbcodify(msg["msg"]))) u413.clear_screen() u413.set_context("MESSAGE "+args)
def wall_func(args,u413): r=db.query("SELECT * FROM wall ORDER BY posted;") if args.strip()=='': if len(r)==0: u413.type("There are no notes on the wall.") else: u413.type("Welcome to the wall!") out='<br/><table style="padding-right:8px;">' for entry in r: u=db.query("SELECT username FROM users WHERE id=%i"%int(entry["user"])) out+='<tr><td>{{<span class="transmit" data-transmit="WHOIS {0}">{0}</span>}}</td><td style="padding-left:1em;">{1} <span class="dim">{2}</span></td></tr>'.format(u[0]["username"],bbcodify(entry["text"]),util.ago(entry["posted"])) u413.donttype(out+'</table>') u413.set_context("WALL") u413.clear_screen() else: if len(r)>=256: db.query("DELETE FROM wall ORDER BY posted LIMIT 1;") db.query("INSERT INTO wall(user,text) VALUES(%i,'%s');"%(u413.user.userid,db.escape(util.htmlify(args)))) wall_func('',u413)
def nsfwall_func(args,u413): r=db.query("SELECT * FROM nsfwall ORDER BY posted;") if args.strip()=='': if len(r)==0: u413.type("There are no notes on the nsfwall.") else: u413.type("The wall for all your NSFW needs.") out='<br/><table style="padding-right:8px;">' for entry in r: u=db.query("SELECT username FROM users WHERE id=%i"%int(entry["user"])) out+='<tr><td>{%s}</td><td style="padding-left:1em;">%s <span class="dim">%s</span></td></tr>'%(u[0]["username"],bbcodify(entry["text"]),util.ago(entry["posted"])) u413.donttype(out+'</table>') u413.set_context("NSFWALL") u413.clear_screen() else: if len(r)>=256: db.query("DELETE FROM nsfwall ORDER BY posted LIMIT 1;") db.query("INSERT INTO nsfwall(user,text) VALUES(%i,'%s');"%(u413.user.userid,db.escape(util.htmlify(args)))) nsfwall_func('',u413)