//set cookies if any time selection was made
//This must be done before any page output
// require_once 'inc_setcookies.php'; //reads $GET_ dh and h24
$i = $_GET['h24'];
if(strlen($i)) {
$h24 = intval($i);
setcookie('h24', $i, time() + 3600 * 720);
}
$i = $_GET['dh'];
if(strlen($i)) {
$dh = intval($i);
setcookie('dh', $i, time() + 3600 * 720);
}
?>
ErrorFM Playlist Archive - ErrorFM Live
print "".$title[$chan]." Change time zone: ";
require 'inc_sel_tz.php';
print ' Return to ErrorFM
';
require 'inc_datformat.php';
$file = "pl$chan.dat";
$t = $date = $lastdate = '';
$fh = @fopen($file, 'rb');
if(!$fh) die("Missing or file busy: $file");
list($dum, $current) = unpack('s', @fread($fh, 2));
if($db) print " current = $current
\n";
if($current < -1 or $current > $recordmax) {
@fclose($fh);
if($db) print "Damaged file $file
";
} else {
if($current >= 0) {
unset($list);
//First, read all records after current
for($r = $current+1; $r <= $recordmax; $r++) $list[] = getRec($fh, $r);
//then read all records from 0 to current
for($r = 0; $r <= $current; $r++) $list[] = getRec($fh, $r);
array_reverse($list);
print '';
for($i = count($list)-1; $i >= 0; $i--) if($list[$i][1]) {
$t = $list[$i][0]+$timeoffset;
$date = date('l M j, Y', $t);
if($date != $lastdate) {
print ''.$date.' |
';
$lastdate = $date;
}
$class = (date('G', $t) % 2);
print ''.date($timefmt, $t).' | '
.''.$list[$i][1].' |
';
}
print '
';
} else {
print "(empty)
";
}
@fclose($fh);
}
if($db) print "
\n";
function getRec($fh, $r) {
global $headersize, $recordsize, $titlemax, $db;
#if($db) print " $r: ";
@fseek($fh, $headersize + $r*$recordsize);
list($dum, $time) = unpack('L', @fread($fh, 4));
list($dum, $strlen) = unpack('C', @fread($fh, 1));
#if($db) print dechex($time)." :: ";
if($strlen) list($dum, $song) = unpack('a'.$strlen, fread($fh, $titlemax));
#if($db) print "[$lastsong]
\n";
return array($time, $song);
}
?>