Tuesday, December 05, 2006

Play counter mt-daapd part 2

Yesterday I told about the counter of my daap-server. I altered the code a bit and now it is smaller.
$myFile = "mt-daapd.log";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);

$address = array('/172.19.3.22/','/172.19.3.19/','/172.19.3.18/') ;
$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";
}
}
?>

1 comment:

Anonymous said...

Above the topic is very helpful to improve my linux web hosting related information.Above all the points are explained very clearly.Reading this kind of article is worthy.web hosting in india