<?php
-$baseDir = getcwd();
-$songDir = "/opt/songbook/Songs";
-$debug = $_REQUEST["debug"];
+$baseDir = getcwd();
+$songbook = "/opt/songbook";
+$songFolder = "Andrew";
+$songDir = "/opt/songbook/$songFolder";
+
+if (isset ($_REQUEST['debug'])) {
+ $debug = $_REQUEST['debug'];
+} // if
+
+// Initialize music objects
+$songs = getSongs($songDir);
+$sets = getSets($songDir);
+$artists = getArtists($songs);
function debug ($msg) {
global $debug;
} // if
} // debug
-function getSongs () {
- global $songDir;
-
+function getSongs ($songDir) {
return glob("$songDir/*.pro");
} // getSongs
-function getSets () {
- global $songDir;
-
+function getSets ($songDir) {
return glob("$songDir/*.lst");
} // getSets
function songsDropdown () {
- $songs = getSongs();
+ global $songs;
print "<form method=\"get\" action=\"webchord.cgi\" name=\"song\">";
print "Songs: ";
} // songsDropdown
function artistsDropdown () {
- $songs = getSongs();
- $artists = getArtists ($songs);
+ global $artists;
print "<form method=\"get\" action=\"displayartist.php\" name=\"artist\">";
print "Artists: ";
} // artistsDropdown
function setsDropdown () {
- $sets = getSets();
+ global $sets;
print "<form method=\"get\" action=\"displayset.php\" name=\"set\">";
print "Sets: ";
} // setsDropdown
function getArtist ($song) {
- $lyrics = file_get_contents ($song);
+ $lyrics = @file_get_contents ($song);
if (preg_match ("/\{(st|subtitle):(.*)\}/", $lyrics, $matches)) {
return trim ($matches[2]);
} // getArtist
function getArtists ($songs) {
- $artists = array();
-
foreach ($songs as $song) {
$artist = getArtist ($song);
return array_keys ($artists);
} // getArtists
-function formatTable ($songs) {
- echo "<ol>";
-
- foreach ($songs as $song) {
- $artist = getArtist ($song);
-
- $title = basename ($song, ".pro");
-
- echo "<li><a href=\"webchord.cgi?chordpro=$song\">$title</a>";
-
- if ($artist != "") {
- echo " ($artist)";
- } // if
- } // foreach
-
- echo "</ol>";
-} // formatTable