Exemplo n.º 1
0
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()
Exemplo n.º 2
0
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()
Exemplo n.º 3
0
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()
Exemplo n.º 4
0
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()