Exemple #1
0
def add_white_ip(request):
    form = WhiteList_Add(data=request.GET)
    if form.is_valid():
        newwhiteip = WhiteIp(   user = Userinfo.objects.get(user=request.user),
                                ip=form.cleaned_data['white_ip'],
                                addtime=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
        newwhiteip.save()
        add_success = True
        whiteip = request.GET.get('white_ip')
        ipflow = request.GET.get('flow')
        if ipflow == "上行":
            ipflow = "0"
        else:
            ipflow = "1"
        print "ipflow",ipflow,"whiteip",whiteip

        resips = ResIp.objects.filter(Q(sip=whiteip,flow="0")|Q(dip=whiteip,flow="1"))
        print "resips",resips
        for i in resips:
            i.iswhite = True
            i.save()
        add_success = True
        return HttpResponseRedirect('/user_statistic/ip/')
    else:
        return render_to_response('error.html',locals(), context_instance = RequestContext(request))
Exemple #2
0
def white_email(request):
    title = u'Email白名单管理'
    
    if request.method == "POST":
        form = WhiteList_Add(data=request.POST)
        if form.is_valid():
            add_success = True
            user = Userinfo.objects.get(user=request.user)
            email=form.cleaned_data['white_email']
            if not WhiteEmail.objects.filter(user=user,email=email):
                newwhiteemail = WhiteEmail(   user = Userinfo.objects.get(user=request.user),
                                    email=form.cleaned_data['white_email'],
                                    addtime=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
                newwhiteemail.save()
                try:
                    whitemails = ResEmail.objects.filter(user=user,sendto=email)
                    for i in whitemails:
                        i.iswhite = True
                        i.save()
                    add = True
                except:
                    add = True
            return render_to_response('usersettings/white_email.html',locals(), context_instance = RequestContext(request))
        else:
            return render_to_response('error.html',locals(), context_instance = RequestContext(request))

    return render_to_response('usersettings/white_email.html',locals(), context_instance = RequestContext(request))
Exemple #3
0
def white_ip(request):
    title = u'IP白名单管理'

    if request.method == "POST":
        form = WhiteList_Add(data=request.POST)
        if form.is_valid():
            add_success = True
            if not WhiteIp.objects.filter(user=Userinfo.objects.get(user=request.user),ip=form.cleaned_data['white_ip']):
                newwhiteip = WhiteIp(   user = Userinfo.objects.get(user=request.user),
                                    ip=form.cleaned_data['white_ip'],
                                    addtime=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
                newwhiteip.save()
                try:
                    whiteips = ResIp.objects.filter(user=Userinfo.objects.get(user=request.user),suspiciousip=form.cleaned_data['white_ip'])
                    for i in whiteips:
                        i.iswhite = True
                        i.save()
                    add = True
                except:
                    add = True
            return render_to_response('usersettings/white_ip.html',locals(), context_instance = RequestContext(request))
        else:
            return render_to_response('error.html',locals(), context_instance = RequestContext(request))

    return render_to_response('usersettings/white_ip.html',locals(), context_instance = RequestContext(request))
Exemple #4
0
def add_white_url(request):
    form = WhiteList_Add(data=request.GET)
    if form.is_valid():
        newwhiteurl = WhiteUrl(   user = Userinfo.objects.get(user=request.user),
                                url=form.cleaned_data['white_url'],
                                addtime=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
        newwhiteurl.save()
        add_success = True
        id = request.GET.get('id')
        editresurl = ResUrl.objects.get(id=id)
        editresurl.iswhite = True
        editresurl.save()
        add_success = True
        return HttpResponseRedirect('/user_statistic/url/')
    else:
        return render_to_response('error.html',locals(), context_instance = RequestContext(request))