Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
8 Replies
8475 Tampilan

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

Avatar
Buang
Jawaban Terbai

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

Avatar
Buang
Penulis

I got Exception 'object unbound'

Can you paste your code ..

Penulis

from openerp.http import request

def git_ip():

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

return ipnew

Penulis

from openerp.http import request

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

return ipnew

Penulis

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 ?

Post Terkait Replies Tampilan Aktivitas
7
Jul 24
27872
10
Jun 21
40522
1
Mar 18
9471
1
Mar 15
6358
0
Mar 15
4129