2 $songs = glob ("/web/songbook/Songs/*.pro");
4 function songsDropdown () {
7 print "<form method=\"post\" action=\"webchord.cgi\" name=\"song\">";
8 print "Songs: ";
9 print "<select name=\"chordpro\">";
12 foreach ($songs as $song) {
13 $title = basename ($song, ".pro");
14 $artist = getArtist ($song);
17 $title .= " ($artist)";
20 print "<option value=\"$song\">$title</option>";
23 print "<input type=\"submit\" value=\"Go\">";
28 function artistsDropdown () {
31 $artists = getArtists ($songs);
33 print "<form method=\"post\" action=\"displayartist.php\" name=\"artist\">";
34 print "Artists: ";
35 print "<select name=\"artist\">";
38 foreach ($artists as $artist) {
39 print "<option>$artist</option>";
42 print "<input type=\"submit\" value=\"Go\">";
47 function getArtist ($song) {
48 $lyrics = file_get_contents ($song);
50 if (preg_match ("/\{(st|subtitle):(.*)\}/", $lyrics, $matches)) {
51 return trim ($matches[2]);
57 function getArtists ($songs) {
60 foreach ($songs as $song) {
61 $artist = getArtist ($song);
64 $artists[$artist] = 1;
68 return array_keys ($artists);
71 function formatTable ($songs) {
74 foreach ($songs as $song) {
75 $artist = getArtist ($song);
77 $title = basename ($song, ".pro");
79 echo "<li><a href=\"webchord.cgi?chordpro=$song\">$title</a>";
82 echo " ($artist)";