Mercurial > hg > ywww
diff us/index.php @ 42:3f400072bf14
merge, involved ediff3 wrt getAmazonInfo.php
| author | Charlie Root |
|---|---|
| date | Sat, 05 Jan 2019 06:21:12 -0500 |
| parents | b058736bc9ad |
| children | dbc006408d2b |
line wrap: on
line diff
--- a/us/index.php Sun Jul 30 05:36:48 2017 -0400 +++ b/us/index.php Sat Jan 05 06:21:12 2019 -0500 @@ -133,15 +133,17 @@ if ( mysqli_num_rows( $res ) > 0 ) { $rows=mysqli_fetch_array($res, MYSQLI_ASSOC); + mysqli_close($link); $title = $rows["Title"]; $author = $rows["Author"]; } else { + mysqli_close($link); $bookDetails = getAmazonDet($isbn,1,'us'); $bookXML = new SimpleXMLElement($bookDetails); // HST added this - if (preg_match("<Error>",$bookDetails)) { + if (preg_match("/<Error>/",$bookDetails)) { $resName=$bookXML->getName(); $code=$bookXML->Error->Code; file_put_contents('/var/ywww/debug/phpDebug',"Losing 3: $resName, ". @@ -151,16 +153,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<sizeof($xml->isbn);$i++){ @@ -181,16 +208,17 @@ if ( mysqli_num_rows( $res ) > 0 ) { $rows=mysqli_fetch_array($res, MYSQLI_ASSOC); + mysqli_close($link); $titleL = $rows["Title"]; $authorL = $rows["Author"]; - mysqli_close($link); } else { + mysqli_close($link); $bookLDetails = getAmazonDet($linkedISBN,1,'us'); $bookLXML = new SimpleXMLElement($bookLDetails); // HST added this - if (preg_match("<Error>",$bookLDetails)) { + if (preg_match("/<Error>/",$bookLDetails)) { $resName=$bookLXML->getName(); $code=$bookLXML->Error->Code; file_put_contents('/var/ywww/debug/phpDebug',"Losing 2: $resName, ". @@ -202,8 +230,21 @@ $titleL = ""; } else { - $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 = ""; } } } restore_error_handler(); @@ -327,5 +368,6 @@ pageTracker._setAllowLinker(true); pageTracker._trackPageview(); } catch(err) {}</script> - </body> + <script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=322bafc0-69fa-4664-8e1c-0b9159259748"></script> + </body> </html>
