diff php/read/getLinkedBooks.php @ 6:077b0a0a3e6d

remaining originals according to dependency walk
author Robert Boland <robert@markup.co.uk>
date Thu, 16 Feb 2017 22:29:02 +0000
parents
children 385ddd7c4b55 b7376319d25a
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/php/read/getLinkedBooks.php	Thu Feb 16 22:29:02 2017 +0000
@@ -0,0 +1,80 @@
+<?PHP
+if(!isset($ret))
+{
+header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
+header("Cache-Control: no-store, no-cache, must-revalidate");
+header("Cache-Control: post-check=0, pre-check=0", false);
+header("Pragma: no-cache");
+}
+$linkedBooks = 0;
+include "similar.php"; 
+
+//$isbn = $_GET['isbn'];
+
+if(isset($_GET['isbn'])){
+	$isbn = $_GET['isbn'];
+}
+
+if(isset($_GET['loc'])){
+	$loc = $_GET['loc'];
+}
+else{
+	$loc = 1;	//default location is 1
+} 
+
+if(isset($ret))
+{
+	include "../../private/db.php"; 
+	$loc = $countryCode; //passed from index.php when googlebot is crawling
+}
+else
+{
+	include "../../../private/db.php";
+	$ret = 0;
+}	
+
+$query = "CALL b_getLinksForISBN('$isbn',$loc)";
+//echo $query;
+$results = mysqli_query($link, $query) or exit( mysqli_error( $link ));
+
+$output = "<?xml version=\"1.0\"?>";
+$output .= "<results>";
+
+while($line = mysqli_fetch_assoc($results)) {
+
+	$linkID = $line["LinkID"];
+	$lISBN=trim($line["LinkedISBN"]);
+	$lID = trim($line["LinkID"]);
+	if($lISBN != "" && $lID != "")
+	{
+		$output .=  "<type>0</type>";
+		$output .=  "<isbn>" . $lISBN . "</isbn>";
+		$output .=  "<linkID>" . $lID . "</linkID>";
+		/*$output .=  "<pos>" . $pos . "</pos>";
+		$output .=  "<search>" . $search . "</search>";*/
+		$linkedBooks++;
+	}
+	/*else{		//this should never happen-> if there is a link, there must be a link ID and also an ISBN to link to
+		echo "**ERROR**"
+		echo "LinkedISBN=$lISBN";		//uncomment this to help debug if this ever happens.
+		echo "LinkID=$lID";
+	}*/
+}
+
+if( $linkedBooks < 8 )
+{
+$amazonBooks=addAmazonSimilarBooks($isbn,$loc,$ret);  
+$output .=  $amazonBooks;
+}
+
+$output .=  "</results>";
+
+if($ret==1)
+	return $output;
+else
+	echo $output;
+
+mysqli_close($link);
+
+?>
\ No newline at end of file