Ejemplo n.º 1
0
def getLastVisitTime(request, siteid):
    '''
        @function: get the last time of whether usr and ip visit the site, and usr first
        @paras:
            siteid - the site.pk, unique identification the site
        @returns: True or False boolean
    '''
    if 'usr' in request.COOKIES:
        visitSetList = Visit.objects.filter(user__username=request.COOKIES['usr'], site__id=siteid).order_by('-visitTime')[:1]
    else:
        visitSetList = Visit.objects.filter(host=getIP(request), site__id=siteid).order_by('-visitTime')[:1]

    if visitSetList.count() == 0:
        return None, 0
    else:
        lvt = visitSetList.values('visitTime')[0]['visitTime']
        interval = Site.objects.get(id=siteid).interval
        # lt = interval - int((timezone.now() - lvt).total_seconds())/60
        # refer: http://docs.python.org/2/library/datetime.html#datetime.timedelta.total_seconds
        # total_seconds is New in version 2.7.
        # so we can use 'td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6' which equals to total_seconds
        td = (timezone.now() - lvt)
        lt = interval - int((td.microseconds + (td.seconds + td.days * 24 * 3600) * 10 ** 6) / 10 ** 6) / 60
        lt = lt if lt >= 0 else 0
        return lvt, lt
Ejemplo n.º 2
0
def verify(request):
    verify_url = 'http://www.google.com/recaptcha/api/verify'
    _wallet = request.COOKIES['wa']
    _recaptcha_challenge_field = request.POST.get('recaptcha_challenge_field', '')
    _recaptcha_response_field = request.POST.get('recaptcha_response_field', '')
    data = {'privatekey': '6LfWhe0SAAAAAEkkiS0DD2w0u2xWA1gxpvFGt7YP', 'remoteip': getIP(request), 'challenge': _recaptcha_challenge_field, 'response': _recaptcha_response_field}
    re = requests.post(verify_url, data)
    reDict = {'wallet': _wallet, 'tips': True, 'success': u'true' in re.text}
    return render_to_response('freebtc/verify.html', reDict)
Ejemplo n.º 3
0
Archivo: views.py Proyecto: whalezy/btc
def getFavFlag(request, siteid):
    '''
        @function: get the flag of whether usr and ip favorite the, and usr first
        @paras:
            sited - the site.pk, unique identification the table
        @returns: True or False boolean
    '''
    if 'usr' in request.COOKIES:
        return Favorite.objects.filter(user__username=request.COOKIES['usr'], site__id=siteid).count() != 0
    else:
        return Favorite.objects.filter(host=getIP(request), site__id=siteid).count() != 0
Ejemplo n.º 4
0
Archivo: views.py Proyecto: whalezy/btc
def getLikeFlag(request, siteid, _flag):
    '''
        @function: get the flag of whether usr and ip liked the site, and usr first
        @paras:
            siteid - the site.pk, unique identification the site
            _flag - Like:True, Unlike:False
        @returns: True or False boolean
    '''
    if 'usr' in request.COOKIES:
        return Like.objects.filter(user__username=request.COOKIES['usr'], flag=_flag, site__id=siteid).count() != 0
    else:
        return Like.objects.filter(host=getIP(request), flag=_flag, site__id=siteid).count() != 0
Ejemplo n.º 5
0
def proof(request, siteid):
    verify_url = 'http://www.google.com/recaptcha/api/verify'

    _proof = request.POST.get('proof', '')

    robots = False
    if _proof == '':
        print 'Just get Proofs!!!'
    else:
        _recaptcha_challenge_field = request.POST.get('recaptcha_challenge_field', '')
        _recaptcha_response_field = request.POST.get('recaptcha_response_field', '')
        data = {'privatekey': '6LfWhe0SAAAAAEkkiS0DD2w0u2xWA1gxpvFGt7YP', 'remoteip': getIP(request), 'challenge': _recaptcha_challenge_field, 'response': _recaptcha_response_field}
        re = requests.post(verify_url, data)

        if u'true' in re.text:
            s = Site.objects.get(id=siteid)
            s.siteProofNum = s.siteProofNum + 1
            s.save()
            Proof.objects.create(site_id=siteid, proofContent=_proof)
        else:
            robots = True
    print robots

    reDict = dict(robots=robots, **getEvaluateDict(request, siteid))
    return render_to_response('freebtc123/evaluate.html', reDict)
Ejemplo n.º 6
0
def submitsite(request):
    verify_url = 'http://www.google.com/recaptcha/api/verify'

    _name = request.POST.get('name', '')
    _description = request.POST.get('description', '')
    _url = request.POST.get('url', '')

    robots = False
    if _url == '':
        pass
    else:
        _recaptcha_challenge_field = request.POST.get('recaptcha_challenge_field', '')
        _recaptcha_response_field = request.POST.get('recaptcha_response_field', '')
        data = {'privatekey': '6LfWhe0SAAAAAEkkiS0DD2w0u2xWA1gxpvFGt7YP', 'remoteip': getIP(request), 'challenge': _recaptcha_challenge_field, 'response': _recaptcha_response_field}
        re = requests.post(verify_url, data)

        if u'true' in re.text:
            csySet = Classify.objects.get(nav__navName='submitsite')
            Site.objects.create(siteName=_name, siteDescription=_description, siteUrl=_url, classify_id=csySet.id)
        else:
            robots = True

    reDict = {'nav': getNav(request), 'csysite': getCsySite(request, 'submitsite', 1), 'usr': getUsr(request), 'wallet': getWallet(request), 'robots': robots}
    return render_to_response('freebtc123/submitsite.html', reDict)