Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
New Extension : IP Based Google Map
I have just uploaded my first add-on for Vanilla. I am a new member to the community and think the Vanilla Forum system is great.
I wanted to write and extension and after looking couldn't find anything like this. IP Based Google Map
This is really a proof of concept idea, it hadn't been done as far as I can tell and as I am usually a Windows .Net developer I wanted to see if I could do it. so the coding may not be the best you have seen.
It basically gets the ip address of the user and does a lat/long lookup and links into Google Maps
Please feel free to let me know how to make the code better and if anyone wants to modify it feel free.
Jon
I wanted to write and extension and after looking couldn't find anything like this. IP Based Google Map
This is really a proof of concept idea, it hadn't been done as far as I can tell and as I am usually a Windows .Net developer I wanted to see if I could do it. so the coding may not be the best you have seen.
It basically gets the ip address of the user and does a lat/long lookup and links into Google Maps
Please feel free to let me know how to make the code better and if anyone wants to modify it feel free.
Jon
0
This discussion has been closed.
Comments
Perhaps one of the Vanilla/PHP guru's could have a check if the db calls I am making are being made correctly.
The main ones are Has anyone else who has installed this had a similar problem?
Jon
Other than that it looks alright...?
mysql_connect($Configuration['DATABASE_HOST'],$Configuration['DATABASE_USER'],$Configuration['DATABASE_PASSWORD']); mysql_select_db($Configuration['DATABASE_NAME']); $result=mysql_query("SELECT RemoteIP FROM ".$Configuration['DATABASE_TABLE_PREFIX']."user WHERE UserID=$AccountUserID") or die(mysql_error()); $row = mysql_fetch_row($result); $IPAddress = $row[0];
by$IPAddress = $Context->Session->User->RemoteIp;
Edit: Nevermind, you need the ip of user account that is view...
$AccountUserID = ForceIncomingInt("u", $Context->Session->UserID);
$AccountUser = $UserManager->GetUserById($AccountUserID);
$IPAddress = $AccountUser->RemoteIp;
I have added in your code and uploaded a new version 0.2.
This does not require the db lookup as it uses the code Dinoboff supplied.
this is bad
If have now removed the stripos() and used strpos() which I believe is php3/4/5 compatible.
but it does'nt show up any map there in the userprofile .. so i bet this could take a few hours right?
If you look in the default.php you will see the following lines
$URL = "http://api.hostip.info/get_html.php?ip=";
$URL .= $IPAddress;
$URL .= "&position=true";
So if you put into you browser http://api.hostip.info/get_html.php?ip=THEIPADDRESS&position=true and see what it returns
If the latitude and longitude are empty then it can't locate the city.
I will see if I can find a better geolocation service to use.
so what should i do? please explain it for scripting idiots like me
edit: ah it's seems like its not the browser its the status .. i see the map only in profiles of banned users
Returns...
----------------------------------------------------------------------
Country: AUSTRALIA (AU)
City: (Unknown city)
Latitude:
Longitude:
----------------------------------------------------------------------
The city is Melbourne, hardly an un-know back water?