Friday, March 28, 2008

Circumventing IP Geolocation

Although IP geolocation can be fairly accurate, it can also be easily thwarted with the use of global gateways or proxy servers that are geographically distant from the actual location of the user.

Using HostIP.info's IP geolocation service with an online PocketPC via Smart GPRS puts my location at Makati, Philippines. The country is correct but the city is a good 570 kilometers from mine, or an hour's ride by plane.


On the other hand, using Anchorfree's Hotspot Shield wifi gateway plants me on the other side of the globe at Washington DC. Well, at least it's the same planet..

Sunday, March 23, 2008

IP Geolocation Gadget

Geolocation by IP address is the method of determining the geographic location of an Internet-connected device by examining data related to the IP address it is using. Google is effectively using geolocation to deliver targeted content by redirecting Google visitors to pages translated into their local language. On the other hand, geolocation can also be used to filter content. Just recently, selected YouTube videos have been discovered to bear special tags indicating that it is inappropriate for viewing in some countries .

There are several IP geolocation services in the Internet so I gave some of them a spin. Here are the results according to increasing accuracy in determining my location.


- IP2location got my country right but was not able to provide my city.
- IPligence got my city wrong.. or maybe it did not know my city and gave the national capital instead as default.
- Geobytes and Maxmind got my city right.
- HostIP.info not only got my city right but also has an API to go with it. And did I mention that the service is free?

Point your browser to http://api.hostip.info/ and you get an XML feed containing not only your City and Country but also your geographic coordinates as well. Sweet!


I can't resist the temptation to use this geolocation service and mix it up with Google Maps API into a Google gadget.. so I came up with another widget called WTHAMI?. Here it is in action..


If it doesn't get your location right, don't sue me. You can update your location at HostIP.info.

Saturday, March 22, 2008

Cebumapia, the Google Gadget

I've always wondered if I could package Cebumapia as a Google Gadget.. After taking a peek at the other Gadget samples, I was determined to build it. The wondering stage is over now..



The gadget uses the Google Maps API to render the map, overlay markers and trigger events when the mouse hovers on markers and when these are clicked. Markers are stored in xml files and fetched using the gadget-specific _IG_FetchXmlContent function.

The Cebumapia gadget code is miniscule - only 200 lines. But then, functionality is trimmed down to the very basic and UI is just as minimalistic. Take out the module header, css and html portions, and you are left with only 100 lines of javascript code.

If you've been wanting to create your own killer gadget and thinking you don't have the time, start now! My advise.. Start with small reliable code and incrementally build on it. Me? I'm planning to add a local news feed.. spruce up the UI for an iPhone-ish look.. or maybe not.

Add the Cebumapia gadget to your iGoogle page..

See the gadget embedded in Blogger template at Cebumapia.

Thursday, March 13, 2008

Testing ZK Ajax Framework with iSeries/AS400 using JDBC

The ZK Ajax Framework standalone zkdemo application has a sample program that uses JDBC to provide database support to an Ajax app. I decided to give it a try using an iSeries datasource. Here's how it was done..

ZK downloads are here.

- Download ZK-quickstart-x.y.z.pdf
- Download and install Tomcat. I used version 5.5 as this was the version referred to in the manual.
- Download zk-demo-x.y.z.zip and extract the package. Copy the zkdemo.war package to the webapps directory of Tomcat (C:\Program Files\Apache Software Foundation\Tomcat 5.5)
- Restart Tomcat and open the url http://localhost:8080/zkdemo/userguide/

Shutdown Tomcat. I copied the ...\webapps\zkdemo directory to ...\webapps\myzk so I can make changes to the sample code without touching the demo application. I then copied ...\webapps\myzk\userguide\dbconnect\jdbc.zul to ...\webapps\myzk\dbconnect\jdbc.zul and modified the submit() function, as follows:


void submit() {
// Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// DriverManager.registerDriver(new com.ibm.as400.access.AS400JDBCDriver());
Class.forName("com.ibm.as400.access.AS400JDBCDriver");
// String url = "jdbc:odbc:Fred";
String mySchema = "REXJUN1";
String myAS400 = "m170pub1.rzkh.de";
String myUserId = "REXJUN";
String myPasswd = "-change-me-";
String url = "jdbc:as400://" + myAS400 + "/" + mySchema;
Connection con = DriverManager.getConnection(url,myUserId, myPasswd);
PreparedStatement stmt = con.prepareStatement("INSERT INTO BASICJDBC values(?, ?)");
//insert what end user entered into database table
stmt.setString(1, id.value);
stmt.setString(2, name.value);
//execute the statement
stmt.executeUpdate();
//commit
con.commit();
//close the jdbc connection
con.close();
}

Add the jt400.jar from JTOpen to the ...\webapps\myzk\WEB-INF\lib directory. This jar file contains the JDBC driver for iSeries.

Restart Tomcat. Opening the url http://localhost:8080/myzk/dbconnect/jdbc.zul should give you this..


A wrong password does not trigger an error and the application seems to hang -- the host system may have requested a password re-entry but the UI failed to render.

Reviewing the file contents shows the successful addition of new records..


ZK also released ZK Mobile 0.8.7 for the mobile platform on November 07, 2007.

Tuesday, March 4, 2008

Gaga over Google Maps

I gotta admit it, I'm hooked on Google Maps, specifically its API. I've seen the maps of Hongkong's MTR system and with it you can practically plan your trips down to the nearest entry and exit points.


Cebu of the Philippines is likewise a destination for many. Although several travel guides featuring Cebu abound on the web, maps are seldom employed to aid those needing directions. With the availability of rooftop-level satellite imagery offered by Google Maps, I decided to overlay Cebu's streets and places of interest with markers. To spice up the pages, I interspersed local info with impressive photos at Panoramio and Flickr courtesy of camera enthusiasts.

Before I forget, let me introduce you to Cebumapia - a Google Map mashup of Cebu's places of interest! And shall I add, always a Work In Progress!


I've started with markers, or should I say.. I planned to use only markers. But as complexity started to evaporate, I found myself twiddling with infowindows and polylines to spruce things up. After the 30th or so marker in place, I realized I barely scratched the surface... so many markers, so little time! I needed an easier way to add and modify map objects without further mangling the html and javascript code of my Blogger template.

Google Docs to the rescue! By migrating the coordinates, waypoints and even descriptions into Google spreadsheets, I can now change map info even without having to log into Blogger. Hmmm... I'm now thinking of letting visitors add their own sites so I don't have to do anything at all!

I've learned a lot of new things already while building this site. Enjoy it as much as I did... or still do.