Reply To: counter per user


@WzrdOfOOst wrote:

Hello I have been using mt-daapd server since a couple of months and wrote a bit of php code to display the number of played songs per user. it uses the log file to check. I am not a very experienced php-programmer actually this is my first bit of code. So don`t flame me…
Check my blog for my experiences with the daap server.

$myFile = "mt-daapd.log";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));

$address = array('/','/','/') ;
$name = array(john, Joe, Lisa);
for ( $counter = 0; $counter <= 2; $counter += 1) {

if (preg_match_all($address[$counter], $theData, $user)) {
echo $name[$counter]," ", count($user[0]), "
} else {
echo $name[$counter]," did not play any songs";


Neat! There are some interesting things you could do with that if you wanted to play in the database as well… Using php and sqlite, you could take results like that and make them an iTunes playlist by poking it right into the database. Then you could have iTunes playlists (for example), with the last 5 things everyone played.

Or the last 20 songs anyone has played. Or what have you.

Neat stuff you can do by reaching right into the database and poking around.

— Ron