Beispiel #1
0
def topic_func(args, u413):
    params = args.split(' ', 2)
    if len(params) == 0 or not util.isint(params[0]):
        u413.type("Invalid topic ID.")
        return
    topic = int(params[0])
    if len(params) == 1:
        page = 1
        output_page(topic, 1, u413)
    elif len(params) == 2:
        if params[1].upper() == "REPLY":
            u413.j["Command"] = "REPLY"
            u413.cmddata["topic"] = topic
            u413.continue_cmd()
        else:
            page = 1
            if util.isint(params[1]):
                page = int(params[1])
            elif params[1].upper() == 'LAST':
                page = db.count_posts(topic)
                if page == 0:
                    page = 1
                else:
                    page = math.ceil(page / 10.0)
            output_page(topic, page, u413)
    elif params[1].upper() == "REPLY":
        db.query(
            "INSERT INTO posts (topic,title,parent,owner,editor,post,locked,edited,posted) VALUES(FALSE,'',%i,%i,0,'%s',FALSE,NULL,NOW());"
            % (topic, u413.user.userid, db.escape(util.htmlify(params[3]))))
        u413.type("Reply made successfully.")
Beispiel #2
0
def board_func(args,u413):
	args=args.split(' ')
	if len(args)==0:
		u413.type('Invalid board ID.')
	#BOARD id
	elif len(args)==1:
		if args[0].upper()=="ALL":
			args[0]=0
		if util.isint(args[0]):
			output_board(int(args[0]),1,u413)
		else:
			u413.type('Invalid board ID.')
	#BOARD id page
	else:
		if args[0].upper()=="ALL":
			args[0]=0
		if args[1].upper()=='LAST':
			args[1]=db.count_posts(args[0])
			if args[1]==0:
				args[1]=1
			else:
				args[1]=math.ceil(args[1]/10.0)
		elif not util.isint(args[1]):
			args[1]=1
		else:
			args[1]=int(args[1])
		output_board(int(args[0]),args[1],u413)
Beispiel #3
0
def topic_func(args,u413):
	params=args.split(' ',2)
	if len(params)==0 or not util.isint(params[0]):
		u413.type("Invalid topic ID.")
		return
	topic=int(params[0])
	if len(params)==1:
		page=1
		output_page(topic,1,u413)
	elif len(params)==2:
		if params[1].upper()=="REPLY":
			u413.j["Command"]="REPLY"
			u413.cmddata["topic"]=topic
			u413.continue_cmd()
		else:
			page=1
			if util.isint(params[1]):
				page=int(params[1])
			elif params[1].upper()=='LAST':
				page=db.count_posts(topic)
				if page==0:
					page=1
				else:
					page=math.ceil(page/10.0)
			output_page(topic,page,u413)
	elif params[1].upper()=="REPLY":
		db.query("INSERT INTO posts (topic,title,parent,owner,editor,post,locked,edited,posted) VALUES(FALSE,'',%i,%i,0,'%s',FALSE,NULL,NOW());"%(topic,u413.user.userid,db.escape(util.htmlify(params[3]))))
		u413.type("Reply made successfully.")
Beispiel #4
0
def board_func(args,u413):
	args=args.split(' ')
	if len(args)==0:
		u413.type('Invalid board ID.')
	#BOARD id
	elif len(args)==1:
		if args[0].upper()=="ALL":
			args[0]=0
		if util.isint(args[0]):
			output_board(int(args[0]),1,u413)
		else:
			u413.type('Invalid board ID.')
	#BOARD id page
	else:
		if args[0].upper()=="ALL":
			args[0]=0
		if args[1].upper()=='LAST':
			args[1]=db.count_posts(args[0])
			if args[1]==0:
				args[1]=1
			else:
				args[1]=math.ceil(args[1]/10.0)
		elif not util.isint(args[1]):
			args[1]=1
		else:
			args[1]=int(args[1])
		output_board(int(args[0]),args[1],u413)
Beispiel #5
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()
Beispiel #6
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()
Beispiel #7
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()
Beispiel #8
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()