3 $songbook = "/opt/songbook";
4 $songFolder = "Andrew";
5 $songDir = "/opt/songbook/$songFolder";
7 if (isset ($_REQUEST['debug'])) {
8 $debug = $_REQUEST['debug'];
11 // Initialize music objects
12 $songs = getSongs($songDir);
13 $sets = getSets($songDir);
14 $artists = getArtists($songs);
16 function debug ($msg) {
20 echo "<font color=red>DEBUG:</font> $msg<br>";
24 function getSongs ($songDir) {
25 return glob("$songDir/*.pro");
28 function getSets ($songDir) {
29 return glob("$songDir/*.lst");
32 function songsDropdown () {
35 print "<form method=\"get\" action=\"webchord.cgi\" name=\"song\">";
36 print "Songs: ";
37 print "<select name=\"chordpro\">";
40 foreach ($songs as $song) {
41 $title = basename ($song, ".pro");
42 $artist = getArtist ($song);
44 print "<option value=\"$title.pro\">$title</option>";
47 $title .= " ($artist)";
52 print " <input type=\"submit\" value=\"Go\">";
56 function artistsDropdown () {
59 print "<form method=\"get\" action=\"displayartist.php\" name=\"artist\">";
60 print "Artists: ";
61 print "<select name=\"artist\">";
64 foreach ($artists as $artist) {
65 print "<option>$artist</option>";
69 print " <input type=\"submit\" value=\"Go\">";
73 function setsDropdown () {
76 print "<form method=\"get\" action=\"displayset.php\" name=\"set\">";
77 print "Sets: ";
78 print "<select name=\"set\">";
81 foreach ($sets as $set) {
82 print "Processing set<br>";
83 $title = basename ($set, ".lst");
85 print "<option value=\"$title.lst\">$title</option>";
89 print " <input type=\"submit\" value=\"Go\">";
93 function getArtist ($song) {
94 $lyrics = @file_get_contents ($song);
96 if (preg_match ("/\{(st|subtitle):(.*)\}/", $lyrics, $matches)) {
97 return trim ($matches[2]);
103 function getArtists ($songs) {
104 foreach ($songs as $song) {
105 $artist = getArtist ($song);
108 $artists[$artist] = 1;
112 return array_keys ($artists);