/    Sign up×
Community /Pin to ProfileBookmark

icecast playlist php script

The following script will clear the screen because ‘document.write’ is used.

How can I change the following php script without using ‘document.write’ but achieving the same results?

[code=php]
<?php

echo “<br>”;

define(‘MAX_RESULTS’, 12);

$playlist = ‘/var/icecast/log/playlist.log’;

$fp = fopen($playlist, ‘r’);

$results = array();

while (($parts = fgetcsv($fp, 0, ‘|’)) !== FALSE)
{
if ((count($parts) != 4) || (strpos($parts[1], ‘/stream’) === false)) {
continue;
}

$date = DateTime::createFromFormat(‘d/M/Y:H:i:s O’, $parts[0]);

$results[] = sprintf(“<h1 class=’playlist-time’><script>document.write(Globalize.format( new Date(‘Thu, Jun 01, 2015 %s:00 GMT+0100 (BST)’), ‘HH:mm’));</script></h1>n<h1 class=’playlist-track’>%s</h1>”, $date->format(‘H:i’), $parts[3]);

if (count($results) > MAX_RESULTS) {
array_shift($results);
}
}
foreach (array_reverse($results) as $item) {
echo “$item”;

}

echo “<br>”;
?>

[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmJun 02.2015 — Is this script used in an ajax call? I question why the concern about erasing a screen area (actually, an html tag) from a php script. A normal php script echoing out html tags is going to rewrite the screen anyway so why worry about an erase? I can see this as a concern in an ajax handler tho.

PS - unless you are re-sizing the default h1 tag font size, this is going to be a pretty bold looking output, no?
×

Success!

Help @dustyfoo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...