3 $songs = glob (dirname($baseDir) . "/Songs/*.pro");
4 $debug = $_REQUEST["debug"];
6 function debug ($msg) {
10 echo "<font color=red>DEBUG:</font> $msg<br>";
14 function getSongs () {
17 $path = "/opt/songbook/Songs";
19 // Why didn't the previous one execute correctly?
20 $songs = glob("$path/*.pro");
23 function songsDropdown () {
26 print "<form method=\"get\" action=\"webchord.cgi\" name=\"song\">";
27 print "Songs: ";
28 print "<select name=\"chordpro\">";
31 foreach ($songs as $song) {
32 $title = basename ($song, ".pro");
33 $artist = getArtist ($song);
35 print "<option value=\"$title.pro\">$title</option>";
38 $title .= " ($artist)";
42 print "<input type=\"submit\" value=\"Go\">";
47 function artistsDropdown () {
50 $artists = getArtists ($songs);
52 print "<form method=\"get\" action=\"displayartist.php\" name=\"artist\">";
53 print "Artists: ";
54 print "<select name=\"artist\">";
57 foreach ($artists as $artist) {
58 print "<option>$artist</option>";
61 print "<input type=\"submit\" value=\"Go\">";
66 function getArtist ($song) {
67 $lyrics = file_get_contents ($song);
69 if (preg_match ("/\{(st|subtitle):(.*)\}/", $lyrics, $matches)) {
70 return trim ($matches[2]);
76 function getArtists ($songs) {
79 foreach ($songs as $song) {
80 $artist = getArtist ($song);
83 $artists[$artist] = 1;
87 return array_keys ($artists);
90 function formatTable ($songs) {
93 foreach ($songs as $song) {
94 $artist = getArtist ($song);
96 $title = basename ($song, ".pro");
98 echo "<li><a href=\"webchord.cgi?chordpro=$song\">$title</a>";
101 echo " ($artist)";