3 $songDir = "/opt/songbook/Songs";
4 $debug = $_REQUEST["debug"];
6 // Initialize music objects
7 $songs = getSongs($songDir);
8 $sets = getSets($songDir);
9 $artists = getArtists($songs);
11 function debug ($msg) {
15 echo "<font color=red>DEBUG:</font> $msg<br>";
19 function getSongs ($songDir) {
20 return glob("$songDir/*.pro");
23 function getSets ($songDir) {
24 return glob("$songDir/*.lst");
27 function songsDropdown () {
30 print "<form method=\"get\" action=\"webchord.cgi\" name=\"song\">";
31 print "Songs: ";
32 print "<select name=\"chordpro\">";
35 foreach ($songs as $song) {
36 $title = basename ($song, ".pro");
37 $artist = getArtist ($song);
39 print "<option value=\"$title.pro\">$title</option>";
42 $title .= " ($artist)";
47 print " <input type=\"submit\" value=\"Go\">";
51 function artistsDropdown () {
54 print "<form method=\"get\" action=\"displayartist.php\" name=\"artist\">";
55 print "Artists: ";
56 print "<select name=\"artist\">";
59 foreach ($artists as $artist) {
60 print "<option>$artist</option>";
64 print " <input type=\"submit\" value=\"Go\">";
68 function setsDropdown () {
71 print "<form method=\"get\" action=\"displayset.php\" name=\"set\">";
72 print "Sets: ";
73 print "<select name=\"set\">";
76 foreach ($sets as $set) {
77 print "Processing set<br>";
78 $title = basename ($set, ".lst");
80 print "<option value=\"$title.lst\">$title</option>";
84 print " <input type=\"submit\" value=\"Go\">";
88 function getArtist ($song) {
89 $lyrics = file_get_contents ($song);
91 if (preg_match ("/\{(st|subtitle):(.*)\}/", $lyrics, $matches)) {
92 return trim ($matches[2]);
98 function getArtists ($songs) {
99 foreach ($songs as $song) {
100 $artist = getArtist ($song);
103 $artists[$artist] = 1;
107 return array_keys ($artists);