DEBUG: $msg
";
} // if
} // debug
function getSongs () {
global $songs;
$path = "/opt/songbook/Songs";
// Why didn't the previous one execute correctly?
$songs = glob("$path/*.pro");
} // getSongs
function songsDropdown () {
global $songs;
print "
";
} // songsDropdown
function artistsDropdown () {
global $songs;
$artists = getArtists ($songs);
print "";
} // artistsDropdown
function getArtist ($song) {
$lyrics = file_get_contents ($song);
if (preg_match ("/\{(st|subtitle):(.*)\}/", $lyrics, $matches)) {
return trim ($matches[2]);
} else {
return "";
} // if
} // getArtist
function getArtists ($songs) {
$artists = array();
foreach ($songs as $song) {
$artist = getArtist ($song);
if ($artist != '') {
$artists[$artist] = 1;
} // if
} // foreach
return array_keys ($artists);
} // getArtists
function formatTable ($songs) {
echo "";
foreach ($songs as $song) {
$artist = getArtist ($song);
$title = basename ($song, ".pro");
echo "- $title";
if ($artist != "") {
echo " ($artist)";
} // if
} // foreach
echo "
";
} // formatTable