fix some things :3
This commit is contained in:
parent
cd763f3930
commit
7f6b5dda21
62
ip.py
Normal file → Executable file
62
ip.py
Normal file → Executable file
@ -1,31 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
import cgi
|
||||
import os
|
||||
import pygeoip
|
||||
|
||||
def header():
|
||||
print("Content-type: text/plain")
|
||||
print("")
|
||||
|
||||
def main():
|
||||
params = cgi.FieldStorage()
|
||||
out = {
|
||||
"ip": None,
|
||||
"country": None,
|
||||
"continent": None,
|
||||
"location": None
|
||||
}
|
||||
header()
|
||||
client_ip = cgi.escape(os.environ["REMOTE_ADDR"])
|
||||
format = F_PLAIN
|
||||
if(len(params) > 0):
|
||||
for key in params:
|
||||
if key == "geo":
|
||||
gi = pygeoip.GeoIP('GeoLiteCity.dat')
|
||||
geo_info = gi.record_by_addr(ip)
|
||||
print(geo_info)
|
||||
else:
|
||||
print(client_ip)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
#!/usr/bin/env python
|
||||
import cgi
|
||||
import os
|
||||
import pygeoip
|
||||
|
||||
def header():
|
||||
print("Content-type: text/plain")
|
||||
print("")
|
||||
|
||||
def main():
|
||||
params = cgi.FieldStorage()
|
||||
out = {
|
||||
"ip": None,
|
||||
"country": None,
|
||||
"continent": None,
|
||||
"location": None
|
||||
}
|
||||
header()
|
||||
client_ip = os.environ["REMOTE_ADDR"]
|
||||
if(len(params) > 0):
|
||||
for key in params:
|
||||
if key == "geo":
|
||||
gi = pygeoip.GeoIP('GeoLiteCity.dat')
|
||||
geo_info = gi.record_by_addr(client_ip)
|
||||
geo_info['ip'] = client_ip
|
||||
print(geo_info)
|
||||
else:
|
||||
print(client_ip)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user