diff php/read/getBookDetails.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 c24ae74bf6d5
children 38d209611508
line wrap: on
line diff
--- a/php/read/getBookDetails.php	Sat Jan 05 06:21:12 2019 -0500
+++ b/php/read/getBookDetails.php	Sat Jan 05 18:00:10 2019 -0500
@@ -1,5 +1,7 @@
 <?php
+include_once "dlog.php";
 
+include_once "web.php";
 function findGenre($browseNode, &$ID, &$gen)
 {
 	if($browseNode->Name == "Subjects")
@@ -23,7 +25,7 @@
 	}
 }
 
-global $out,$isbn;
+global $out,$isbn,$Aserver,$Aassociates_id;
 if(isset($_GET['isbn'])){
 	$isbn = $_GET['isbn'];
 	if(isset($_GET['locale'])){
@@ -106,9 +108,7 @@
 	  {
 	    include "aws_signed_request.php";
 	    include_once "../../xml/doAmazonRequest.inc";
-	    file_put_contents('/var/ywww/debug/phpDebug',
-			      "nbd proceeding: $isbn\n",
-			      FILE_APPEND);
+	    dl("nbd proceeding: $isbn\n");
 
 	    //book does not exist already so look up all the info from browse nodes....
 
@@ -128,46 +128,6 @@
 			    );
 	    //change the debug options to true if you want to activate them or call the script with '?show_array=true' to see what actual information you're getting from Amazon and how little my standard script is actually showing of it
 
-	    $Aassociates_id=array(
-				  'uk' => 'bookwhack-21',
-				  'us' => 'your02b-20',
-				  'ca' => 'book009-20',
-				  'de' => 'book04c-21',
-				  'fr' => 'book07f-21',
-				  );
-
-	    $Aserver=array(
-			   'ca' => array(
-					 'ext' => 'ca'                      ,  //Canadian normal server
-					 'nor' => 'http://www.amazon.ca'    ,  //Canadian normal server
-					 'xml' => 'http://xml.amazon.com'   ,  //Canadian xml server
-					 ),
-			   'de' => array(
-					 'ext' => 'de'                      ,  //German normal server
-					 'nor' => 'http://www.amazon.de'    ,  //German normal server
-					 'xml' => 'http://xml-eu.amazon.com',  //German xml server
-					 ),
-			   'fr' => array(
-					 'ext' => 'fr'                      ,  //French normal server
-					 'nor' => 'http://www.amazon.fr'    ,  //French normal server
-					 'xml' => 'http://xml-eu.amazon.com',  //French xml server
-					 ),
-			   'jp' => array(
-					 'ext' => 'jp'                      ,  //Japanese normal server, not co.jp!
-					 'nor' => 'http://www.amazon.co.jp' ,  //Japanese normal server
-					 'xml' => 'http://xml.amazon.com'   ,  //Japanese xml server
-					 ),
-			   'uk' => array(
-					 'ext' => 'co.uk'                   ,  //UK normal server
-					 'nor' => 'http://www.amazon.co.uk' ,  //UK normal server
-					 'xml' => 'http://xml-eu.amazon.com',  //UK xml server
-					 ),
-			   'us' => array(
-					 'ext' => 'com'                     ,  //USA normal server
-					 'nor' => 'http://www.amazon.com'   ,  //USA normal server
-					 'xml' => 'http://xml.amazon.com'   ,  //USA xml server
-					 ),
-			   );
 
 	    //for all parameters see if the user has overruled it or use the default
 	    foreach ($Adefault as $i=>$d) {
@@ -192,14 +152,10 @@
 	      //use this xml to pull out the necessary information and save it
 	      set_error_handler(function () {
 		  global $out,$isbn;
-		  file_put_contents('/var/ywww/debug/phpDebug',
-				    "Caught one bd: ".$isbn,
-				    FILE_APPEND);
-		  file_put_contents('/var/ywww/debug/phpDebug',
-				    print_r($out, TRUE)."\n",
-				    FILE_APPEND);
+		  dl("Caught one bd: $isbn\n");
+		  dl(print_r($out, TRUE)."\n");
 		} );
-	      include "../../../private/db.php";
+	      include "db.php";
 	
 	      $title="";
 	      $author="";
@@ -317,9 +273,7 @@
 	      if (!$res) {
 		$err=mysqli_error( $link );
 		mysqli_close($link);
-		file_put_contents('/var/ywww/debug/phpDebug',
-				  "anb failed: $err, $pubDate, $g2, $publisher, $title\n",
-				  FILE_APPEND);
+		dl("anb failed: $err, $pubDate, $g2, $publisher, $title\n");
 		exit($err);
 	      }
 	      mysqli_close($link);	//do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop		
@@ -340,9 +294,7 @@
 	      $output .=  "<ProductGroup>Book</ProductGroup>";
 	    }
 	    catch (Exception $e) {
-	      file_put_contents('/var/ywww/debug/phpDebug',
-				"gBD: dAR failed:".$e->getMessage()."\n",
-				FILE_APPEND);
+	      dl("gBD: dAR failed:".$e->getMessage()."\n");
 	    }
 	  }
 	$output .=  "</BookDetails>";