Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
8 ตอบกลับ
8429 มุมมอง

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

อวตาร
ละทิ้ง
ผู้เขียน

I got Exception 'object unbound'

Can you paste your code ..

ผู้เขียน

from openerp.http import request

def git_ip():

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

return ipnew

ผู้เขียน

from openerp.http import request

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

return ipnew

ผู้เขียน

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 ?

Related Posts ตอบกลับ มุมมอง กิจกรรม
7
ก.ค. 24
27747
how to get user ip address? แก้ไขแล้ว
10
มิ.ย. 21
40409
1
มี.ค. 18
9429
1
มี.ค. 15
6307
0
มี.ค. 15
4095