# HG changeset patch # User Charlie Root # Date 1535663892 14400 # Node ID 84a412b8122c1dadb1305dbae4ac15e71f2d8f00 # Parent c41a5802b26cf972c41d301431d3d00571ee2d4d try to protect against a range of missing info diff -r c41a5802b26c -r 84a412b8122c ca/index.php --- 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 "
"; echo ""; - + echo ""; echo ""; echo ""; @@ -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 ""; echo $launchScript;//""; } + echo ""; echo ""; @@ -222,7 +253,7 @@ catch(Exception $e) { echo 'Message: ' .$e->getMessage(); - } + } } } else @@ -252,6 +283,7 @@ echo ""; echo $launchScript;//""; } + echo ""; echo ""; @@ -271,7 +303,7 @@ FB.Canvas.setSize(obj); "; } - } + } ?> diff -r c41a5802b26c -r 84a412b8122c de/index.php --- a/de/index.php Sun Jul 30 05:34:46 2017 -0400 +++ b/de/index.php Thu Aug 30 17:18:12 2018 -0400 @@ -124,7 +124,7 @@ $ret = 1; $countryCode = 3; - include "../../private/db.php"; + include "../../private/db.php"; $query = "CALL b_getBookInfo('$isbn', $countryCode)"; //echo $query; $res = mysqli_query($link, $query) or exit( mysqli_error( $link )); @@ -138,10 +138,27 @@ } else { - $bookDetails = getAmazonDet($isbn,1,'ca'); + $bookDetails = getAmazonDet($isbn,1,'de'); $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,'de'); $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 != "") { @@ -273,7 +303,7 @@ FB.Canvas.setSize(obj); "; } - } + } ?> diff -r c41a5802b26c -r 84a412b8122c fr/index.php --- a/fr/index.php Sun Jul 30 05:34:46 2017 -0400 +++ b/fr/index.php Thu Aug 30 17:18:12 2018 -0400 @@ -117,7 +117,7 @@ } else { - try{ + try{ $isbn = substr($isbn, 5); $chars = explode("/",$isbn); $isbn = $chars[0]; @@ -140,8 +140,25 @@ { $bookDetails = getAmazonDet($isbn,1,'fr'); $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,'fr'); $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 != "") { @@ -245,13 +275,13 @@ "; if($iPhone && !$iPad) { - echo ""; - echo ""; + echo ""; + echo ""; } else { - echo ""; - echo $launchScript;//""; + echo ""; + echo $launchScript;//""; } echo ""; @@ -273,7 +303,7 @@ FB.Canvas.setSize(obj); "; } - } + } ?> diff -r c41a5802b26c -r 84a412b8122c index.php --- a/index.php Sun Jul 30 05:34:46 2017 -0400 +++ b/index.php Thu Aug 30 17:18:12 2018 -0400 @@ -35,5 +35,6 @@ + diff -r c41a5802b26c -r 84a412b8122c php/read/updateLink.php --- a/php/read/updateLink.php Sun Jul 30 05:34:46 2017 -0400 +++ b/php/read/updateLink.php Thu Aug 30 17:18:12 2018 -0400 @@ -6,6 +6,7 @@ echo $change; $dir = strval($_GET['dir']); echo $dir; +$userID=""; $userID = strval($_GET['userID']); echo $userID; diff -r c41a5802b26c -r 84a412b8122c uk/index.php --- a/uk/index.php Sun Jul 30 05:34:46 2017 -0400 +++ b/uk/index.php Thu Aug 30 17:18:12 2018 -0400 @@ -140,8 +140,25 @@ { $bookDetails = getAmazonDet($isbn,1,'uk'); $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,'uk'); $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 != "") { diff -r c41a5802b26c -r 84a412b8122c us/index.php --- a/us/index.php Sun Jul 30 05:34:46 2017 -0400 +++ b/us/index.php Thu Aug 30 17:18:12 2018 -0400 @@ -151,16 +151,41 @@ // principled solution in place } $title = ""; + $author = ""; } else { - $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"; + $linkedBooks = include "../php/read/getLinkedBooks.php"; + try { $xml = new SimpleXMLElement($linkedBooks); - + } + catch (Exception $e) { + file_put_contents('/var/ywww/debug/phpDebug', + "Bad XML?: ".$linkedBooks, + FILE_APPEND); + throw $e; + } $recommended = ""; $linkedRecommended = ""; for($i=0;$i