Esempio n. 1
0
    def handle(self, *v, **u):
        args = self.arguments

        assert (args.content)
        if args.raw:
            postRawStatu(args.content)
        else:
            postStatu(args.content)
Esempio n. 2
0
 def handle(self, *v, **u):
     args = self.arguments
     
     assert(args.content)
     if args.raw:
         postRawStatu(args.content)
     else:
         postStatu(args.content)
Esempio n. 3
0
def index(req):
    ipaddr = req.META.get('REMOTE_ADDR', '')
    _content = ''
    _need_recaptcha = False
    if req.method == 'POST':
        _content = req.POST.get('content', '')
        _need_recaptcha = needRecaptchar(ipaddr, _content)
        if _need_recaptcha and len(
                req.POST.get('recaptcha_challenge_field', '')) == 0:
            messages.error(req, MSG['RECAPTCHA_NEEDED'])
        elif _need_recaptcha and not captcha.submit(
                req.POST.get('recaptcha_challenge_field', ''),
                req.POST.get('recaptcha_response_field'),
                RECAPTCHA_PRIVATE_KEY, ipaddr).is_valid:
            messages.error(req, MSG['RECAPTCHA_INCORRECT'])
        elif not checkIP(ipaddr):
            messages.error(req, MSG['IP_NOT_VALID'])
        elif not (len(_content) < 120 and len(_content) > 5):
            messages.error(req, MSG['CONTENT_TOO_LONG'])
        elif ContentModel.objects.filter(ip=ipaddr, time__range=\
                (datetime.now()-timedelta(minutes=30), datetime.now())).count() > 0:
            messages.error(req, MSG['TOO_MANY_TIMES'])
        else:
            try:
                postStatu(_content, ipaddr)
            except:
                messages.error(req, MSG['PUBLISH_ERROR'])
                logging.error('Error in ' + str(ContentModel.objects.count()))
            else:
                messages.success(req, MSG['PUBLISH_OK'])
                _content = ''

# for doreamon icon
    try:
        icon = int(req.path[1:])
    except ValueError:
        icon = 0
    tourl = ''
    if icon == 0 or req.session.get('redirect', 0) == 0:
        req.session['redirect'] = 1
        tourl = '/' + str(random.randint(1, 16))
    else:
        req.session['redirect'] = 0
    isIphone = ('iPhone' in req.META.get('HTTP_USER_AGENT', '')
                and req.method == 'GET')
    return render_to_response('index.html', \
            {'ICO_NUM': icon, 'TOURL': tourl, 'ISIPHONE': isIphone,
                'LINKS': LINKS,
                'PLACEHOLER': PlaceholderModel.objects.order_by('?')[0].content,
                'content': _content,
                'RECAPTCHA_PUBLIC_KEY': RECAPTCHA_PUBLIC_KEY,
                'need_recaptcha': _need_recaptcha,
                'COLOR': random.choice(COLORS)},
            context_instance=RequestContext(req))
Esempio n. 4
0
def index(req):
    ipaddr = req.META.get('REMOTE_ADDR', '')
    _content = ''
    _need_recaptcha = False
    if req.method == 'POST':
        _content = req.POST.get('content', '')
        _need_recaptcha = needRecaptchar(ipaddr, _content)
        if _need_recaptcha and len(req.POST.get('recaptcha_challenge_field', '')) == 0:
            messages.error(req, MSG['RECAPTCHA_NEEDED'])
        elif _need_recaptcha and not captcha.submit(req.POST.get('recaptcha_challenge_field', ''), 
                req.POST.get('recaptcha_response_field'), 
                RECAPTCHA_PRIVATE_KEY, ipaddr).is_valid:
            messages.error(req, MSG['RECAPTCHA_INCORRECT'])
        elif not checkIP(ipaddr):
            messages.error(req, MSG['IP_NOT_VALID'])
        elif not (len(_content) < 120 and len(_content) > 5):
            messages.error(req, MSG['CONTENT_TOO_LONG'])
        elif ContentModel.objects.filter(ip=ipaddr, time__range=\
                (datetime.now()-timedelta(minutes=30), datetime.now())).count() > 0:
            messages.error(req, MSG['TOO_MANY_TIMES'])
        else:
            try:
                postStatu(_content, ipaddr)
            except:
                messages.error(req, MSG['PUBLISH_ERROR'])
                logging.error('Error in ' + str(ContentModel.objects.count()))
            else:
                messages.success(req, MSG['PUBLISH_OK'])
                _content = ''

# for doreamon icon
    try:
        icon = int(req.path[1:])
    except ValueError:
        icon = 0
    tourl = ''
    if icon == 0 or req.session.get('redirect', 0) == 0:
        req.session['redirect'] = 1
        tourl = '/' + str(random.randint(1, 16))
    else:
        req.session['redirect'] = 0
    isIphone = ('iPhone' in req.META.get('HTTP_USER_AGENT', '') and req.method == 'GET')
    return render_to_response('index.html', \
            {'ICO_NUM': icon, 'TOURL': tourl, 'ISIPHONE': isIphone, 
                'LINKS': LINKS, 
                'PLACEHOLER': PlaceholderModel.objects.order_by('?')[0].content, 
                'content': _content, 
                'RECAPTCHA_PUBLIC_KEY': RECAPTCHA_PUBLIC_KEY, 
                'need_recaptcha': _need_recaptcha, 
                'COLOR': random.choice(COLORS)}, 
            context_instance=RequestContext(req))
