Have you ever wanted you own MySpace tracker? Well look no farther. I’ve decided to convert Jordan’s MySpace tracker to be used in a web application framework. The framework I’ve chosen is Kohana and originally was a fork of CodeIgniter. The code originally was going to be used as a reference for Jordan so he could see what it looks like. Anyways, the tracker is simplistic and doesn’t have all the features that I’ve seen in some of these MySpace trackers. It wasn’t designed to be a full solution or as a replacement. It is good enough for me and I’m sure you’ll find it useful.
Well what does this tracker have? The tracker records the IP address, User Agent, HTTP Referer, Date, Time as well as a tag. The tag is just the name of the picture you use in the link. If you created an image tag <img src=”http://somehost/t/tag-name.gif”> Then the tag name that would show up in the tracker would be “tag-name”. That way you can track multiple profiles or blog posts on MySpace with the same tracker. All you have to do is put an image tag with the link into your profile headline. That way if your profile is set to private it will still record everyone that has clicked on it. It will also record information when someone searches for you. MySpace seems to be upgrading their search so this might not happen as often as it used to.
Once you start getting a few profile views there will be two columns that show up as “unknown”. Using the viewer column you can assign a name to an IP address. You will have to determine who’s IP address it actually is by other means since this cannot be automated. I suggest using a combination of geo ip location service as well as whois information. That way you can tell the rough location of the person’s IP address as well as their ISP. The other column “profile” will also show up as “unknown” this this is going to be your “friendid” or URL to your profile. If you managed to put a link into someone else’s profile through their comments then it could also be their “friendid”. If you put your mouse over the IP address it will show the user agent information in a tool tip. Finally, if you hover your mouse over the info column it will show you any additional parameters. That is only really useful for searches so that you can see what page you came up on and what exactly someone was searching for.
Now let’s talk about the setup. First you will need you own hosting with a PHP5 version >= 5.2.0. You will also need several other extensions as well. You will also need access to a database preferably MySQL since that is the only database I’ve tested with (also I don’t have another database schema). Please use the Kohana database documentation as a reference.
You should only have to modify at most 3 files to get this working correctly. The first file is
.htaccess and you will need to change
RewriteBase if you uploaded the files in any other location than document root. If you put all the files into a folder
/tracker than change the
RewriteBase path from
/tracker. The next file you need to change is
application/config/config.php, but only if you don’t have the files in document root. In that file you will see
$config['site_domain'] and you will need to change
/ to what you put for
RewriteBase. Assuming you have put the files into a folder called
/tracker then your configuration should match below.
# Turn on URL rewriting RewriteEngine On # Installation directory RewriteBase /tracker
<?php defined('SYSPATH') or die('No direct script access.'); /** * Base path of the web site. If this includes a domain, eg: localhost/kohana/ * then a full URL will be used, eg: http://localhost/kohana/. If it only includes * the path, and a site_protocol is specified, the domain will be auto-detected. */ $config['site_domain'] = '/tracker';
The next file you are going to change is the database configuration
application/config/database.php. You will need to change the
database variables to match your own configuration. At this point you will need to create a new database and user to match what you have provided in the configuration. Once that has been done then import the MySQL schema into the newly created database.
You should be able to open your web browser and login. The default username and password is admin / admins. Here is a demo of the tracker that you can log into. Now you need to setup your MySpace profile with an image so when people visit your profile and request the image is saves their information into the tracker. Please use the following as an example. You will need to change the hostname and path if you didn’t install it into document root.
<img src="http://mstdemo.hackdd.net/t/ms-tracker.gif" />
If you had installed it into the
/tracker directory then it would look like this.
<img src="http://mstdemo.hackdd.net/tracker/t/ms-tracker.gif" />
Don’t actually use those for testing in your profile if you care about others seeing your IP address!
The passwords are stored in the MySQL database and are salted with a value I’ve provided. If you wish to change the salt then you will need to open the login model and change $this->salt to a new value. You have to be logged in while you do this so that you can change the password after you changed the salt. If you don’t then you won’t be able to log in. The tracking link by default is going to be
/t if you wish to change this to something else you will have to rename the controller
t.php to something else. You will also have to change the controller name inside the file. There is documentation available for this.
As always all of my code is GPLv2 unless noted otherwise. You can download the MySpace tracker here.
Update (September 03, 2008)
If configuring everything is too much for you or you don’t have any hosting, you are welcome to signup and use my tracker. Just follow the link http://mst.hackdd.net.