3 $songs = glob ($baseDir . "/Songs/*.pro");
5 function songsDropdown () {
8 print "<form method=\"post\" action=\"webchord.cgi\" name=\"song\">";
9 print "Songs: ";
10 print "<select name=\"chordpro\">";
13 foreach ($songs as $song) {
14 $title = basename ($song, ".pro");
15 $artist = getArtist ($song);
18 $title .= " ($artist)";
21 print "<option value=\"$song\">$title</option>";
24 print "<input type=\"submit\" value=\"Go\">";
29 function artistsDropdown () {
32 $artists = getArtists ($songs);
34 print "<form method=\"post\" action=\"displayartist.php\" name=\"artist\">";
35 print "Artists: ";
36 print "<select name=\"artist\">";
39 foreach ($artists as $artist) {
40 print "<option>$artist</option>";
43 print "<input type=\"submit\" value=\"Go\">";
48 function getArtist ($song) {
49 $lyrics = file_get_contents ($song);
51 if (preg_match ("/\{(st|subtitle):(.*)\}/", $lyrics, $matches)) {
52 return trim ($matches[2]);
58 function getArtists ($songs) {
61 foreach ($songs as $song) {
62 $artist = getArtist ($song);
65 $artists[$artist] = 1;
69 return array_keys ($artists);
72 function formatTable ($songs) {
75 foreach ($songs as $song) {
76 $artist = getArtist ($song);
78 $title = basename ($song, ".pro");
80 echo "<li><a href=\"webchord.cgi?chordpro=$song\">$title</a>";
83 echo " ($artist)";