Added Bob's list
authorAndrew DeFaria <Andrew@DeFaria.com>
Tue, 1 Aug 2017 22:38:58 +0000 (15:38 -0700)
committerAndrew DeFaria <Andrew@DeFaria.com>
Tue, 1 Aug 2017 22:38:58 +0000 (15:38 -0700)
Also change displayset.php to extract the artist from the song itself
and if found it will override any artist specified in the .lst file.

Songs/Bob.lst
web/displayset.php
web/songbook.php

index c2534a8..50c8461 100644 (file)
@@ -6,5 +6,5 @@ Blackbird
 California Dreamin'
 Can't Find My Way Home
 Casey Jones
-Doctir My Eyes
-For What It's  Worth
\ No newline at end of file
+Doctor My Eyes
+For What It's Worth
\ No newline at end of file
index dbce735..704f405 100644 (file)
@@ -11,7 +11,7 @@
 
 <?php
 include_once "songbook.php";
-$set = $_REQUEST ["set"];
+$set = $_REQUEST["set"];
 ?>
 
 <style>
@@ -44,29 +44,33 @@ foreach (file("$songDir/$set") as $line) {
     continue;
   } // if
 
-  if (preg_match ("/(.*)\s+-\s+(.*)/", $line, $matches)) {
-    $song   = trim ($matches[1]);
-    $artist = trim ($matches[2]);
+  if (preg_match("/(.*)\s+-\s+(.*)/", $line, $matches)) {
+    $song   = trim($matches[1]);
+    $artist = trim($matches[2]);
   } else {
-    $song   = trim ($line);
-    $artist = "";
+    $song   = trim($line);
+    $artist = '';
   } // if
 
   if (file_exists ("$songDir/$song.pro")) {
     print "<li><a href=\"webchord.cgi?chordpro=$song.pro\">";
-    print basename ($song);
+    print basename($song);
     print "</a>";
   } else {
     print "<li>";
-    print basename ($song);
-  }
+    print basename($song);
+  } // if
 
-  print " - ";
+  $artist = getArtist ("$songDir/$song.pro"); 
 
-  if (in_array ($artist, $artists)) {
-    print "<a href=\"displayartist.php?artist=$artist\">$artist</a>";
-  } else {
-    print $artist;
+  if ($artist != '') {
+    print " - ";
+
+    if (in_array ($artist, $artists)) {
+      print "<a href=\"displayartist.php?artist=$artist\">$artist</a>";
+    } else {
+       print $artist;
+    } // if
   } // if
 
   print "</li>";
index 113af43..26917b9 100644 (file)
@@ -1,7 +1,10 @@
 <?php
 $baseDir = getcwd();
 $songDir = "/opt/songbook/Songs";
-$debug   = $_REQUEST["debug"];
+
+if (isset ($_REQUEST['debug'])) {
+  $debug = $_REQUEST['debug'];
+} // if
 
 // Initialize music objects
 $songs   = getSongs($songDir);
@@ -86,7 +89,7 @@ function setsDropdown () {
 } // 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]);