Mercurial > hg > ywww
comparison 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 |
comparison
equal
deleted
inserted
replaced
41:0578c6e438d3 | 42:3f400072bf14 |
---|---|
131 include "../xml/aws_signed_request.php"; | 131 include "../xml/aws_signed_request.php"; |
132 include "../xml/getAmazonInfo.php"; | 132 include "../xml/getAmazonInfo.php"; |
133 if ( mysqli_num_rows( $res ) > 0 ) | 133 if ( mysqli_num_rows( $res ) > 0 ) |
134 { | 134 { |
135 $rows=mysqli_fetch_array($res, MYSQLI_ASSOC); | 135 $rows=mysqli_fetch_array($res, MYSQLI_ASSOC); |
136 mysqli_close($link); | |
136 $title = $rows["Title"]; | 137 $title = $rows["Title"]; |
137 $author = $rows["Author"]; | 138 $author = $rows["Author"]; |
138 } | 139 } |
139 else | 140 else |
140 { | 141 { |
142 mysqli_close($link); | |
141 $bookDetails = getAmazonDet($isbn,1,'us'); | 143 $bookDetails = getAmazonDet($isbn,1,'us'); |
142 $bookXML = new SimpleXMLElement($bookDetails); | 144 $bookXML = new SimpleXMLElement($bookDetails); |
143 // HST added this | 145 // HST added this |
144 if (preg_match("<Error>",$bookDetails)) { | 146 if (preg_match("/<Error>/",$bookDetails)) { |
145 $resName=$bookXML->getName(); | 147 $resName=$bookXML->getName(); |
146 $code=$bookXML->Error->Code; | 148 $code=$bookXML->Error->Code; |
147 file_put_contents('/var/ywww/debug/phpDebug',"Losing 3: $resName, ". | 149 file_put_contents('/var/ywww/debug/phpDebug',"Losing 3: $resName, ". |
148 $code."\n",FILE_APPEND); | 150 $code."\n",FILE_APPEND); |
149 if ($code=='RequestThrottled') { | 151 if ($code=='RequestThrottled') { |
150 usleep(200000); // Try to reduce throttling until we get a | 152 usleep(200000); // Try to reduce throttling until we get a |
151 // principled solution in place | 153 // principled solution in place |
152 } | 154 } |
153 $title = ""; | 155 $title = ""; |
156 $author = ""; | |
154 } | 157 } |
155 else { | 158 else { |
156 $title = $bookXML->Items->Item[0]->ItemAttributes->Title; | 159 if ($bookXML->Items && $bookXML->Items->Item[0] && |
157 $author = $bookXML->Items->Item[0]->ItemAttributes->Author; | 160 $bookXML->Items->Item[0]->ItemAttributes) |
158 } | 161 { $attrs=$bookXML->Items->Item[0]->ItemAttributes; |
159 } | 162 if ($attrs->Title) { |
160 | 163 $title = $attrs->Title; } |
161 $linkedBooks = include "../php/read/getLinkedBooks.php"; | 164 else { |
165 $title ="[no Title]"; | |
166 } | |
167 if ($attrs->Author) { | |
168 $author = $attrs->Author; | |
169 } | |
170 else { | |
171 $author ="[no Author]"; | |
172 } | |
173 } | |
174 else { | |
175 $title ="[no Title]"; | |
176 $author = "[no Author]"; | |
177 } | |
178 } | |
179 } | |
180 | |
181 $linkedBooks = include "../php/read/getLinkedBooks.php"; | |
182 try { | |
162 $xml = new SimpleXMLElement($linkedBooks); | 183 $xml = new SimpleXMLElement($linkedBooks); |
163 | 184 } |
185 catch (Exception $e) { | |
186 file_put_contents('/var/ywww/debug/phpDebug', | |
187 "Bad XML?: ".$linkedBooks, | |
188 FILE_APPEND); | |
189 throw $e; | |
190 } | |
164 $recommended = ""; | 191 $recommended = ""; |
165 $linkedRecommended = ""; | 192 $linkedRecommended = ""; |
166 for($i=0;$i<sizeof($xml->isbn);$i++){ | 193 for($i=0;$i<sizeof($xml->isbn);$i++){ |
167 $linkedISBN = $xml->isbn[$i]; | 194 $linkedISBN = $xml->isbn[$i]; |
168 include "../../private/db.php"; | 195 include "../../private/db.php"; |
179 // FILE_APPEND); | 206 // FILE_APPEND); |
180 } ); | 207 } ); |
181 if ( mysqli_num_rows( $res ) > 0 ) | 208 if ( mysqli_num_rows( $res ) > 0 ) |
182 { | 209 { |
183 $rows=mysqli_fetch_array($res, MYSQLI_ASSOC); | 210 $rows=mysqli_fetch_array($res, MYSQLI_ASSOC); |
211 mysqli_close($link); | |
184 $titleL = $rows["Title"]; | 212 $titleL = $rows["Title"]; |
185 $authorL = $rows["Author"]; | 213 $authorL = $rows["Author"]; |
186 mysqli_close($link); | |
187 } | 214 } |
188 else | 215 else |
189 { | 216 { |
217 mysqli_close($link); | |
190 $bookLDetails = getAmazonDet($linkedISBN,1,'us'); | 218 $bookLDetails = getAmazonDet($linkedISBN,1,'us'); |
191 $bookLXML = new SimpleXMLElement($bookLDetails); | 219 $bookLXML = new SimpleXMLElement($bookLDetails); |
192 // HST added this | 220 // HST added this |
193 if (preg_match("<Error>",$bookLDetails)) { | 221 if (preg_match("/<Error>/",$bookLDetails)) { |
194 $resName=$bookLXML->getName(); | 222 $resName=$bookLXML->getName(); |
195 $code=$bookLXML->Error->Code; | 223 $code=$bookLXML->Error->Code; |
196 file_put_contents('/var/ywww/debug/phpDebug',"Losing 2: $resName, ". | 224 file_put_contents('/var/ywww/debug/phpDebug',"Losing 2: $resName, ". |
197 $code."\n",FILE_APPEND); | 225 $code."\n",FILE_APPEND); |
198 if ($code=='RequestThrottled') { | 226 if ($code=='RequestThrottled') { |
200 // principled solution in place | 228 // principled solution in place |
201 } | 229 } |
202 $titleL = ""; | 230 $titleL = ""; |
203 } | 231 } |
204 else { | 232 else { |
205 $titleL = $bookLXML->Items->Item[0]->ItemAttributes->Title; | 233 if ($bookLXML->Items && |
206 $authorL = $bookLXML->Items->Item[0]->ItemAttributes->Author; | 234 $bookLXML->Items->Item[0] && |
235 $bookLXML->Items->Item[0]->ItemAttributes) { | |
236 $attrs=$bookLXML->Items->Item[0]->ItemAttributes; | |
237 if ($attrs->Title) { | |
238 $titleL = $attrs->Title; } | |
239 else { | |
240 $titleL = ""; } | |
241 if ($attrs->Author) { | |
242 $authorL = $attrs->Author; } | |
243 else { | |
244 $authorL = ""; } | |
245 } | |
246 else { | |
247 $titleL = ""; } | |
207 } | 248 } |
208 } | 249 } |
209 restore_error_handler(); | 250 restore_error_handler(); |
210 if($titleL != "") | 251 if($titleL != "") |
211 { | 252 { |
325 var pageTracker = _gat._getTracker("UA-15026249-1"); | 366 var pageTracker = _gat._getTracker("UA-15026249-1"); |
326 pageTracker._setDomainName("none"); | 367 pageTracker._setDomainName("none"); |
327 pageTracker._setAllowLinker(true); | 368 pageTracker._setAllowLinker(true); |
328 pageTracker._trackPageview(); | 369 pageTracker._trackPageview(); |
329 } catch(err) {}</script> | 370 } catch(err) {}</script> |
330 </body> | 371 <script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&adInstanceId=322bafc0-69fa-4664-8e1c-0b9159259748"></script> |
372 </body> | |
331 </html> | 373 </html> |