comparison us/index.php @ 43:dbc006408d2b

ASSUMES we have SetEnv PHP_VALUE "include_path =.:/var/test/private:/var/test/ywww:/usr/share/php" in apache2/.../test.conf use dl(...) for debug logging, defined in dlog.php use doAmazonRequest in amazonBookSearch use ../private/web.php (q.v., not in mercurial) for Aserver and Aassociates Started by updating from 40:c24ae74bf6d5, i.e. just before the bug on the main line
author Charlie Root
date Sat, 05 Jan 2019 18:00:10 -0500
parents b058736bc9ad
children 38d209611508
comparison
equal deleted inserted replaced
42:3f400072bf14 43:dbc006408d2b
1 <?PHP 1 <?PHP
2 include_once "dlog.php";
2 session_start(); 3 session_start();
3 4
4 function uniqueRand($n, $min = 0, $max = null) 5 function uniqueRand($n, $min = 0, $max = null)
5 { 6 {
6 if($max === null) 7 if($max === null)
7 $max = getrandmax(); 8 $max = getrandmax();
8 $array = range($min, $max); 9 $array = range($min, $max);
77 <li><a href=\"http://www.ehow.com/how_2033406_enable-javascript-firefox.html\">Firefox</a></li> 78 <li><a href=\"http://www.ehow.com/how_2033406_enable-javascript-firefox.html\">Firefox</a></li>
78 <li><a href=\"http://www.chromefans.org/chrome-tutorial/how-to-enable-or-disable-javascript-in-google-chrome.htm\">Chrome</a></li> 79 <li><a href=\"http://www.chromefans.org/chrome-tutorial/how-to-enable-or-disable-javascript-in-google-chrome.htm\">Chrome</a></li>
79 <li><a href=\"http://support.microsoft.com/gp/howtoscript\">Internet Explorer</a></li> 80 <li><a href=\"http://support.microsoft.com/gp/howtoscript\">Internet Explorer</a></li>
80 </ul> 81 </ul>
81 <p>Thank you for using YourNextRead<p> 82 <p>Thank you for using YourNextRead<p>
82 <img src=\"http://www.yournextread.com/images/topleft.gif\" alt=\"YourNextRead\"/> 83 <img src=\"http://test.markup.co.uk/ywww/images/topleft.gif\" alt=\"YourNextRead\"/>
83 </noscript>"; 84 </noscript>";
84 if($iPhone && !$iPad) 85 if($iPhone && !$iPad)
85 { 86 {
86 echo "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />"; 87 echo "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />";
87 echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksMob/books.nocache.js\"></script>"; 88 echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksMob/books.nocache.js\"></script>";
109 $ListName = $xml->List[$id]->SavedListName; 110 $ListName = $xml->List[$id]->SavedListName;
110 echo "<p><b>$ListName</b></p><BR></BR>"; 111 echo "<p><b>$ListName</b></p><BR></BR>";
111 for($i=0;$i<sizeof($xml->List[$id]->ListDetails->Book);$i++){ 112 for($i=0;$i<sizeof($xml->List[$id]->ListDetails->Book);$i++){
112 $bookTitle = $xml->List[$id]->ListDetails->Book[$i]->BookTitle; 113 $bookTitle = $xml->List[$id]->ListDetails->Book[$i]->BookTitle;
113 $isbn = $xml->List[$id]->ListDetails->Book[$i]->ISBN; 114 $isbn = $xml->List[$id]->ListDetails->Book[$i]->ISBN;
114 echo "<a href=http://www.YourNextRead.com/us/#!isbn=$isbn>$bookTitle</a> "; 115 echo "<a href=http://test.markup.co.uk/ywww/us/#!isbn=$isbn>$bookTitle</a> ";
115 } 116 }
116 } 117 }
117 } 118 }
118 else 119 else
119 { 120 {
144 $bookXML = new SimpleXMLElement($bookDetails); 145 $bookXML = new SimpleXMLElement($bookDetails);
145 // HST added this 146 // HST added this
146 if (preg_match("/<Error>/",$bookDetails)) { 147 if (preg_match("/<Error>/",$bookDetails)) {
147 $resName=$bookXML->getName(); 148 $resName=$bookXML->getName();
148 $code=$bookXML->Error->Code; 149 $code=$bookXML->Error->Code;
149 file_put_contents('/var/ywww/debug/phpDebug',"Losing 3: $resName, ". 150 dl("Losing 3: $resName, $code\n");
150 $code."\n",FILE_APPEND);
151 if ($code=='RequestThrottled') { 151 if ($code=='RequestThrottled') {
152 usleep(200000); // Try to reduce throttling until we get a 152 usleep(200000); // Try to reduce throttling until we get a
153 // principled solution in place 153 // principled solution in place
154 } 154 }
155 $title = ""; 155 $title = "";
181 $linkedBooks = include "../php/read/getLinkedBooks.php"; 181 $linkedBooks = include "../php/read/getLinkedBooks.php";
182 try { 182 try {
183 $xml = new SimpleXMLElement($linkedBooks); 183 $xml = new SimpleXMLElement($linkedBooks);
184 } 184 }
185 catch (Exception $e) { 185 catch (Exception $e) {
186 file_put_contents('/var/ywww/debug/phpDebug', 186 dl("Bad XML?: ".$linkedBooks."\n");
187 "Bad XML?: ".$linkedBooks,
188 FILE_APPEND);
189 throw $e; 187 throw $e;
190 } 188 }
191 $recommended = ""; 189 $recommended = "";
192 $linkedRecommended = ""; 190 $linkedRecommended = "";
193 for($i=0;$i<sizeof($xml->isbn);$i++){ 191 for($i=0;$i<sizeof($xml->isbn);$i++){
196 $query = "CALL b_getBookInfo('$linkedISBN', $countryCode)"; 194 $query = "CALL b_getBookInfo('$linkedISBN', $countryCode)";
197 //echo $query; 195 //echo $query;
198 $res = mysqli_query($link, $query) or exit( mysqli_error( $link )); 196 $res = mysqli_query($link, $query) or exit( mysqli_error( $link ));
199 set_error_handler(function () { 197 set_error_handler(function () {
200 global $bookLDetails, $linkedISBN; 198 global $bookLDetails, $linkedISBN;
201 file_put_contents('/var/ywww/debug/phpDebug', 199 dl("Caught other one?: $linkedISBN\n");
202 "Caught other one?: ".$linkedISBN,
203 FILE_APPEND);
204 //file_put_contents('/var/ywww/debug/phpDebug',
205 // print_r($bookLDetails, TRUE)."\n",
206 // FILE_APPEND);
207 } ); 200 } );
208 if ( mysqli_num_rows( $res ) > 0 ) 201 if ( mysqli_num_rows( $res ) > 0 )
209 { 202 {
210 $rows=mysqli_fetch_array($res, MYSQLI_ASSOC); 203 $rows=mysqli_fetch_array($res, MYSQLI_ASSOC);
211 mysqli_close($link); 204 mysqli_close($link);
219 $bookLXML = new SimpleXMLElement($bookLDetails); 212 $bookLXML = new SimpleXMLElement($bookLDetails);
220 // HST added this 213 // HST added this
221 if (preg_match("/<Error>/",$bookLDetails)) { 214 if (preg_match("/<Error>/",$bookLDetails)) {
222 $resName=$bookLXML->getName(); 215 $resName=$bookLXML->getName();
223 $code=$bookLXML->Error->Code; 216 $code=$bookLXML->Error->Code;
224 file_put_contents('/var/ywww/debug/phpDebug',"Losing 2: $resName, ". 217 dl("Losing 2: $resName, $code\n");
225 $code."\n",FILE_APPEND);
226 if ($code=='RequestThrottled') { 218 if ($code=='RequestThrottled') {
227 usleep(200000); // Try to reduce throttling until we get a 219 usleep(200000); // Try to reduce throttling until we get a
228 // principled solution in place 220 // principled solution in place
229 } 221 }
230 $titleL = ""; 222 $titleL = "";
251 if($titleL != "") 243 if($titleL != "")
252 { 244 {
253 $recommended .= " $titleL by $authorL,"; 245 $recommended .= " $titleL by $authorL,";
254 $underAuthor = str_replace(" ","_",$authorL); 246 $underAuthor = str_replace(" ","_",$authorL);
255 $underTitle = str_replace(" ","_",$titleL); 247 $underTitle = str_replace(" ","_",$titleL);
256 $linkedRecommended .= "<a href=\"http://www.YourNextRead.com/us/#!isbn=$linkedISBN/$underTitle" . "_by_$authorL\">$titleL by $authorL</a>, "; 248 $linkedRecommended .= "<a href=\"http://test.markup.co.uk/ywww/us/#!isbn=$linkedISBN/$underTitle" . "_by_$authorL\">$titleL by $authorL</a>, ";
257 } 249 }
258 } 250 }
259 251
260 $vote = "Vote on these recommendations!"; 252 $vote = "Vote on these recommendations!";
261 253
269 <li><a href=\"http://www.ehow.com/how_2033406_enable-javascript-firefox.html\">Firefox</a></li> 261 <li><a href=\"http://www.ehow.com/how_2033406_enable-javascript-firefox.html\">Firefox</a></li>
270 <li><a href=\"http://www.chromefans.org/chrome-tutorial/how-to-enable-or-disable-javascript-in-google-chrome.htm\">Chrome</a></li> 262 <li><a href=\"http://www.chromefans.org/chrome-tutorial/how-to-enable-or-disable-javascript-in-google-chrome.htm\">Chrome</a></li>
271 <li><a href=\"http://support.microsoft.com/gp/howtoscript\">Internet Explorer</a></li> 263 <li><a href=\"http://support.microsoft.com/gp/howtoscript\">Internet Explorer</a></li>
272 </ul> 264 </ul>
273 <p>Thank you for using YourNextRead<p> 265 <p>Thank you for using YourNextRead<p>
274 <img src=\"http://www.yournextread.com/images/topleft.gif\" alt=\"YourNextRead\"/> 266 <img src=\"http://test.markup.co.uk/ywww/images/topleft.gif\" alt=\"YourNextRead\"/>
275 </noscript>"; 267 </noscript>";
276 if($iPhone && !$iPad) 268 if($iPhone && !$iPad)
277 { 269 {
278 echo "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />"; 270 echo "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />";
279 echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksMob/books.nocache.js\"></script>"; 271 echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksMob/books.nocache.js\"></script>";
289 echo "<body>"; 281 echo "<body>";
290 echo "<p>Recommended Books for <b>$title</b> by <b>$author</b>:"; 282 echo "<p>Recommended Books for <b>$title</b> by <b>$author</b>:";
291 echo $linkedRecommended . "</p>"; 283 echo $linkedRecommended . "</p>";
292 echo "<p>" . $vote . "</p>"; 284 echo "<p>" . $vote . "</p>";
293 285
294 echo "Change to <a href=\"http://www.YourNextRead.com/de/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead Germany</a>, "; 286 echo "Change to <a href=\"http://test.markup.co.uk/ywww/de/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead Germany</a>, ";
295 echo "Change to <a href=\"http://www.YourNextRead.com/ca/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead Canada</a>, "; 287 echo "Change to <a href=\"http://test.markup.co.uk/ywww/ca/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead Canada</a>, ";
296 echo "Change to <a href=\"http://www.YourNextRead.com/fr/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead France</a>, "; 288 echo "Change to <a href=\"http://test.markup.co.uk/ywww/fr/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead France</a>, ";
297 echo "Change to <a href=\"http://www.YourNextRead.com/us/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead USA</a>"; 289 echo "Change to <a href=\"http://test.markup.co.uk/ywww/us/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead USA</a>";
298 echo ", See this on <a href=\"http://www.YourNextPresent.com/us/#!isbn=$isbn\">YourNextPresent</a>, "; 290 echo ", See this on <a href=\"http://www.YourNextPresent.com/us/#!isbn=$isbn\">YourNextPresent</a>, ";
299 echo "Switch to <a href=\"http://www.YourNextFilm.com/us/\">YourNextFilm</a>, "; 291 echo "Switch to <a href=\"http://www.YourNextFilm.com/us/\">YourNextFilm</a>, ";
300 echo "Switch to <a href=\"http://www.YourNextGame.com/us/\">YourNextGame</a>"; 292 echo "Switch to <a href=\"http://www.YourNextGame.com/us/\">YourNextGame</a>";
301 } 293 }
302 catch(Exception $e) 294 catch(Exception $e)
318 <li><a href=\"http://www.ehow.com/how_2033406_enable-javascript-firefox.html\">Firefox</a></li> 310 <li><a href=\"http://www.ehow.com/how_2033406_enable-javascript-firefox.html\">Firefox</a></li>
319 <li><a href=\"http://www.chromefans.org/chrome-tutorial/how-to-enable-or-disable-javascript-in-google-chrome.htm\">Chrome</a></li> 311 <li><a href=\"http://www.chromefans.org/chrome-tutorial/how-to-enable-or-disable-javascript-in-google-chrome.htm\">Chrome</a></li>
320 <li><a href=\"http://support.microsoft.com/gp/howtoscript\">Internet Explorer</a></li> 312 <li><a href=\"http://support.microsoft.com/gp/howtoscript\">Internet Explorer</a></li>
321 </ul> 313 </ul>
322 <p>Thank you for using YourNextRead<p> 314 <p>Thank you for using YourNextRead<p>
323 <img src=\"http://www.yournextread.com/images/topleft.gif\" alt=\"YourNextRead\"/> 315 <img src=\"http://test.markup.co.uk/ywww/images/topleft.gif\" alt=\"YourNextRead\"/>
324 </noscript>"; 316 </noscript>";
325 if($iPhone && !$iPad) 317 if($iPhone && !$iPad)
326 { 318 {
327 echo "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />"; 319 echo "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />";
328 echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksMob/books.nocache.js\"></script>"; 320 echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksMob/books.nocache.js\"></script>";