def allstart(): ip = request.headers.get('X-Real-Ip') or request.environ.get('REMOTE_ADDR') local.r = sx.mydict(ua=request.headers.get('User-Agent'), ip=ip, kuk=sx.mydict(request.cookies), fz=sx.mydict(request.POST), getl=sx.mydict(request.GET)) local.r.auth = local.r.kuk.auth
def blog_tag(tag): blogs = api.lst('tags/%s' % hsh(tag)) comms = mydict({n: len(api.lst('topic/%s' % n)) - 6 for n in blogs}) msgs = mydict({n: api.get_msg(n) for n in blogs}) return template('blog-list.html', blogs=blogs, msgs=msgs, comms=comms, tag=tag, ea='', pge=-1, u=u())
def blog_list(ea=''): if not ea: ea = api.echolist()[0] blogs = api.lst('et/%s' % ea) comms = mydict({n:len(api.lst('topic/%s' % n))-6 for n in blogs}) pge = request.query.page or '1' return template ('blog-list.html',ea=ea,blogs=blogs,comms=comms,pge=int(pge)-1)
def msg_post(ea): allstart() fz = local.r.fz cfg = api.load_echo(False) ufor = request.forms.msgfrom.encode('utf-8') if not flt.echo_flt(ea): return ea if not fz.msg or not fz.subj: return 'empty msg or subj' uname, uaddr = points.check_hash(ufor) if uaddr: mo = sx.mydict() for _ in ('subj', 'msg', 'repto'): mo[_] = fz[_].decode('utf-8') mo['msgfrom'] = uname mo['msg'] = mo['msg'].replace('\r\n', '\n') mo['date'] = str(sx.gts()) mo.update(addr='%s, %s' % (cfg[0][1], uaddr), msgto=request.forms.msgto, echoarea=ea) api.savemsg(mo) else: return 'no auth' if ufor != local.r.auth: response.set_cookie('auth', ufor, path='/', max_age=7776000) return ( '<html><head><meta http-equiv="refresh" content="0; /%s" /></head><body></body></html>' % ea) else: redirect('/%s' % ea)
def msg_post(ea): allstart() fz = local.r.fz cfg = config(CONFIG) ufor = request.forms.msgfrom.encode('utf-8') if not flt.echo_flt(ea): return ea if not fz.msg or not fz.subj: return 'empty msg or subj' uname, uaddr = points.check_hash(ufor) if uaddr: mo = sx.mydict() for _ in ('subj', 'msg', 'repto'): mo[_] = fz[_].decode('utf-8') mo['msgfrom'] = uname mo['msg'] = mo['msg'].replace('\r\n', '\n') mo.update(addr='%s,%s' % (cfg['server']['address'], uaddr), msgto=request.forms.msgto, echoarea=ea) h = api.point_newmsg(mo) if not h: return 'bad message' else: return 'no auth' redir = fz.goback or '/%s' % ea if ufor != local.r.auth: response.set_cookie('auth', ufor, path='/', max_age=7776000) return ( '<html><head><meta http-equiv="refresh" content="0; %s" /></head><body></body></html>' % redir) else: redirect(redir)
def create_message_point(): ud = udata(request.forms.pauth.encode('utf-8')) dta = b64d(request.forms.tmsg.encode('utf-8')).decode('utf-8').splitlines() repto, tags = '', '' if dta[4].startswith('@repto:'): repto = dta[4][7:] if len(repto) != 20: return 'wrong repto!' txt = '\n'.join(dta[5:]) elif dta[4].startswith('@tags:'): tags = dta[4][6:] txt = '\n'.join(dta[5:]) else: txt = '\n'.join(dta[4:]) mo = mydict(ea=dta[0], txt=txt, repto=repto, tags=tags, to=dta[1], title=dta[2] or '***') if repto: mo.topicid = api.get_msg(repto).topicid if ud.check() and ud.uname: nmsg = api.create_msg(mo, ud) return 'msg ok:%s' % nmsg
def reply_form(ea, topicid, repto): if repto and repto != '-': prev = api.get_msg(repto) else: prev = mydict() return template('frmnews.html', u=u(), prev=prev, typ='blog', ea=ea, topicid=topicid, repto=repto)
def msg_post(ea): allstart(); fz = local.r.fz cfg = config(CONFIG) ufor = request.forms.msgfrom.encode('utf-8') if not flt.echo_flt(ea): return ea if not fz.msg or not fz.subj: return 'empty msg or subj' uname, uaddr = points.check_hash(ufor) if uaddr: mo = sx.mydict() for _ in ('subj', 'msg', 'repto'): mo[_] = fz[_].decode('utf-8') mo['msgfrom'] = uname mo['msg']=mo['msg'].replace('\r\n','\n') mo.update(addr='%s,%s' % (cfg['server']['address'], uaddr),msgto=request.forms.msgto,echoarea=ea) h = api.point_newmsg(mo) if not h: return 'bad message' else: return 'no auth' redir = fz.goback or '/%s' % ea if ufor != local.r.auth: response.set_cookie('auth',ufor,path='/',max_age=7776000) return ('<html><head><meta http-equiv="refresh" content="0; %s" /></head><body></body></html>' % redir) else: redirect (redir)
def allstart(): ip=request.headers.get('X-Real-Ip') or request.environ.get('REMOTE_ADDR') local.r = sx.mydict(ua=request.headers.get('User-Agent'),ip=ip,kuk=sx.mydict(request.cookies),fz=sx.mydict(request.POST),getl=sx.mydict(request.GET)) local.r.auth = local.r.kuk.auth
def topic_list(topicid): topic = api.lst('topic/%s' % topicid) msgs = mydict({n:api.get_msg(n) for n in topic[5:]}) return template('forum-topic.html',topicid=topicid,topic=topic,msgs=msgs,u=u())