Esempio n. 5
0
def index(req):
    ipaddr = req.META.get("REMOTE_ADDR", "")
    if req.method == "POST":
        _content = req.POST.get("content", "")
        if not checkIP(ipaddr):
            messages.error(req, MSG["IP_NOT_VALID"])
        elif not (len(_content) < 120 and len(_content) > 5):
            messages.error(req, MSG["CONTENT_TOO_LONG"])
        elif (
            ContentModel.objects.filter(
                ip=ipaddr, time__range=(datetime.now() - timedelta(minutes=30), datetime.now())
            ).count()
            > 0
        ):
            messages.error(req, MSG["TOO_MANY_TIMES"])
        else:
            new_content = ContentModel(ip=ipaddr, time=datetime.now(), content=_content)
            new_content.save()
            try:
                postStatu(_content, ContentModel.objects.count())
            except RuntimeError:
                messages.error(req, MSG["PUBLISH_ERROR"])
                logging.error("Error in " + str(ContentModel.objects.count()))
            else:
                messages.success(req, MSG["PUBLISH_OK"])

    # for doreamon icon
    try:
        icon = int(req.path[1:])
    except ValueError:
        icon = 0
    tourl = ""
    if icon == 0 or req.session.get("redirect", 0) == 0:
        req.session["redirect"] = 1
        tourl = "/" + str(random.randint(1, 16))
    else:
        req.session["redirect"] = 0
    isIphone = "iPhone" in req.META.get("HTTP_USER_AGENT", "") and req.method == "GET"
    return render_to_response(
        "index.html",
        {"ICO_NUM": icon, "TOURL": tourl, "ISIPHONE": isIphone, "LINKS": LINKS},
        context_instance=RequestContext(req),
    )
Esempio n. 6
0
def index(req):
    ipaddr = req.META.get('REMOTE_ADDR', '')
    if req.method == 'POST':
        _content = req.POST.get('content', '')
        if not checkIP(ipaddr):
            messages.error(req, MSG['IP_NOT_VALID'])
        elif not (len(_content) < 120 and len(_content) > 5):
            messages.error(req, MSG['CONTENT_TOO_LONG'])
        elif ContentModel.objects.filter(ip=ipaddr, time__range=\
                (datetime.now()-timedelta(minutes=30), datetime.now())).count() > 0:
            messages.error(req, MSG['TOO_MANY_TIMES'])
        else:
            new_content = ContentModel(ip=ipaddr, 
                    time=datetime.now(), 
                    content=_content)
            new_content.save()
            try:
                postStatu(_content, ContentModel.objects.count())
            except RuntimeError:
                messages.error(req, MSG['PUBLISH_ERROR'])
                logging.error('Error in ' + str(ContentModel.objects.count()))
            else:
                messages.success(req, MSG['PUBLISH_OK'])

# for doreamon icon
    try:
        icon = int(req.path[1:])
    except ValueError:
        icon = 0
    tourl = ''
    if icon == 0 or req.session.get('redirect', 0) == 0:
        req.session['redirect'] = 1
        tourl = '/' + str(random.randint(1, 16))
    else:
        req.session['redirect'] = 0
    isIphone = ('iPhone' in req.META.get('HTTP_USER_AGENT', '') and req.method == 'GET')
    return render_to_response('index.html', \
            {'ICO_NUM': icon, 'TOURL': tourl, 'ISIPHONE': isIphone, 
                'LINKS': LINKS, 
                'PLACEHOLER': PlaceholderModel.objects.order_by('?')[0].content }, 
            context_instance=RequestContext(req))
Esempio n. 7
0
def index(req):
    ipaddr = req.META.get('REMOTE_ADDR', '')
    if req.method == 'POST':
        _content = req.POST.get('content', '')
        if not checkIP(ipaddr):
            messages.error(req, MSG['IP_NOT_VALID'])
        elif not (len(_content) < 120 and len(_content) > 5):
            messages.error(req, MSG['CONTENT_TOO_LONG'])
        elif ContentModel.objects.filter(ip=ipaddr, time__range=\
                (datetime.now()-timedelta(minutes=30), datetime.now())).count() > 0:
            messages.error(req, MSG['TOO_MANY_TIMES'])
        else:
            new_content = ContentModel(ip=ipaddr,
                                       time=datetime.now(),
                                       content=_content)
            new_content.save()
            try:
                postStatu(_content, ContentModel.objects.count())
            except RuntimeError:
                messages.error(req, MSG['PUBLISH_ERROR'])
                logging.error('Error in ' + str(ContentModel.objects.count()))
            else:
                messages.success(req, MSG['PUBLISH_OK'])

# for doreamon icon
    try:
        icon = int(req.path[1:])
    except ValueError:
        icon = 0
    tourl = ''
    if icon == 0 or req.session.get('redirect', 0) == 0:
        req.session['redirect'] = 1
        tourl = '/' + str(random.randint(1, 16))
    else:
        req.session['redirect'] = 0
    isIphone = ('iPhone' in req.META.get('HTTP_USER_AGENT', '')
                and req.method == 'GET')
    return render_to_response('index.html', \
            {'ICO_NUM': icon, 'TOURL': tourl, 'ISIPHONE': isIphone, 'LINKS': LINKS},
            context_instance=RequestContext(req))