Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
8 Trả lời
8412 Lượt xem

Am trying to track the visitor ip address ,but am failed to  implement it..please help me...Urgent.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

You can try the below code:

if "HTTP_X_FORWARDED_FOR" in request.httprequest.environ:
    # Virtual host
    ip = request.httprequest.environ["HTTP_X_FORWARDED_FOR"]
elif "HTTP_HOST" in request.httprequest.environ:
    # Non-virtualhost
    ip = request.httprequest.environ["REMOTE_ADDR"]


Hope this could helps

Ảnh đại diện
Huỷ bỏ
Tác giả

I got Exception 'object unbound'

Can you paste your code ..

Tác giả

from openerp.http import request

def git_ip():

ipnew = request.httprequest.headers.environ['REMOTE_ADDR']

return ipnew

Tác giả

from openerp.http import request

ipnew = request.httprequest.headers.environ['REMOTE_ADDR']

return ipnew

Tác giả

from openerp.http import request

def get_ip():

ipnew = request.httprequest.environ['REMOTE_ADDR']

return ipnew

May be you're missing @http.rout decorator. Btw from where you're calling your method ?

Bài viết liên quan Trả lời Lượt xem Hoạt động
7
thg 7 24
27720
10
thg 6 21
40364
1
thg 3 18
9420
1
thg 3 15
6301
0
thg 3 15
4084