예제 #1
0
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)
예제 #2
0
파일: __init__.py 프로젝트: 6vasia/ii-base
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)
예제 #3
0
파일: run.py 프로젝트: 6vasia/ii-base
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!'
예제 #4
0
파일: run.py 프로젝트: gk11-ru/ii-elp
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!'
예제 #5
0
파일: run.py 프로젝트: 6vasia/ii-base
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!'
예제 #6
0
파일: __init__.py 프로젝트: 6vasia/ii-base
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)