Notice: The following tutorial is not to be used in ways that are against the law. It only demonstrates a problem that can be caused by the way blogger.com uses profile images. A similar technique is used by many ad services.
Suppose you want more info on the traffic, or even trying to find out the real identity of a blogger who maintains a blog at blogger.com -or even their visitors. How can you do this? Here is a simple step-by-step recipe….
What you need (other ingredients can be used too, this is just an example):
1 server running PHP + MySQL
1 blogger.com account
Cooking:
- Choose the jpeg image you will use for your blogger.com profile “photo” (preferably one not bigger than 64×64). Let’s say photo.jpg
- Upload this photo at your server. Let’s say the address is http://myserver/mydir/photo.jpg
- Create the following table at your MySQL db: <pre>create table blogger_stats(dt timestamp, ip varchar(27),
page varchar(255), agent varchar(255)) ;</pre>
- Create the following php script, and upload it as http://myserver/mydir/photo.php
<pre>
require_once 'DB.php' ;
$DSN = "mysql://dbuser:dbpass@localhost/dbname";
$bit_db = DB::connect($DSN);
$res=$bit_db->query("INSERT INTO blogger_stats(ip, page, agent)
VALUES('{$_SERVER['REMOTE_ADDR']}','{$_SERVER['HTTP_REFERER']}',
'{$_SERVER['HTTP_USER_AGENT']}') ");
header ('Content-Length: ' . filesize('./photo.jpg') ) ;
header('Content-Type: image/jpeg') ;
readfile('./photo.jpg') ;
</pre>
- If there is not a .htaccess file in this directory, create an empty one.
- put the following lines in this .htaccess file: <pre>
RewriteEngine On
RewriteRule ^photo.jpg photo.php
</pre>
- Now use http://myserver/mydir/photo.jpg as your photo in your blogger.com profile.
You are ready!
Just put a comment in any post you want to “keep an eye”. Every time someone visits the comments page, you will have a new entry in the blogger_stats table. Actually this is a nice way to keep your blog’s stats too (this is how it started for me)!
(The technique can be improved with the use of cookies, but this is out of the scope of this article!)