Show listen.php syntax highlighted
<?php
require_once ('core/ecp-full.php'); // Include basic classes
try {
$MusicLibrary = ModulesManager :: loadModule('MusicLibrary');
} catch (NoModuleException $e) {
exit ('Something went wrong.');
}
if (isset ($_GET['file'])) {
$songs = array (
base64_decode($_GET['file']
));
}
$songs = array ();
foreach ($_POST as $name => $value) {
$pos = strpos($name, 'song');
if ($pos !== false && $pos === 0) {
$songs[] = $value;
}
}
if (!sizeof($songs)) {
var_dump($songs);
exit ('nothing to play');
}
$playlist = date('d-m-Y') . '-' . User :: $profile->id;
header("Content-Disposition: attachment; filename=\"" . $playlist . ".pls\"");
header("Content-Type: audio/x-scpls");
if (@ !file_exists('playlists/' . User :: $profile->id))
mkdir('playlists/' . User :: $profile->id);
?>
[playlist]
NumberOfEntries=<?=sizeof($songs)?>
<?php
foreach ($songs as $id => $song) {
$source = false;
$song = explode('#####', $song);
$letter = base64_decode($song[0]);
$song = $song[1];
$MusicLibrary->selectDriveLetter($letter);
$path = $MusicLibrary->getSelectedDrive();
if (@ file_exists($path . $song)) {
$source = $path . $song;
} else
if (@ file_exists($song)) {
$source = $song;
}
if ($source !== false && !empty ($song)) {
if ($MusicLibrary->getSettings()->localUser) {
echo 'File' . ((int) $id +1) . '=' . $source;
} else {
$filename = 'playlists/' . User :: $profile->id . '/' . ((int) $id +1) . '.mp3';
if (@ file_exists($filename)) {
unlink($filename);
}
symlink($source, $filename);
echo 'File' . ((int) $id +1) . '=http://ecp/playlists/' . User :: $profile->id . '/' . ((int) $id +1) . '.mp3';
}
?>
<?php
}
}
?>
See more files for this project here