1
+ − 1 <?PHP
+ − 2 session_start();
+ − 3
+ − 4 function uniqueRand($n, $min = 0, $max = null)
+ − 5 {
+ − 6 if($max === null)
+ − 7 $max = getrandmax();
+ − 8 $array = range($min, $max);
+ − 9 $return = array();
+ − 10 $keys = array_rand($array, $n);
+ − 11 foreach($keys as $key)
+ − 12 $return[] = $array[$key];
+ − 13 return $return;
+ − 14 }
+ − 15
+ − 16 include "../mdetect.php";
+ − 17 $uagent_obj = new uagent_info();
+ − 18 $iPhone = $uagent_obj->DetectSmartphone();
+ − 19 $iPad = $uagent_obj->DetectIpad();
+ − 20
+ − 21 $proceed = true;
+ − 22 $launchScript = "<script type=\"text/javascript\" language=\"javascript\" src=\"../books/books.nocache.js\"></script>";
+ − 23
+ − 24 //print_r($_SERVER);
+ − 25 if (isset($_SERVER['HTTP_REFERER']) || isset($_GET['facebook']))
+ − 26 {
+ − 27 $pos = strpos($_SERVER['HTTP_REFERER'], "apps.facebook.com");
+ − 28 if($pos !== false || isset($_GET['facebook']))
+ − 29 {
+ − 30 //we are in facebook canvas so react appropriately
+ − 31 include_once '../facebook.php';
+ − 32
+ − 33 $facebook = new Facebook(array(
+ − 34 'appId' => '128245333876633',
+ − 35 'secret' => 'f51afc7e04289db62448edd8b70d83bf',
+ − 36 'cookie' => true,
+ − 37 'domain' => 'yournextpresent.com'
+ − 38 ));
+ − 39
+ − 40 $session = $facebook->getSession();
+ − 41
+ − 42 if (!$session) {
+ − 43 $proceed = false;
+ − 44 $url = $facebook->getLoginUrl(array(
+ − 45 'canvas' => 1,
+ − 46 'fbconnect' => 0,
+ − 47 'req_perms' => 'email,user_birthday,publish_stream'
+ − 48 ));
+ − 49
+ − 50 echo "<script type='text/javascript'>top.location.href = '$url';</script>";
+ − 51 }
+ − 52 else
+ − 53 {
+ − 54 $launchScript = "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksFB/books.nocache.js\"></script>";
+ − 55 }
+ − 56 }
+ − 57 }
+ − 58 echo "<!DOCTYPE html><html>";
+ − 59 if($proceed)
+ − 60 {
+ − 61 echo "<head>";
+ − 62 echo "<meta name=\"fragment\" content=\"!\">";
+ − 63 echo "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />";
+ − 64 echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">";
+ − 65 echo "<link type=\"text/css\" rel=\"stylesheet\" href=\"../Books.css\">";
+ − 66
+ − 67 if(isset($_GET['_escaped_fragment_'])) {
+ − 68 $isbn = $_GET['_escaped_fragment_'];
+ − 69 if($isbn == ""){
+ − 70 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!\">";
+ − 71
+ − 72 echo "<title>YourNextRead: Book Recommendations (UK)</title>";
+ − 73 echo "<div id=\"script\"></div><noscript>
+ − 74 <p>You need to have Javascript enabled to use YourNextRead - Sorry!<p>
+ − 75 <p>Please see instructions on how to switch this on, depending on which browser you use:<p>
+ − 76 <ul>
+ − 77 <li><a href=\"http://www.ehow.com/how_2033406_enable-javascript-firefox.html\">Firefox</a></li>
+ − 78 <li><a href=\"http://www.chromefans.org/chrome-tutorial/how-to-enable-or-disable-javascript-in-google-chrome.htm\">Chrome</a></li>
+ − 79 <li><a href=\"http://support.microsoft.com/gp/howtoscript\">Internet Explorer</a></li>
+ − 80 </ul>
+ − 81 <p>Thank you for using YourNextRead<p>
+ − 82 <img src=\"http://www.yournextread.com/images/topleft.gif\" alt=\"YourNextRead\"/>
+ − 83 </noscript>";
+ − 84 if($iPhone && !$iPad)
+ − 85 {
+ − 86 echo "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />";
+ − 87 echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksMob/books.nocache.js\"></script>";
+ − 88 }
+ − 89 else
+ − 90 {
+ − 91 echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../raphael-min.js\"></script>";
+ − 92 echo $launchScript;//"<script type=\"text/javascript\" language=\"javascript\" src=\"../books/books.nocache.js\"></script>";
+ − 93 }
+ − 94 echo "</head>";
+ − 95 echo "<body>";
+ − 96 //we are at the launch page
+ − 97 echo "<p>Get started, search for a book you like... or choose from one of the lists below:</p><BR></BR>";
+ − 98
+ − 99 $ret = 1;
+ − 100
+ − 101 $bookLists = include "../php/read/getAllSavedBooks.php";
+ − 102 $xml = new SimpleXMLElement($bookLists);
+ − 103
+ − 104 $numOfLists = sizeof($xml->List) - 1; //-1 for zero indexing
+ − 105
+ − 106 $randomFourLists = uniqueRand(4,0,$numOfLists);
+ − 107
+ − 108 foreach ($randomFourLists as $id) {
+ − 109 $ListName = $xml->List[$id]->SavedListName;
+ − 110 echo "<p><b>$ListName</b></p><BR></BR>";
+ − 111 for($i=0;$i<sizeof($xml->List[$id]->ListDetails->Book);$i++){
+ − 112 $bookTitle = $xml->List[$id]->ListDetails->Book[$i]->BookTitle;
+ − 113 $isbn = $xml->List[$id]->ListDetails->Book[$i]->ISBN;
+ − 114 echo "<a href=http://www.YourNextRead.com/uk/#!isbn=$isbn>$bookTitle</a> ";
+ − 115 }
+ − 116 }
+ − 117 }
+ − 118 else
+ − 119 {
+ − 120 try{
+ − 121 $isbn = substr($isbn, 5);
+ − 122 $chars = explode("/",$isbn);
+ − 123 $isbn = $chars[0];
+ − 124 $ret = 1;
+ − 125 $countryCode = 1;
+ − 126
+ − 127 include "../../private/db.php";
+ − 128 $query = "CALL b_getBookInfo('$isbn', $countryCode)";
+ − 129 //echo $query;
+ − 130 $res = mysqli_query($link, $query) or exit( mysqli_error( $link ));
+ − 131 include "../xml/aws_signed_request.php";
+ − 132 include "../xml/getAmazonInfo.php";
+ − 133 if ( mysqli_num_rows( $res ) > 0 )
+ − 134 {
+ − 135 $rows=mysqli_fetch_array($res, MYSQLI_ASSOC);
+ − 136 $title = $rows["Title"];
+ − 137 $author = $rows["Author"];
+ − 138 }
+ − 139 else
+ − 140 {
+ − 141 $bookDetails = getAmazonDet($isbn,1,'uk');
+ − 142 $bookXML = new SimpleXMLElement($bookDetails);
+ − 143 $title = $bookXML->Items->Item[0]->ItemAttributes->Title;
+ − 144 $author = $bookXML->Items->Item[0]->ItemAttributes->Author;
+ − 145 }
+ − 146
+ − 147 $linkedBooks = include "../php/read/getLinkedBooks.php";
+ − 148 $xml = new SimpleXMLElement($linkedBooks);
+ − 149
+ − 150 $recommended = "";
+ − 151 $linkedRecommended = "";
+ − 152 for($i=0;$i<sizeof($xml->isbn);$i++){
+ − 153 $linkedISBN = $xml->isbn[$i];
+ − 154 include "../../private/db.php";
+ − 155 $query = "CALL b_getBookInfo('$linkedISBN', $countryCode)";
+ − 156 //echo $query;
+ − 157 $res = mysqli_query($link, $query) or exit( mysqli_error( $link ));
+ − 158 if ( mysqli_num_rows( $res ) > 0 )
+ − 159 {
+ − 160 $rows=mysqli_fetch_array($res, MYSQLI_ASSOC);
+ − 161 $titleL = $rows["Title"];
+ − 162 $authorL = $rows["Author"];
+ − 163 mysqli_close($link);
+ − 164 }
+ − 165 else
+ − 166 {
+ − 167 $bookLDetails = getAmazonDet($linkedISBN,1,'uk');
+ − 168 $bookLXML = new SimpleXMLElement($bookLDetails);
+ − 169 $titleL = $bookLXML->Items->Item[0]->ItemAttributes->Title;
+ − 170 $authorL = $bookLXML->Items->Item[0]->ItemAttributes->Author;
+ − 171 }
+ − 172 if($titleL != "")
+ − 173 {
+ − 174 $recommended .= " $titleL by $authorL,";
+ − 175 $underAuthor = str_replace(" ","_",$authorL);
+ − 176 $underTitle = str_replace(" ","_",$titleL);
+ − 177 $linkedRecommended .= "<a href=\"http://www.YourNextRead.com/uk/#!isbn=$linkedISBN/$underTitle" . "_by_$authorL\">$titleL by $authorL</a>, ";
+ − 178 }
+ − 179 }
+ − 180
+ − 181 $vote = "Vote on these recommendations!";
+ − 182
+ − 183 echo "<META NAME=\"Description\" CONTENT=\"YourNextRead recommended books for $title by $author:$recommended $vote\">";
+ − 184
+ − 185 echo "<title>YourNextRead (UK) Recommended Books for $title by $author</title>";
+ − 186 echo "<div id=\"script\"></div><noscript>
+ − 187 <p>You need to have Javascript enabled to use YourNextRead - Sorry!<p>
+ − 188 <p>Please see instructions on how to switch this on, depending on which browser you use:<p>
+ − 189 <ul>
+ − 190 <li><a href=\"http://www.ehow.com/how_2033406_enable-javascript-firefox.html\">Firefox</a></li>
+ − 191 <li><a href=\"http://www.chromefans.org/chrome-tutorial/how-to-enable-or-disable-javascript-in-google-chrome.htm\">Chrome</a></li>
+ − 192 <li><a href=\"http://support.microsoft.com/gp/howtoscript\">Internet Explorer</a></li>
+ − 193 </ul>
+ − 194 <p>Thank you for using YourNextRead<p>
+ − 195 <img src=\"http://www.yournextread.com/images/topleft.gif\" alt=\"YourNextRead\"/>
+ − 196 </noscript>";
+ − 197 if($iPhone && !$iPad)
+ − 198 {
+ − 199 echo "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />";
+ − 200 echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksMob/books.nocache.js\"></script>";
+ − 201 }
+ − 202 else
+ − 203 {
+ − 204 echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../raphael-min.js\"></script>";
+ − 205 echo $launchScript;//"<script type=\"text/javascript\" language=\"javascript\" src=\"../books/books.nocache.js\"></script>";
+ − 206 }
+ − 207
+ − 208 echo "</head>";
+ − 209
+ − 210 echo "<body>";
+ − 211 echo "<p>Recommended Books for <b>$title</b> by <b>$author</b>:";
+ − 212 echo $linkedRecommended . "</p>";
+ − 213 echo "<p>" . $vote . "</p>";
+ − 214
+ − 215 echo "Change to <a href=\"http://www.YourNextRead.com/de/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead Germany</a>, ";
+ − 216 echo "Change to <a href=\"http://www.YourNextRead.com/ca/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead Canada</a>, ";
+ − 217 echo "Change to <a href=\"http://www.YourNextRead.com/fr/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead France</a>, ";
+ − 218 echo "Change to <a href=\"http://www.YourNextRead.com/us/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead USA</a>";
+ − 219 echo ", See this on <a href=\"http://www.YourNextPresent.com/uk/#!isbn=$isbn\">YourNextPresent</a>, ";
+ − 220 echo "Switch to <a href=\"http://www.YourNextFilm.com/uk/\">YourNextFilm</a>, ";
+ − 221 echo "Switch to <a href=\"http://www.YourNextGame.com/uk/\">YourNextGame</a>";
+ − 222 }
+ − 223 catch(Exception $e)
+ − 224 {
+ − 225 echo 'Message: ' .$e->getMessage();
+ − 226 }
+ − 227 }
+ − 228 }
+ − 229 else
+ − 230 {
+ − 231 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!\">";
+ − 232
+ − 233 echo "<title>YourNextRead: Book Recommendations (UK)</title>";
+ − 234 //the title will get changed dynamically in the GWT code
+ − 235 echo "<div id=\"script\"></div><noscript>
+ − 236 <p>You need to have Javascript enabled to use YourNextRead - Sorry!<p>
+ − 237 <p>Please see instructions on how to switch this on, depending on which browser you use:<p>
+ − 238 <ul>
+ − 239 <li><a href=\"http://www.ehow.com/how_2033406_enable-javascript-firefox.html\">Firefox</a></li>
+ − 240 <li><a href=\"http://www.chromefans.org/chrome-tutorial/how-to-enable-or-disable-javascript-in-google-chrome.htm\">Chrome</a></li>
+ − 241 <li><a href=\"http://support.microsoft.com/gp/howtoscript\">Internet Explorer</a></li>
+ − 242 </ul>
+ − 243 <p>Thank you for using YourNextRead<p>
+ − 244 <img src=\"http://www.yournextread.com/images/topleft.gif\" alt=\"YourNextRead\"/>
+ − 245 </noscript>";
+ − 246 if($iPhone && !$iPad)
+ − 247 {
+ − 248 echo "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />";
+ − 249 echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksMob/books.nocache.js\"></script>";
+ − 250 }
+ − 251 else
+ − 252 {
+ − 253 echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../raphael-min.js\"></script>";
+ − 254 echo $launchScript;//"<script type=\"text/javascript\" language=\"javascript\" src=\"../books/books.nocache.js\"></script>";
+ − 255 }
+ − 256
+ − 257 echo "</head>";
+ − 258
+ − 259 echo "<body>";
+ − 260 echo "<div id=\"fb-root\"></div>
+ − 261 <script type=\"text/javascript\" src=\"http://connect.facebook.net/en_US/all.js\"></script>
+ − 262 <script type=\"text/javascript\">
+ − 263 FB.init({
+ − 264 appId : '128245333876633',
+ − 265 status : true, // check login status
+ − 266 cookie : true, // enable cookies to allow the server to access the session
+ − 267 xfbml : true // parse XFBML
+ − 268 });
+ − 269 </script>";
+ − 270 echo "<script type=\"text/javascript\">
+ − 271 var obj = new Object;
+ − 272 obj.height=960;
+ − 273 FB.Canvas.setSize(obj);
+ − 274 </script>";
+ − 275 }
+ − 276 }
+ − 277 ?>
+ − 278
+ − 279 <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
+ − 280
+ − 281 <script type="text/javascript">
+ − 282 var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+ − 283 document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+ − 284 </script>
+ − 285 <script type="text/javascript">
+ − 286 try {
+ − 287 var pageTracker = _gat._getTracker("UA-15026249-1");
+ − 288 pageTracker._setDomainName("none");
+ − 289 pageTracker._setAllowLinker(true);
+ − 290 pageTracker._trackPageview();
+ − 291 } catch(err) {}</script>
+ − 292 </body>
+ − 293 </html>