Use new get_client_ip() function instead of using REMOTE_ADDR.

This commit is contained in:
Magnus Hagander
2010-06-17 14:56:26 +02:00
parent 6c1c4213d5
commit 2942c2832a
2 changed files with 4 additions and 7 deletions

View File

@ -13,6 +13,7 @@ import cPickle as pickle
from pgweb.util.decorators import ssl_required, nocache
from pgweb.util.contexts import NavContext
from pgweb.util.helpers import simple_form, PgXmlHelper
from pgweb.util.misc import get_client_ip
from models import *
from forms import *
@ -90,7 +91,7 @@ def ftpbrowser(request, subpath):
def _get_numeric_ip(request):
try:
ip = request.META['REMOTE_ADDR']
ip = get_client_ip(request)
p = ip.split('.')
return int(p[0])*16777216 + int(p[1])*65536 + int(p[2])*256 + int(p[3])
except:

View File

@ -3,6 +3,7 @@ from django.http import HttpResponse, Http404, HttpResponseServerError, HttpResp
from django.db import connection
from pgweb.util.contexts import NavContext
from pgweb.util.misc import get_client_ip
from models import Survey, SurveyAnswer, SurveyLock
@ -26,12 +27,7 @@ def vote(request, surveyid):
attrname = "tot%s" % ansnum
# Do IP based locking...
try:
addr = request.META.get('REMOTE_ADDR')
if addr == None or addr == "":
raise Exception()
except:
return HttpResponseServerError("Unable to determine client IP address")
addr = get_client_ip(request)
# Clean out any old junk
curs = connection.cursor()