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 _point_msg(pauth,tmsg): msgfrom, addr = points.check_hash(pauth) if not addr: return 'auth error!' cfg = config('_server.cfg') mo = api.toss(msgfrom,'%s,%s' % (cfg['server']['address'],addr),tmsg.strip()) if mo.msg.startswith('@repto:'): tmpmsg = mo.msg.splitlines() mo.repto = tmpmsg[0][7:] mo.msg = '\n'.join(tmpmsg[1:]) # а ещё лучше - засунуть это в api.toss if len(mo.msg.encode('utf-8')) < 64100: h = api.point_newmsg(mo) if h: return 'msg ok:%s: <a href="/%s">%s</a>' % (h, mo.echoarea, mo.echoarea) else: return 'error:unknown' else: return 'msg big!'
def _point_msg(pauth, tmsg): msgfrom, addr = points.check_hash(pauth) if not addr: return 'auth error!' cfg = api.load_echo(False) mo = api.toss(msgfrom, '%s, %s' % (cfg[0][1], addr), tmsg.strip()) if mo.msg.startswith('@repto:'): tmpmsg = mo.msg.splitlines() mo.repto = tmpmsg[0][7:] mo.msg = '\n'.join(tmpmsg[1:]) if len(mo.msg.encode('utf-8')) < 64100: h = api.point_newmsg(mo) if h: return 'msg ok:%s: <a href="/%s">%s</a>' % (h, mo.echoarea, mo.echoarea) else: return 'error:unknown' else: return 'msg big!'
def _point_msg(pauth, tmsg): msgfrom, addr = points.check_hash(pauth) if not addr: return 'auth error!' cfg = config('_server.cfg') mo = api.toss(msgfrom, '%s,%s' % (cfg['server']['address'], addr), tmsg.strip()) if mo.msg.startswith('@repto:'): tmpmsg = mo.msg.splitlines() mo.repto = tmpmsg[0][7:] mo.msg = '\n'.join(tmpmsg[1:]) # а ещё лучше - засунуть это в api.toss if len(mo.msg.encode('utf-8')) < 64100: h = api.point_newmsg(mo) if h: return 'msg ok:%s: <a href="/%s">%s</a>' % (h, mo.echoarea, mo.echoarea) else: return 'error:unknown' else: return 'msg big!'
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)