Archive for March 2009

UNSW Library Lawn in Photosynth

Today I went out onto the Library Lawn at work and took 75 images, which I then dropped into Microsoft’s rather excellent Photosynth tool, building the panorama you’ll see embedded below (or here) if you’ve got Silverlight plugin installed (unfortunately this excludes OSX):

I really was quite surprised at how quick and easy it was to build this panorama. True, walking around taking lots of photos is a bit of a drag, but the whole process took less than half an hour.

Telstra: give back my grandmother’s phone

My grandmother Lorna

Updated 18 March: Jono H at Telstra is express posting a starter kit & $60 voucher! Now assuming Australia Post does its job, this will all be sorted out by the weekend! I can’t say a big enough thank you to Jono H & Telstra for making this happen. You guys are awesome.

This is my grandmother Lorna. She’s 79 years old, lives on her own, and is completely independent. But she’s still 79 years old, and likes the security of being in contact with her family through her mobile phone. If she ever needs to, she can call us. Or if we can’t get in touch with her at home, we can call her.

That is, until Telstra cancelled her pre-paid mobile phone because she hadn’t put any more money into her account in the last few  months.

Here’s how Telstra Pre-Paid works. You buy a SIM card with a credit balance for phone calls, and put it in any phone. The balance on your account also comes with a credit expiry date, which you extend by putting more money on your account. After this date passes, your phone goes into a “recharge only period” in which you need to add more money, regardless of your account balance. After a few more months, Telstra deactivates your phone and keeps any money left in your account. (You can find out more in this document at points 3.7 to 3.26.)

My grandmother doesn’t make that many calls from her mobile phone, so she doesn’t recharge her credit very often. Why, then, does Telstra have the right to switch off her mobile phone service and pocket the money in her account? Does it put too much of a hole in Telstra’s bottom line to provide a phone service that generally only receives calls? (Telstra’s net profit in 2007/08 was $3.7 billion, up 13% on the previous year.)

Of course I called Telstra to try to sort this out. On my first call to 1258880 I was told that the service was “quarantined” on 11 March, and that it could only be reactivated after six months. When I asked about having it reactivated sooner, I was told to call 125111. I called this number, and after being transferred to the “prepaid” division was told that the phone number had been “deactivated” on 11 March, and there was no chance it was ever coming back. Impossible. So which one of these is it, Telstra?

This is all I want: to be able to hand my grandmother’s mobile phone back to her in working order, on Friday, so she can take it with her on holidays. Is that too hard to ask, Telstra? You can contact me at flashman@gmail.com or on Twitter. Here’s your chance to shine & show you’re not just a corporate monolith. Please don’t disappoint us.

HOWTO: Track user activity on your PHPBB forum

Introduction

I run a music forum called Small Night In using PHPBB forum software. Like any website owner, I’m interested in the user activity on my site. That’s why I run Google Analytics, which covers visitor numbers, referring sites, and a wealth of other useful data. Additionally, PHPBB reports the number of users, topics and posts in total and on average.

However, what PHPBB doesn’t report is potentially more useful: long-term trends in growth or decline of active users and new posts. Tracking visits in Google Analytics isn’t sufficient, because some visitors are casual and don’t return – active, registered users are the most valuable to a forum. Tracking the average daily number of posts is no good either, because it gives an average and not an ongoing series of activity snapshots.

To address both these issues, I’ve written a useful script which will allow someone with a minimal amount of PHP/MySQL knowledge to track the long-term number of active users and daily posts on their website.

The script, in brief:

  • Get the time and date 24 hours ago
  • Count how many users last visited later than that time
  • Count how many posts were created later than that time
  • Output the results

The script output is (according to the user’s needs) either a simple PHP echo() of the number to a webpage, or written to a .CSV file for easy long-term tracking and charting.

The script

The first part of the code is just database settings, which you should personalise as needed:

// Change these to your MySQL details
$host = "localhost"; // you probably won't need to change this setting
$user = "your_php_username";
$pass = "your_php_password";
$database = "your_phpbb_database_name";

The next section grabs the current timestamp and subtracts one day’s worth of seconds, as well as yesterday’s date in YYYY-MM-DD format:


$time24hoursago = time() - 86400; // Get the timestamp for a day ago by subtracting 24*60*60 seconds
$date = date('Y-m-d', $time24hoursago);

In the next section, we get the number of entries (users) in `phpbb_users` where the timestamp in `user_lastvisit` is more recent than the $time24hoursago timestamp:


// Database query, recent users
$conn = mysql_connect( $host, $user, $pass ) or die ("Could not connect to MySQL");
$rs = @mysql_select_db($database, $conn) or die("Could not connect to database");
$sql="SELECT COUNT(user_id) FROM `phpbb_users` WHERE `user_lastvisit` > '$time24hoursago'";
$rs = mysql_query( $sql,$conn );
$activeusers = mysql_fetch_array($rs);

Then we do the same thing for recent posts:


// Database query, recent posts
$sql="SELECT COUNT(`post_id`) FROM `phpbb_posts` WHERE `post_time` > '$time24hoursago'";
$rs = mysql_query( $sql,$conn );
$posts = mysql_fetch_array($rs);

Now the arrays $activeusers and $posts contain the number of users and posts. If you just want to see the results, a simple echo command will do the trick:


echo $date . ',' . $activeusers["0"] . ',' . $posts["0"];

Of course, you might be like me, and want to automate the entire process using cron. This next bit of script will write the date and number to a .CSV file called “forum_activity.csv” in the format YYYY_MM_DD,users,posts. For the following process, I’ve modified the file append tutorial on Tizag.com:


$myFile = "public_html/scripts/forum_activity.csv"; // this is the file we'll put the results in
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = $date . ',' . $activeusers["0"] . ',' . $posts["0"] . "\n";
fwrite($fh, $stringData);
fclose($fh);

Mind the file path $myFile. If you’re running this script through a web browser, you’ll want to make the reference local – that is, have the file path as just “forum_activity.csv” and place the file in the same folder as the script. But if you run this script through cron – for instance daily at midnight, as I do – you’ll want to put the full path to the .csv file or cron won’t be able to find it. Always test before leaving this running for a week and finding it doesn’t work!