comparison us/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 226f00d9f6f5
children d606320ec331
comparison
equal deleted inserted replaced
18:c41a5802b26c 19:84a412b8122c
149 if ($code=='RequestThrottled') { 149 if ($code=='RequestThrottled') {
150 usleep(200000); // Try to reduce throttling until we get a 150 usleep(200000); // Try to reduce throttling until we get a
151 // principled solution in place 151 // principled solution in place
152 } 152 }
153 $title = ""; 153 $title = "";
154 $author = "";
154 } 155 }
155 else { 156 else {
156 $title = $bookXML->Items->Item[0]->ItemAttributes->Title; 157 if ($bookXML->Items && $bookXML->Items->Item[0] &&
157 $author = $bookXML->Items->Item[0]->ItemAttributes->Author; 158 $bookXML->Items->Item[0]->ItemAttributes)
158 } 159 { $attrs=$bookXML->Items->Item[0]->ItemAttributes;
159 } 160 if ($attrs->Title) {
160 161 $title = $attrs->Title; }
161 $linkedBooks = include "../php/read/getLinkedBooks.php"; 162 else {
163 $title ="[no Title]";
164 }
165 if ($attrs->Author) {
166 $author = $attrs->Author;
167 }
168 else {
169 $author ="[no Author]";
170 }
171 }
172 else {
173 $title ="[no Title]";
174 $author = "[no Author]";
175 }
176 }
177 }
178
179 $linkedBooks = include "../php/read/getLinkedBooks.php";
180 try {
162 $xml = new SimpleXMLElement($linkedBooks); 181 $xml = new SimpleXMLElement($linkedBooks);
163 182 }
183 catch (Exception $e) {
184 file_put_contents('/var/ywww/debug/phpDebug',
185 "Bad XML?: ".$linkedBooks,
186 FILE_APPEND);
187 throw $e;
188 }
164 $recommended = ""; 189 $recommended = "";
165 $linkedRecommended = ""; 190 $linkedRecommended = "";
166 for($i=0;$i<sizeof($xml->isbn);$i++){ 191 for($i=0;$i<sizeof($xml->isbn);$i++){
167 $linkedISBN = $xml->isbn[$i]; 192 $linkedISBN = $xml->isbn[$i];
168 include "../../private/db.php"; 193 include "../../private/db.php";
200 // principled solution in place 225 // principled solution in place
201 } 226 }
202 $titleL = ""; 227 $titleL = "";
203 } 228 }
204 else { 229 else {
205 $titleL = $bookLXML->Items->Item[0]->ItemAttributes->Title; 230 if ($bookLXML->Items &&
206 $authorL = $bookLXML->Items->Item[0]->ItemAttributes->Author; 231 $bookLXML->Items->Item[0] &&
232 $bookLXML->Items->Item[0]->ItemAttributes) {
233 $attrs=$bookLXML->Items->Item[0]->ItemAttributes;
234 if ($attrs->Title) {
235 $titleL = $attrs->Title; }
236 else {
237 $titleL = ""; }
238 if ($attrs->Author) {
239 $authorL = $attrs->Author; }
240 else {
241 $authorL = ""; }
242 }
243 else {
244 $titleL = ""; }
207 } 245 }
208 } 246 }
209 restore_error_handler(); 247 restore_error_handler();
210 if($titleL != "") 248 if($titleL != "")
211 { 249 {
325 var pageTracker = _gat._getTracker("UA-15026249-1"); 363 var pageTracker = _gat._getTracker("UA-15026249-1");
326 pageTracker._setDomainName("none"); 364 pageTracker._setDomainName("none");
327 pageTracker._setAllowLinker(true); 365 pageTracker._setAllowLinker(true);
328 pageTracker._trackPageview(); 366 pageTracker._trackPageview();
329 } catch(err) {}</script> 367 } catch(err) {}</script>
330 </body> 368 <script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=322bafc0-69fa-4664-8e1c-0b9159259748"></script>
369 </body>
331 </html> 370 </html>