Hallo ben opzoek naar een php script dat de laatste 10 nummers weergeeft wat je gedraaid heb via de live stream. Het voorbeeld staat hier http://www.radiocontinue.nl/play_list/read_last100.php alleen wou ik dit graag weergeven van de laatste 10 nummers.
P.s dat script van die site heb ik niet gemaakt.
Wel heb ik ergens een script gevonden alleen die wil maar niet werken
<?class Radio
{
var $fields;
var $very_first_str;
var $domain, $port;
var $errno, $errstr;
var $trackLists = array();
function Radio($domain, $port)
{
$this->domain = $domain;
$this->port = $port;
$this->setOffset("Current Stream Information");
$this->setTableStart("<table border=0 cellpadding=2 cellspacing=2>");
$this->setTableEnd("</table>");
}
function setFields($array=array())
{
$this->fields = $array;
}
function setOffset($string)
{
$this->very_first_str = $string;
}
function setTableStart($string)
{
$this->tableStart = $string;
}
function setTableEnd($string)
{
$this->tableEnd = $string;
}
function getHTML($page)
{
$contents = "";
$domain = (substr($this->domain, 0, 7) == "http://") ? substr($this->domain, 7) : $this->domain;
if ($fp = fsockopen($domain, $this->port, $this->errno, $this->errstr, 2))
{
fputs($fp, "GET ".$page." HTTP/1.1\r\n".
"User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 9\r\n".
"Host: ".$domain."\r\n\r\n");
while (!feof($fp))
$contents .= fgets($fp, 256);
fclose ($fp);
return $contents;
}
else
{
return False;
}
}
function getServerInfo($page="/", $display_array=null, $very_first_str=null)
{
if (!isset($display_array))
$display_array = $this->fields;
if (!isset($very_first_str))
$very_first_str = $this->very_first_str;
if ($html = $this->getHTML($page))
{
// parsing the contents
foreach ($display_array AS $key => $item)
{
$very_first_pos = stripos($html, $very_first_str);
$first_pos = stripos($html, $item, $very_first_pos);
$line_start = strpos($html, "<td>", $first_pos);
$line_end = strpos($html, "</td>", $line_start) + 4;
$difference = $line_end - $line_start;
$line = substr($html, $line_start, $difference);
$data[$key] = strip_tags($line);
}
return $data;
}
else
{
return $this->errstr." (".$this->errno.")";
}
}
function createHistoryArray($page)
{
if (!in_array($page, $this->trackLists))
{
$this->trackLists[] = $page;
if ($html = $this->getHTML($page))
{
$fromPos = stripos($html, $this->tableStart);
$toPos = stripos($html, $this->tableEnd);
$tableData = substr($html, $fromPos, ($toPos-$fromPos));
$lines = explode("</tr><tr>", $tableData);
$tracks = array();
$c = 0;
foreach ($lines AS $line)
{
$info = explode ("</td><td>", $line);
$time = trim(strip_tags($info[0]));
if (substr($time, 0, 9) != "Copyright")
{
$this->tracks[$c]['time'] = $time;
$this->tracks[$c++]['track'] = trim(strip_tags($info[1]));
}
}
unset($this->tracks[0]);
$this->tracks[1]['track'] = str_replace("Current Song", "", $this->tracks[1]['track']);
}
else
{
$this->tracks[0] = array("time"=>$this->errno, "track"=>$this->errstr);
}
}
}
function getHistoryArray($page="/played.html")
{
if (!in_array($page, $this->trackLists))
$this->createHistoryArray($page);
return $this->tracks;
}
function getHistoryTable($page="/played.html", $timeColText=False, $trackColText=False, $class=False)
{
if (!in_array($page, $this->trackLists))
$this->createHistoryArray($page);
$output = "<table".($class ? " class=\"".$class."\"" : "").">";
if ($timeColText && $trackColText)
$output .= "<tr><td>".$timeColText."</td><td>".$trackColText."</td></tr>";
foreach ($this->tracks AS $trackArr)
$output .= "<tr><td>".$trackArr['time']."</td><td>".$trackArr['track']."</td></tr>";
$output .= "</table>\n";
return $output;
}
}
// this is needed for those with a php version < 5
// the function is copied from the user comments @ php.net (http://nl3.php.net/stripos)
if (!function_exists("stripos"))
{
function stripos($haystack, $needle, $offset=0)
{
return strpos(strtoupper($haystack), strtoupper($needle), $offset);
}
}
Iemand een oplossing