Mercurial > hg > ywww
view de/index.php @ 49:a67bf725e87b
put both paths in include_path and depend on that
author | Charlie Root |
---|---|
date | Wed, 16 Jan 2019 13:42:15 -0500 |
parents | 84a412b8122c |
children |
line wrap: on
line source
<?PHP session_start(); 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(); $proceed = true; $launchScript = "<script type=\"text/javascript\" language=\"javascript\" src=\"../books/books.nocache.js\"></script>"; //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 "<script type='text/javascript'>top.location.href = '$url';</script>"; } else { $launchScript = "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksFB/books.nocache.js\"></script>"; } } } echo "<!DOCTYPE html><html>"; if($proceed) { echo "<head>"; echo "<meta name=\"fragment\" content=\"!\">"; echo "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />"; 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 (Deutschland)</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 && !$iPad) { echo "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />"; echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksMob/books.nocache.js\"></script>"; } else { echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../raphael-min.js\"></script>"; echo $launchScript;//"<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/de/#!isbn=$isbn>$bookTitle</a> "; } } } else { try{ $isbn = substr($isbn, 5); $chars = explode("/",$isbn); $isbn = $chars[0]; $ret = 1; $countryCode = 3; include "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,'de'); $bookXML = new SimpleXMLElement($bookDetails); if ($bookXML->Items && $bookXML->Items->Item[0] && $bookXML->Items->Item[0]->ItemAttributes) { $attrs=$bookXML->Items->Item[0]->ItemAttributes; if ($attrs->Title) { $title = $attrs->Title; } else { $title ="[no Title]"; } if ($attrs->Author) { $author = $attrs->Author; } else { $author ="[no Author]"; } } else { $title ="[no Title]"; $author = "[no Author]"; } } $linkedBooks = include "../php/read/getLinkedBooks.php"; $xml = new SimpleXMLElement($linkedBooks); $recommended = ""; $linkedRecommended = ""; for($i=0;$i<sizeof($xml->isbn);$i++){ $linkedISBN = $xml->isbn[$i]; include "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,'de'); $bookLXML = new SimpleXMLElement($bookLDetails); if ($bookLXML->Items && $bookLXML->Items->Item[0] && $bookLXML->Items->Item[0]->ItemAttributes) { $attrs=$bookLXML->Items->Item[0]->ItemAttributes; if ($attrs->Title) { $titleL = $attrs->Title; } else { $titleL = ""; } if ($attrs->Author) { $authorL = $attrs->Author; } else { $authorL = ""; } } else { $titleL = ""; } } if($titleL != "") { $recommended .= " $titleL by $authorL,"; $underAuthor = str_replace(" ","_",$authorL); $underTitle = str_replace(" ","_",$titleL); $linkedRecommended .= "<a href=\"http://www.YourNextRead.com/de/#!isbn=$linkedISBN/$underTitle" . "_by_$authorL\">$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 (Deutschland) 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 && !$iPad) { echo "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />"; echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksMob/books.nocache.js\"></script>"; } else { echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../raphael-min.js\"></script>"; echo $launchScript;//"<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 . "</p>"; echo "<p>" . $vote . "</p>"; echo "Change to <a href=\"http://www.YourNextRead.com/fr/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead France</a>, "; echo "Change to <a href=\"http://www.YourNextRead.com/ca/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead Canada</a>, "; echo "Change to <a href=\"http://www.YourNextRead.com/uk/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead UK</a>, "; echo "Change to <a href=\"http://www.YourNextRead.com/us/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead USA</a>"; echo ", See this on <a href=\"http://www.YourNextPresent.com/de/#!isbn=$isbn\">YourNextPresent</a>, "; echo "Switch to <a href=\"http://www.YourNextFilm.com/de/\">YourNextFilm</a>, "; echo "Switch to <a href=\"http://www.YourNextGame.com/de/\">YourNextGame</a>"; } catch(Exception $e) { echo 'Message: ' .$e->getMessage(); } } } 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 (Deutschland)</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 && !$iPad) { echo "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />"; echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksMob/books.nocache.js\"></script>"; } else { echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../raphael-min.js\"></script>"; echo $launchScript;//"<script type=\"text/javascript\" language=\"javascript\" src=\"../books/books.nocache.js\"></script>"; } echo "</head>"; echo "<body>"; echo "<div id=\"fb-root\"></div> <script type=\"text/javascript\" src=\"http://connect.facebook.net/en_US/all.js\"></script> <script type=\"text/javascript\"> FB.init({ appId : '128245333876633', status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); </script>"; echo "<script type=\"text/javascript\"> var obj = new Object; obj.height=960; FB.Canvas.setSize(obj); </script>"; } } ?> <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>