# HG changeset patch
# User robert
# Date 1482928963 0
# Node ID 7a532f1e0f078ad87a639d3f964a3b717f1acc2e
# Parent 5f4560ac65b796366ee01f2f57af708f3799eb62
original
diff -r 5f4560ac65b7 -r 7a532f1e0f07 uk/index.php
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/uk/index.php Wed Dec 28 12:42:43 2016 +0000
@@ -0,0 +1,293 @@
+DetectSmartphone();
+ $iPad = $uagent_obj->DetectIpad();
+
+ $proceed = true;
+ $launchScript = "";
+
+ //print_r($_SERVER);
+ if (isset($_SERVER['HTTP_REFERER']) || isset($_GET['facebook']))
+ {
+ $pos = strpos($_SERVER['HTTP_REFERER'], "apps.facebook.com");
+ if($pos !== false || isset($_GET['facebook']))
+ {
+ //we are in facebook canvas so react appropriately
+ include_once '../facebook.php';
+
+ $facebook = new Facebook(array(
+ 'appId' => '128245333876633',
+ 'secret' => 'f51afc7e04289db62448edd8b70d83bf',
+ 'cookie' => true,
+ 'domain' => 'yournextpresent.com'
+ ));
+
+ $session = $facebook->getSession();
+
+ if (!$session) {
+ $proceed = false;
+ $url = $facebook->getLoginUrl(array(
+ 'canvas' => 1,
+ 'fbconnect' => 0,
+ 'req_perms' => 'email,user_birthday,publish_stream'
+ ));
+
+ echo "";
+ }
+ else
+ {
+ $launchScript = "";
+ }
+ }
+ }
+ echo "";
+ if($proceed)
+ {
+ echo "
";
+ echo "";
+ echo "";
+ echo "";
+ echo "";
+
+ if(isset($_GET['_escaped_fragment_'])) {
+ $isbn = $_GET['_escaped_fragment_'];
+ if($isbn == ""){
+ echo "";
+
+ echo "YourNextRead: Book Recommendations (UK)";
+ echo "";
+ if($iPhone && !$iPad)
+ {
+ echo "";
+ echo "";
+ }
+ else
+ {
+ echo "";
+ echo $launchScript;//"";
+ }
+ echo "";
+ echo "";
+ //we are at the launch page
+ echo "Get started, search for a book you like... or choose from one of the lists below:
";
+
+ $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 "$ListName
";
+ for($i=0;$iList[$id]->ListDetails->Book);$i++){
+ $bookTitle = $xml->List[$id]->ListDetails->Book[$i]->BookTitle;
+ $isbn = $xml->List[$id]->ListDetails->Book[$i]->ISBN;
+ echo "$bookTitle ";
+ }
+ }
+ }
+ else
+ {
+ try{
+ $isbn = substr($isbn, 5);
+ $chars = explode("/",$isbn);
+ $isbn = $chars[0];
+ $ret = 1;
+ $countryCode = 1;
+
+ include "../../private/db.php";
+ $query = "CALL b_getBookInfo('$isbn', $countryCode)";
+ //echo $query;
+ $res = mysqli_query($link, $query) or exit( mysqli_error( $link ));
+ include "../xml/aws_signed_request.php";
+ include "../xml/getAmazonInfo.php";
+ if ( mysqli_num_rows( $res ) > 0 )
+ {
+ $rows=mysqli_fetch_array($res, MYSQLI_ASSOC);
+ $title = $rows["Title"];
+ $author = $rows["Author"];
+ }
+ else
+ {
+ $bookDetails = getAmazonDet($isbn,1,'uk');
+ $bookXML = new SimpleXMLElement($bookDetails);
+ $title = $bookXML->Items->Item[0]->ItemAttributes->Title;
+ $author = $bookXML->Items->Item[0]->ItemAttributes->Author;
+ }
+
+ $linkedBooks = include "../php/read/getLinkedBooks.php";
+ $xml = new SimpleXMLElement($linkedBooks);
+
+ $recommended = "";
+ $linkedRecommended = "";
+ for($i=0;$iisbn);$i++){
+ $linkedISBN = $xml->isbn[$i];
+ include "../../private/db.php";
+ $query = "CALL b_getBookInfo('$linkedISBN', $countryCode)";
+ //echo $query;
+ $res = mysqli_query($link, $query) or exit( mysqli_error( $link ));
+ if ( mysqli_num_rows( $res ) > 0 )
+ {
+ $rows=mysqli_fetch_array($res, MYSQLI_ASSOC);
+ $titleL = $rows["Title"];
+ $authorL = $rows["Author"];
+ mysqli_close($link);
+ }
+ else
+ {
+ $bookLDetails = getAmazonDet($linkedISBN,1,'uk');
+ $bookLXML = new SimpleXMLElement($bookLDetails);
+ $titleL = $bookLXML->Items->Item[0]->ItemAttributes->Title;
+ $authorL = $bookLXML->Items->Item[0]->ItemAttributes->Author;
+ }
+ if($titleL != "")
+ {
+ $recommended .= " $titleL by $authorL,";
+ $underAuthor = str_replace(" ","_",$authorL);
+ $underTitle = str_replace(" ","_",$titleL);
+ $linkedRecommended .= "$titleL by $authorL, ";
+ }
+ }
+
+ $vote = "Vote on these recommendations!";
+
+ echo "";
+
+ echo "YourNextRead (UK) Recommended Books for $title by $author";
+ echo "";
+ if($iPhone && !$iPad)
+ {
+ echo "";
+ echo "";
+ }
+ else
+ {
+ echo "";
+ echo $launchScript;//"";
+ }
+
+ echo "";
+
+ echo "";
+ echo "Recommended Books for $title by $author:";
+ echo $linkedRecommended . "
";
+ echo "" . $vote . "
";
+
+ echo "Change to YourNextRead Germany, ";
+ echo "Change to YourNextRead Canada, ";
+ echo "Change to YourNextRead France, ";
+ echo "Change to YourNextRead USA";
+ echo ", See this on YourNextPresent, ";
+ echo "Switch to YourNextFilm, ";
+ echo "Switch to YourNextGame";
+ }
+ catch(Exception $e)
+ {
+ echo 'Message: ' .$e->getMessage();
+ }
+ }
+ }
+ else
+ {
+ echo "";
+
+ echo "YourNextRead: Book Recommendations (UK)";
+ //the title will get changed dynamically in the GWT code
+ echo "";
+ if($iPhone && !$iPad)
+ {
+ echo "";
+ echo "";
+ }
+ else
+ {
+ echo "";
+ echo $launchScript;//"";
+ }
+
+ echo "";
+
+ echo "";
+ echo "
+
+ ";
+ echo "";
+ }
+ }
+ ?>
+
+
+
+
+
+
+