3 $songs = glob (dirname($baseDir) . "/Songs/*.pro");
8 $path = "/opt/clearscm/songbook/Songs";
10 // Why didn't the previous one execute correctly?
11 $songs = glob("$path/*.pro");
14 function songsDropdown () {
17 print "<form method=\"get\" action=\"webchord.cgi\" name=\"song\">";
18 print "Songs: ";
19 print "<select name=\"chordpro\">";
22 foreach ($songs as $song) {
23 $title = basename ($song, ".pro");
24 $artist = getArtist ($song);
26 print "<option value=\"$title.pro\">$title</option>";
29 $title .= " ($artist)";
33 print "<input type=\"submit\" value=\"Go\">";
38 function artistsDropdown () {
41 $artists = getArtists ($songs);
43 print "<form method=\"get\" action=\"displayartist.php\" name=\"artist\">";
44 print "Artists: ";
45 print "<select name=\"artist\">";
48 foreach ($artists as $artist) {
49 print "<option>$artist</option>";
52 print "<input type=\"submit\" value=\"Go\">";
57 function getArtist ($song) {
58 $lyrics = file_get_contents ($song);
60 if (preg_match ("/\{(st|subtitle):(.*)\}/", $lyrics, $matches)) {
61 return trim ($matches[2]);
67 function getArtists ($songs) {
70 foreach ($songs as $song) {
71 $artist = getArtist ($song);
74 $artists[$artist] = 1;
78 return array_keys ($artists);
81 function formatTable ($songs) {
84 foreach ($songs as $song) {
85 $artist = getArtist ($song);
87 $title = basename ($song, ".pro");
89 echo "<li><a href=\"webchord.cgi?chordpro=$song\">$title</a>";
92 echo " ($artist)";