view ca/bkp_index.php @ 51:e6976d92cfc9

refactor 503
author Charlie Root
date Thu, 06 Jun 2019 16:32:56 -0400
parents 077b0a0a3e6d
children
line wrap: on
line source

<!DOCTYPE html>

<html>
  <?PHP
  
	function uniqueRand($n, $min = 0, $max = null)
	{
		if($max === null)
			$max = getrandmax();
		$array = range($min, $max);
		$return = array();
		$keys = array_rand($array, $n);
		foreach($keys as $key)
			$return[] = $array[$key];
		return $return;
	}
  
  	//include "../mdetect.php";
	//$uagent_obj = new uagent_info();
	//$iPhone = $uagent_obj->DetectSmartphone();
	//$iPad = $uagent_obj->DetectIpad();
  
	echo "<head>";
	echo "<meta name=\"fragment\" content=\"!\">";
    echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">";
	echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"../Books.css\">";
	
		if(isset($_GET['_escaped_fragment_'])) {
			$isbn = $_GET['_escaped_fragment_'];			
			if($isbn == ""){
				echo "<META NAME=\"Description\" CONTENT=\"Discover and share your next book at YourNextRead. YourNextRead makes book discovery and recommendation simple. Great for both bookworms and casual readers!\">";

				echo "<title>YourNextRead: Book Recommendations (Canada)</title>";
				echo "<div id=\"script\"></div><noscript>
				<p>You need to have Javascript enabled to use YourNextRead - Sorry!<p>
				<p>Please see instructions on how to switch this on, depending on which browser you use:<p>
				<ul>
				<li><a href=\"http://www.ehow.com/how_2033406_enable-javascript-firefox.html\">Firefox</a></li>
				<li><a href=\"http://www.chromefans.org/chrome-tutorial/how-to-enable-or-disable-javascript-in-google-chrome.htm\">Chrome</a></li>
				<li><a href=\"http://support.microsoft.com/gp/howtoscript\">Internet Explorer</a></li>
				</ul>
				<p>Thank you for using YourNextRead<p>
				<img src=\"http://www.yournextread.com/images/topleft.gif\" alt=\"YourNextRead\"/>
				</noscript>";
				//if($iPhone)
				//	echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksMob/books.nocache.js\"></script>";
				//else
					echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../books/books.nocache.js\"></script>";
				echo "</head>";
				echo "<body>";
				//we are at the launch page
				echo "<p>Get started, search for a book you like... or choose from one of the lists below:</p><BR></BR>";
				
				$ret = 1;													
								
				$bookLists = include "../php/read/getAllSavedBooks.php"; 			
				$xml = new SimpleXMLElement($bookLists);
				
				$numOfLists = sizeof($xml->List) - 1;	//-1 for zero indexing 
					
				$randomFourLists = uniqueRand(4,0,$numOfLists);				
				
				foreach ($randomFourLists as $id) {
					$ListName = $xml->List[$id]->SavedListName;
					echo "<p><b>$ListName</b></p><BR></BR>";
					for($i=0;$i<sizeof($xml->List[$id]->ListDetails->Book);$i++){
						$bookTitle = $xml->List[$id]->ListDetails->Book[$i]->BookTitle;
						$isbn = $xml->List[$id]->ListDetails->Book[$i]->ISBN;
						echo "<a href=http://www.YourNextRead.com/ca/#!isbn=$isbn>$bookTitle</a> ";
					}
				}		
			}
			else
			{
				$isbn = substr($isbn, 5); 
				$ret = 1;
				$countryCode = 2;
				
				$linkedBooks = include "../php/read/getLinkedBooks.php"; 
				
				$xml = new SimpleXMLElement($linkedBooks);
		
				include "../xml/getAmazonInfo.php";
				$bookDetails = getAmazonDet($isbn,1,'ca');
				$bookXML = new SimpleXMLElement($bookDetails);
				
				$title = $bookXML->Items->Item[0]->ItemAttributes->Title;
				$author = $bookXML->Items->Item[0]->ItemAttributes->Author;

				$amazonReview = $bookXML->Items->Item[0]->EditorialReviews[0]->EditorialReview->Content;
				$amazonRating = $bookXML->Items->Item[0]->CustomerReviews[0]->AverageRating;

				$recommended = "";
				$linkedRecommended = "";
				for($i=0;$i<sizeof($xml->isbn);$i++){
					$linkedISBN = $xml->isbn[$i];
					$bookLDetails = getAmazonDet($linkedISBN,1,'ca'); 
					$bookLXML = new SimpleXMLElement($bookLDetails);
					$titleL = $bookLXML->Items->Item[0]->ItemAttributes->Title;
					$authorL = $bookLXML->Items->Item[0]->ItemAttributes->Author;
					if($titleL != "")
					{
						$recommended .= " $titleL by $authorL,";
						$linkedRecommended .= "<a href=\"http://www.YourNextRead.com/ca/#!isbn=$linkedISBN\">$titleL by $authorL</a>, ";		
					}					
				}
				
				$vote = "Vote on these recommendations!";
				
				echo "<META NAME=\"Description\" CONTENT=\"YourNextRead recommended books for $title by $author:$recommended $vote\">";

				echo "<title>YourNextRead (Canada) Recommended Books for $title by $author</title>";
				echo "<div id=\"script\"></div><noscript>
				<p>You need to have Javascript enabled to use YourNextRead - Sorry!<p>
				<p>Please see instructions on how to switch this on, depending on which browser you use:<p>
				<ul>
				<li><a href=\"http://www.ehow.com/how_2033406_enable-javascript-firefox.html\">Firefox</a></li>
				<li><a href=\"http://www.chromefans.org/chrome-tutorial/how-to-enable-or-disable-javascript-in-google-chrome.htm\">Chrome</a></li>
				<li><a href=\"http://support.microsoft.com/gp/howtoscript\">Internet Explorer</a></li>
				</ul>
				<p>Thank you for using YourNextRead<p>
				<img src=\"http://www.yournextread.com/images/topleft.gif\" alt=\"YourNextRead\"/>
				</noscript>";
				//if($iPhone)
				//	echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksMob/books.nocache.js\"></script>";
				//else
					echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../books/books.nocache.js\"></script>";
				
				echo "</head>";
				
				echo "<body>";				
				echo "<p>Recommended Books for <b>$title</b> by <b>$author</b>:";
				echo $linkedRecommended;
				echo $vote;
				
				echo "<BR></BR><b>Amazon Review</b>: $amazonReview";
				echo "<BR></BR><b>Amazon AvgRating</b>: $amazonRating";
				
				echo "<BR></BR><b>Customer Reviews</b>: ";
				
				for($i=0;$i<sizeof($bookXML->Items->Item[0]->CustomerReviews[0]->Review);$i++){
					$customerReview = $bookXML->Items->Item[0]->CustomerReviews[0]->Review[$i]->Content;
					echo "<BR></BR><b>Customer Review $i</b>:<BR></BR>$customerReview";
				}	
				echo "</p>";
				
				echo "Change to <a href=\"http://www.YourNextRead.com/fr/#!isbn=$linkedISBN\">YourNextRead France</a>, ";
				echo "Change to <a href=\"http://www.YourNextRead.com/de/#!isbn=$linkedISBN\">YourNextRead Germany</a>, ";
				echo "Change to <a href=\"http://www.YourNextRead.com/uk/#!isbn=$linkedISBN\">YourNextRead UK</a>, ";				
				echo "Change to <a href=\"http://www.YourNextRead.com/us/#!isbn=$linkedISBN\">YourNextRead USA</a>";
			}
		}
		else
		{
			echo "<META NAME=\"Description\" CONTENT=\"YourNextRead recommends your next book. YourNextRead provides a book recommendation system showing aggregated book reviews, updated by real peoples opinions, in a simple visual map, helping you to decide 'What Should I Read Next?'. Perfect for both bookworms and casual readers!\">";

			echo "<title>YourNextRead: Book Recommendations (Canada)</title>";
			//the title will get changed dynamically in the GWT code
			echo "<div id=\"script\"></div><noscript>
			<p>You need to have Javascript enabled to use YourNextRead - Sorry!<p>
			<p>Please see instructions on how to switch this on, depending on which browser you use:<p>
			<ul>
			<li><a href=\"http://www.ehow.com/how_2033406_enable-javascript-firefox.html\">Firefox</a></li>
			<li><a href=\"http://www.chromefans.org/chrome-tutorial/how-to-enable-or-disable-javascript-in-google-chrome.htm\">Chrome</a></li>
			<li><a href=\"http://support.microsoft.com/gp/howtoscript\">Internet Explorer</a></li>
			</ul>
			<p>Thank you for using YourNextRead<p>
			<img src=\"http://www.yournextread.com/images/topleft.gif\" alt=\"YourNextRead\"/>
			</noscript>";
			//if($iPhone)
			//	echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksMob/books.nocache.js\"></script>";
			//else
				echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../books/books.nocache.js\"></script>";
			
			echo "</head>";

			echo "<body>";
		}
	?>
  
    <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
	
	<script type="text/javascript">
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
	</script>
	<script type="text/javascript">
	try {
	var pageTracker = _gat._getTracker("UA-15026249-1");
	pageTracker._setDomainName("none");
	pageTracker._setAllowLinker(true);
	pageTracker._trackPageview();
	} catch(err) {}</script>
  </body>
</html>