<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Apache access_log to Google Earth KML</title>
	<atom:link href="http://www.kahunaburger.com/2009/03/25/apache-access_log-to-google-earth-kml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kahunaburger.com/2009/03/25/apache-access_log-to-google-earth-kml/</link>
	<description>home of pia, max, frisco and tobias</description>
	<lastBuildDate>Sat, 24 Jul 2010 00:26:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Tobias</title>
		<link>http://www.kahunaburger.com/2009/03/25/apache-access_log-to-google-earth-kml/comment-page-1/#comment-43457</link>
		<dc:creator>Tobias</dc:creator>
		<pubDate>Thu, 09 Apr 2009 16:43:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.kahunaburger.com/?p=1351#comment-43457</guid>
		<description>Ok - I escaped it properly and also deleted the older trashed comment - thanks again :-)</description>
		<content:encoded><![CDATA[<p>Ok &#8211; I escaped it properly and also deleted the older trashed comment &#8211; thanks again <img src='http://www.kahunaburger.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Haarith Devarajan</title>
		<link>http://www.kahunaburger.com/2009/03/25/apache-access_log-to-google-earth-kml/comment-page-1/#comment-43451</link>
		<dc:creator>Haarith Devarajan</dc:creator>
		<pubDate>Thu, 09 Apr 2009 01:22:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.kahunaburger.com/?p=1351#comment-43451</guid>
		<description>Sent the code..offcourse  edited the username and password to be hd .. should not have been lazy and put username and password in its place .. :D</description>
		<content:encoded><![CDATA[<p>Sent the code..offcourse  edited the username and password to be hd .. should not have been lazy and put username and password in its place .. <img src='http://www.kahunaburger.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tobias</title>
		<link>http://www.kahunaburger.com/2009/03/25/apache-access_log-to-google-earth-kml/comment-page-1/#comment-43450</link>
		<dc:creator>Tobias</dc:creator>
		<pubDate>Thu, 09 Apr 2009 00:42:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.kahunaburger.com/?p=1351#comment-43450</guid>
		<description>Ugh - those comments did not turn out too well. If you want to send the code to me, I&#039;ll make sure it looks ok. Tks - T</description>
		<content:encoded><![CDATA[<p>Ugh &#8211; those comments did not turn out too well. If you want to send the code to me, I&#8217;ll make sure it looks ok. Tks &#8211; T</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Haarith Devarajan</title>
		<link>http://www.kahunaburger.com/2009/03/25/apache-access_log-to-google-earth-kml/comment-page-1/#comment-43449</link>
		<dc:creator>Haarith Devarajan</dc:creator>
		<pubDate>Thu, 09 Apr 2009 00:28:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.kahunaburger.com/?p=1351#comment-43449</guid>
		<description>Final version. Thanks again for putting this up.

&lt;pre&gt;
use strict;
use DBI;

my %seen;
my $dbh = DBI-&gt;connect(&quot;dbi:mysql:ipinfo&quot;,&quot;hd&quot;,&quot;hd&quot;);
die &quot;unable to connect to database&quot; unless ($dbh);
# kml header
print qq{&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;kml xmlns=&quot;http://earth.google.com/kml/2.2&quot;&gt;
\t&lt;Document&gt;
};

print qq{&lt;Style id=&quot;a&quot;&gt;};
print qq{&lt;IconStyle&gt;};
print
qq{&lt;Icon&gt;&lt;href&gt;http://maps.google.com/mapfiles/ms/icons/green-dot.png&lt;/h
ref&gt;&lt;/Icon&gt;};
print qq{&lt;/IconStyle&gt;};
print qq{ &lt;/Style&gt;};


# loop over access_log lines
while(&lt;&gt;) {
   # does it look like an access log entry?
   next unless
(/^(\d+)\.(\d+)\.(\d+)\.(\d+).*\[([^\]]+)\]\s+&quot;(\S+)\s+(\S+)\s+HTTP\/\d.
\d/);
   my($a,$b,$c,$d,$date,$method,$uri)=($1,$2,$3,$4,$5,$6,$7);
   # make sure we have a good ip address
   next if ($a &lt; 0 &#124;&#124; $a &gt; 255 &#124;&#124; $b &lt; 0 &#124;&#124; $b &gt; 255 &#124;&#124;
            $c &lt; 0 &#124;&#124; $c &gt; 255 &#124;&#124; $d &lt; 0 &#124;&#124; $d &gt; 255);
   # did we see this IP already?
   next if $seen{&quot;$a.$b.$c.$d&quot;}++;
   # compute value for ipinfo lookup
   my($val)=(($a*256+$b)*256+$c)*256;
   # fetch ipinfo data
   my($r)=$dbh-&gt;selectall_arrayref(qq{select
country_code,region_code,city,latitude,longitude
       from ip_group_city where ip_start &lt;= $val order by ip_start desc
limit 1});
   # no iearth.google.complacemark!
   next if !defined($r);
   print qq{\t\t&lt;Placemark&gt;\n};
   print qq{\t\t\t&lt;name&gt;$a.$b.$c.$d&lt;/name&gt;\n};
   print qq{\t\t\t&lt;styleUrl&gt;#a&lt;/styleUrl&gt;\n};
 #    print qq{\t\t\t&lt;description&gt;$a.$b.$c.$d&lt;/description&gt;\n};
   print qq{\t\t\t&lt;description&gt;&lt;![CDATA[};
   print qq{&lt;b&gt;$method $uri from $r-&gt;[0]-&gt;[0]/$r-&gt;[0]-&gt;[1]/$r-&gt;[0]-&gt;[2]
at &lt;i&gt;$date&lt;/i&gt;&lt;br /&gt;};
   print qq{]]&gt;&lt;/description&gt;\n};
   print qq{\t\t\t&lt;Point&gt;\n};
   print
qq{\t\t\t\t&lt;coordinates&gt;$r-&gt;[0]-&gt;[4],$r-&gt;[0]-&gt;[3]&lt;/coordinates&gt;\n};
   print qq{\t\t\t&lt;/Point&gt;\n};
   print qq{\t\t&lt;/Placemark&gt;\n};
   print qq{\t\t\n};
}
# kml trailer
print qq{\t&lt;/Document&gt;
&lt;/kml&gt;
};
$dbh-&gt;disconnect();

&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Final version. Thanks again for putting this up.</p>
<pre>
use strict;
use DBI;

my %seen;
my $dbh = DBI-&gt;connect("dbi:mysql:ipinfo","hd","hd");
die "unable to connect to database" unless ($dbh);
# kml header
print qq{&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;kml xmlns="http://earth.google.com/kml/2.2"&gt;
\t&lt;Document&gt;
};

print qq{&lt;Style id="a"&gt;};
print qq{&lt;IconStyle&gt;};
print
qq{&lt;Icon&gt;&lt;href&gt;http://maps.google.com/mapfiles/ms/icons/green-dot.png&lt;/h
ref&gt;&lt;/Icon&gt;};
print qq{&lt;/IconStyle&gt;};
print qq{ &lt;/Style&gt;};

# loop over access_log lines
while(&lt;&gt;) {
   # does it look like an access log entry?
   next unless
(/^(\d+)\.(\d+)\.(\d+)\.(\d+).*\[([^\]]+)\]\s+"(\S+)\s+(\S+)\s+HTTP\/\d.
\d/);
   my($a,$b,$c,$d,$date,$method,$uri)=($1,$2,$3,$4,$5,$6,$7);
   # make sure we have a good ip address
   next if ($a &lt; 0 || $a &gt; 255 || $b &lt; 0 || $b &gt; 255 ||
            $c &lt; 0 || $c &gt; 255 || $d &lt; 0 || $d &gt; 255);
   # did we see this IP already?
   next if $seen{"$a.$b.$c.$d"}++;
   # compute value for ipinfo lookup
   my($val)=(($a*256+$b)*256+$c)*256;
   # fetch ipinfo data
   my($r)=$dbh-&gt;selectall_arrayref(qq{select
country_code,region_code,city,latitude,longitude
       from ip_group_city where ip_start &lt;= $val order by ip_start desc
limit 1});
   # no iearth.google.complacemark!
   next if !defined($r);
   print qq{\t\t&lt;Placemark&gt;\n};
   print qq{\t\t\t&lt;name&gt;$a.$b.$c.$d&lt;/name&gt;\n};
   print qq{\t\t\t&lt;styleUrl&gt;#a&lt;/styleUrl&gt;\n};
 #    print qq{\t\t\t&lt;description&gt;$a.$b.$c.$d&lt;/description&gt;\n};
   print qq{\t\t\t&lt;description&gt;&lt;![CDATA[};
   print qq{&lt;b&gt;$method $uri from $r-&gt;[0]-&gt;[0]/$r-&gt;[0]-&gt;[1]/$r-&gt;[0]-&gt;[2]
at &lt;i&gt;$date&lt;/i&gt;&lt;br /&gt;};
   print qq{]]&gt;&lt;/description&gt;\n};
   print qq{\t\t\t&lt;Point&gt;\n};
   print
qq{\t\t\t\t&lt;coordinates&gt;$r-&gt;[0]-&gt;[4],$r-&gt;[0]-&gt;[3]&lt;/coordinates&gt;\n};
   print qq{\t\t\t&lt;/Point&gt;\n};
   print qq{\t\t&lt;/Placemark&gt;\n};
   print qq{\t\t\n};
}
# kml trailer
print qq{\t&lt;/Document&gt;
&lt;/kml&gt;
};
$dbh-&gt;disconnect();
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tobias</title>
		<link>http://www.kahunaburger.com/2009/03/25/apache-access_log-to-google-earth-kml/comment-page-1/#comment-43444</link>
		<dc:creator>Tobias</dc:creator>
		<pubDate>Wed, 08 Apr 2009 01:13:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.kahunaburger.com/?p=1351#comment-43444</guid>
		<description>Thanks Haarith - as I said, if you like this one, wait til you take a look at the one I posted this morning: http://www.kahunaburger.com/2009/04/07/google-earth-forensics/ ;-)</description>
		<content:encoded><![CDATA[<p>Thanks Haarith &#8211; as I said, if you like this one, wait til you take a look at the one I posted this morning: <a href="http://www.kahunaburger.com/2009/04/07/google-earth-forensics/" rel="nofollow">http://www.kahunaburger.com/2009/04/07/google-earth-forensics/</a> <img src='http://www.kahunaburger.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: HaarithDevarajan</title>
		<link>http://www.kahunaburger.com/2009/03/25/apache-access_log-to-google-earth-kml/comment-page-1/#comment-43443</link>
		<dc:creator>HaarithDevarajan</dc:creator>
		<pubDate>Wed, 08 Apr 2009 01:06:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.kahunaburger.com/?p=1351#comment-43443</guid>
		<description>Just Brilliant Tobi. Great work.

I am still playing with your code. saw the co-ordinates move to a 0,0. so trying to figure that part out.

Oh and you could also create style icons instead of placemarks if you wanted to ( that way you can separate/represent different request types with different icons )

 





http://maps.google.com/mapfiles/ms/icons/red-dot.png



 </description>
		<content:encoded><![CDATA[<p>Just Brilliant Tobi. Great work.</p>
<p>I am still playing with your code. saw the co-ordinates move to a 0,0. so trying to figure that part out.</p>
<p>Oh and you could also create style icons instead of placemarks if you wanted to ( that way you can separate/represent different request types with different icons )</p>
<p><a href="http://maps.google.com/mapfiles/ms/icons/red-dot.png" rel="nofollow">http://maps.google.com/mapfiles/ms/icons/red-dot.png</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tobias</title>
		<link>http://www.kahunaburger.com/2009/03/25/apache-access_log-to-google-earth-kml/comment-page-1/#comment-43440</link>
		<dc:creator>Tobias</dc:creator>
		<pubDate>Wed, 08 Apr 2009 00:30:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.kahunaburger.com/?p=1351#comment-43440</guid>
		<description>Thanks for catching this one - no idea why the copy &amp; paste added that extra space. 

Cheers - Tobias

PS: something (or somebody) does not want to keep the &lt;= characters together - I added a warning in the code and need to figure out what keeps on inserting that extra space ...</description>
		<content:encoded><![CDATA[<p>Thanks for catching this one &#8211; no idea why the copy &#038; paste added that extra space. </p>
<p>Cheers &#8211; Tobias</p>
<p>PS: something (or somebody) does not want to keep the <= characters together &#8211; I added a warning in the code and need to figure out what keeps on inserting that extra space &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: HaarithDevarajan</title>
		<link>http://www.kahunaburger.com/2009/03/25/apache-access_log-to-google-earth-kml/comment-page-1/#comment-43439</link>
		<dc:creator>HaarithDevarajan</dc:creator>
		<pubDate>Wed, 08 Apr 2009 00:26:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.kahunaburger.com/?p=1351#comment-43439</guid>
		<description>Great Stuff, thanks.

There is small typo in the code though. not really a typo more of a space.

here ip_start &lt; = $val
should be
here ip_start &lt;= $val

otherwise we get
here ip_start select country_code from ip_group_city where ip_start &lt; = 14203352 order by ip_start desc limit 1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘= 14203352 order by ip_start desc limit 1′ at line 1</description>
		<content:encoded><![CDATA[<p>Great Stuff, thanks.</p>
<p>There is small typo in the code though. not really a typo more of a space.</p>
<p>here ip_start &lt; = $val<br />
should be<br />
here ip_start &lt;= $val</p>
<p>otherwise we get<br />
here ip_start select country_code from ip_group_city where ip_start &lt; = 14203352 order by ip_start desc limit 1;<br />
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘= 14203352 order by ip_start desc limit 1′ at line 1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Google Earth as a traceroute viewer &#124; kahunaburger</title>
		<link>http://www.kahunaburger.com/2009/03/25/apache-access_log-to-google-earth-kml/comment-page-1/#comment-43380</link>
		<dc:creator>Google Earth as a traceroute viewer &#124; kahunaburger</dc:creator>
		<pubDate>Sat, 28 Mar 2009 17:55:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.kahunaburger.com/?p=1351#comment-43380</guid>
		<description>[...] played a bit more with the idea that I presented in &#8220;Apache access_log to Google Earth KML&#8221; and, I think, I came up with something extremely [...]</description>
		<content:encoded><![CDATA[<p>[...] played a bit more with the idea that I presented in &#8220;Apache access_log to Google Earth KML&#8221; and, I think, I came up with something extremely [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>
