diff ca/index.php @ 19:84a412b8122c

try to protect against a range of missing info
author Charlie Root
date Thu, 30 Aug 2018 17:18:12 -0400
parents 077b0a0a3e6d
children a67bf725e87b
line wrap: on
line diff
--- a/ca/index.php	Sun Jul 30 05:34:46 2017 -0400
+++ b/ca/index.php	Thu Aug 30 17:18:12 2018 -0400
@@ -60,7 +60,7 @@
 	{
 	echo "<head>";
 	echo "<meta name=\"fragment\" content=\"!\">";
-	
+	echo "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />";
     echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">";
 	echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"../Books.css\">";
 	
@@ -140,8 +140,25 @@
 				{
 					$bookDetails = getAmazonDet($isbn,1,'ca'); 
 					$bookXML = new SimpleXMLElement($bookDetails);
-					$title = $bookXML->Items->Item[0]->ItemAttributes->Title;
-					$author = $bookXML->Items->Item[0]->ItemAttributes->Author;
+					if ($bookXML->Items && $bookXML->Items->Item[0] &&
+					    $bookXML->Items->Item[0]->ItemAttributes)
+					  { $attrs=$bookXML->Items->Item[0]->ItemAttributes;
+					    if ($attrs->Title) {
+					      $title = $attrs->Title; }
+					    else {
+					      $title ="[no Title]";
+					    }
+					    if ($attrs->Author) {
+					      $author = $attrs->Author;
+					    }
+					    else {
+					      $author ="[no Author]";
+					    }
+					  }
+					else {
+					  $title ="[no Title]";
+					  $author = "[no Author]";
+					}
 				}
 
 				$linkedBooks = include "../php/read/getLinkedBooks.php"; 
@@ -166,8 +183,21 @@
 					{					
 						$bookLDetails = getAmazonDet($linkedISBN,1,'ca'); 
 						$bookLXML = new SimpleXMLElement($bookLDetails);
-						$titleL = $bookLXML->Items->Item[0]->ItemAttributes->Title;
-						$authorL = $bookLXML->Items->Item[0]->ItemAttributes->Author;
+						if ($bookLXML->Items &&
+						    $bookLXML->Items->Item[0] &&
+						    $bookLXML->Items->Item[0]->ItemAttributes) {
+						  $attrs=$bookLXML->Items->Item[0]->ItemAttributes;
+						  if ($attrs->Title) {
+						    $titleL = $attrs->Title; }
+						  else {
+						    $titleL = ""; }
+						  if ($attrs->Author) {
+						    $authorL = $attrs->Author; }
+						  else {
+						    $authorL = ""; }
+						}
+						else {
+						  $titleL = ""; }
 					}
 					if($titleL != "")
 					{
@@ -204,6 +234,7 @@
 					echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../raphael-min.js\"></script>";
 					echo $launchScript;//"<script type=\"text/javascript\" language=\"javascript\" src=\"../books/books.nocache.js\"></script>";
 				}
+				
 				echo "</head>";
 				
 				echo "<body>";				
@@ -222,7 +253,7 @@
 				catch(Exception $e)
 				{
 				  echo 'Message: ' .$e->getMessage();
-				}	
+				}
 			}
 		}
 		else
@@ -252,6 +283,7 @@
 				echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../raphael-min.js\"></script>";
 				echo $launchScript;//"<script type=\"text/javascript\" language=\"javascript\" src=\"../books/books.nocache.js\"></script>";
 			}
+			
 			echo "</head>";
 
 			echo "<body>";
@@ -271,7 +303,7 @@
 			FB.Canvas.setSize(obj);
 			</script>";
 		}
-	}
+	}	
 	?>
   
     <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>