Nov 09 2006

Disecting A Self Counting MySpace Bulletin

Published by at 12:54 pm under PHP

This is an old article and the information contained within it may be out of date, not reflect my current views and/or contain broken links. If you feel this article is still valid and requires updating, you can use the contact form to let me know. However, I make no guarantee that it will get updated.

I came across a MySpace bulletin that announced itself as “The only bulletin that counts how many times its been posted!”. If read someone elses bulletin all you need to do is click the link at the bottom and it loads up your own bulletin posting form for you to repost the bulletin with the latest posting count.

Being the inquisitive sort of person I am [trying to be]. I decided to take a look at how the bulletin works. Whilst it appears to work by magic, the code behind it is very simple. The link that you click in the bulletin to repost it is actually a link to This page contains a form on it that is the same as the MySpace bulletin posting form (only on a different server). The user never sees this form, however, as when the page is loaded javascript on the page automatically submits the form to MySpace.

But how does the count get updated? That’s very simple and comes down to three lines of code:

$count= read_file("count.txt");

What happens is when you click the repost bulletin link, the bullcount.php page opens up the count.txt file, reads the number, adds one and saves the number again. It then creates the bulletin post form (including the new count) and submits it for you. Quite simple really.

This is all very nice, however, unless you know what you are doing you’ll never know quite how far the bulletin has got to, even if you have a lot of friends on MySpace you’ll only get the latest count so long as your friends re-post the bulletin. So I propose an upgrade to this simple setup. Whilst it is not possible to dynamically change the number in the bulletin, we can change the number in the body of the bulletin. This can be done using a dynamically generated gif (a graphical representation of the number), which is very trivial in PHP and there are numerous scripts out there which do just this. The result would be that the bulletin title could indicate at which point the users joined the chain, and the image in the bulletin body would indicate how far it has got.

The current implementation relies on a simple text file but this can lead to all sorts of concurrency problems, especially if you have 100,000 users opening it for outputting to the gif, therefore this upgrade may require a change to using a DB that can handle locking but I’ll leave that for someone else to sort out.

If you’re planning on creating your own version the code required for the bulletin posting form is:

<form name="bulletinForm" action="" method="POST" target="_self">
<input type="hidden" name="groupID" value="0">
<input type="hidden" name="hashcode" value="MHsGCisGAQQBgjdYA8igbTBrBgorBgEEAYI3WAMBoF0wWwIDAgABAgJmAwICAMAECMDZad0h0zS3BBBjEFtHHZcIPZ22xHDNx80PBDB/bOdbTVXoblD/iQi1aMqvh//wZuk7RhaHgFKCy/h6bH0MSkrfs7r9H1gdk0fA69k=">
<input type="hidden" name="hash" value="6308J150O169O160O160O153O168O157O162">
<div style="visibility:hidden;display:none;">
<input type="hidden" name="subject" value="
echo("Let's see how big this can get. Repost number: $count");
" size="1" maxlength="50">
<textarea name="body" type="hidden" style="width: 0px; height: 0px;"><Center>
<font face="comic sans ms">
This is the only bulliten that counts how many times its been posted!<br>
So far this bulletin has been posted<br><big>
<?php echo("$count"); ?></big><br>
<a href="">
Click here to repost this bulletin</a><br>
<input type="submit" value="Click here if you're not automatically redirected.">

This code was “borrowed” from here… I assume they don’t mind me re-posting it as they did put the source code online :)

3 responses so far