3 $songDir = "/opt/songbook/Songs";
5 if (isset ($_REQUEST['debug'])) {
6 $debug = $_REQUEST['debug'];
9 // Initialize music objects
10 $songs = getSongs($songDir);
11 $sets = getSets($songDir);
12 $artists = getArtists($songs);
14 function debug ($msg) {
18 echo "<font color=red>DEBUG:</font> $msg<br>";
22 function getSongs ($songDir) {
23 return glob("$songDir/*.pro");
26 function getSets ($songDir) {
27 return glob("$songDir/*.lst");
30 function songsDropdown () {
33 print "<form method=\"get\" action=\"webchord.cgi\" name=\"song\">";
34 print "Songs: ";
35 print "<select name=\"chordpro\">";
38 foreach ($songs as $song) {
39 $title = basename ($song, ".pro");
40 $artist = getArtist ($song);
42 print "<option value=\"$title.pro\">$title</option>";
45 $title .= " ($artist)";
50 print " <input type=\"submit\" value=\"Go\">";
54 function artistsDropdown () {
57 print "<form method=\"get\" action=\"displayartist.php\" name=\"artist\">";
58 print "Artists: ";
59 print "<select name=\"artist\">";
62 foreach ($artists as $artist) {
63 print "<option>$artist</option>";
67 print " <input type=\"submit\" value=\"Go\">";
71 function setsDropdown () {
74 print "<form method=\"get\" action=\"displayset.php\" name=\"set\">";
75 print "Sets: ";
76 print "<select name=\"set\">";
79 foreach ($sets as $set) {
80 print "Processing set<br>";
81 $title = basename ($set, ".lst");
83 print "<option value=\"$title.lst\">$title</option>";
87 print " <input type=\"submit\" value=\"Go\">";
91 function getArtist ($song) {
92 $lyrics = @file_get_contents ($song);
94 if (preg_match ("/\{(st|subtitle):(.*)\}/", $lyrics, $matches)) {
95 return trim ($matches[2]);
101 function getArtists ($songs) {
102 foreach ($songs as $song) {
103 $artist = getArtist ($song);
106 $artists[$artist] = 1;
110 return array_keys ($artists);