Mercurial > hg > ywww
annotate uk/index.php @ 60:05f29eb72283 default tip
review from DB not working???
| author | Charlie Root |
|---|---|
| date | Sun, 09 Jun 2019 06:50:44 -0400 |
| parents | a67bf725e87b |
| children |
| rev | line source |
|---|---|
| 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 | |
|
49
a67bf725e87b
put both paths in include_path and depend on that
Charlie Root
parents:
23
diff
changeset
|
127 include "db.php"; |
| 1 | 128 $query = "CALL b_getBookInfo('$isbn', $countryCode)"; |
| 129 //echo $query; | |
|
23
d606320ec331
post-5.7-upgrade efforts to reduce dropped connections, db insertion fails
Charlie Root
parents:
19
diff
changeset
|
130 $res = mysqli_query($link, $query); |
|
d606320ec331
post-5.7-upgrade efforts to reduce dropped connections, db insertion fails
Charlie Root
parents:
19
diff
changeset
|
131 if (!$res) { |
|
d606320ec331
post-5.7-upgrade efforts to reduce dropped connections, db insertion fails
Charlie Root
parents:
19
diff
changeset
|
132 $err=mysqli_error( $link ); |
|
d606320ec331
post-5.7-upgrade efforts to reduce dropped connections, db insertion fails
Charlie Root
parents:
19
diff
changeset
|
133 mysqli_close($link); |
|
d606320ec331
post-5.7-upgrade efforts to reduce dropped connections, db insertion fails
Charlie Root
parents:
19
diff
changeset
|
134 exit($err); |
|
d606320ec331
post-5.7-upgrade efforts to reduce dropped connections, db insertion fails
Charlie Root
parents:
19
diff
changeset
|
135 } |
| 1 | 136 include "../xml/aws_signed_request.php"; |
| 137 include "../xml/getAmazonInfo.php"; | |
| 138 if ( mysqli_num_rows( $res ) > 0 ) | |
| 139 { | |
| 140 $rows=mysqli_fetch_array($res, MYSQLI_ASSOC); | |
|
23
d606320ec331
post-5.7-upgrade efforts to reduce dropped connections, db insertion fails
Charlie Root
parents:
19
diff
changeset
|
141 mysqli_close($link); |
| 1 | 142 $title = $rows["Title"]; |
| 143 $author = $rows["Author"]; | |
| 144 } | |
| 145 else | |
| 146 { | |
|
23
d606320ec331
post-5.7-upgrade efforts to reduce dropped connections, db insertion fails
Charlie Root
parents:
19
diff
changeset
|
147 mysqli_close($link); |
| 1 | 148 $bookDetails = getAmazonDet($isbn,1,'uk'); |
| 149 $bookXML = new SimpleXMLElement($bookDetails); | |
| 19 | 150 if ($bookXML->Items && $bookXML->Items->Item[0] && |
| 151 $bookXML->Items->Item[0]->ItemAttributes) | |
| 152 { $attrs=$bookXML->Items->Item[0]->ItemAttributes; | |
| 153 if ($attrs->Title) { | |
| 154 $title = $attrs->Title; } | |
| 155 else { | |
| 156 $title ="[no Title]"; | |
| 157 } | |
| 158 if ($attrs->Author) { | |
| 159 $author = $attrs->Author; | |
| 160 } | |
| 161 else { | |
| 162 $author ="[no Author]"; | |
| 163 } | |
| 164 } | |
| 165 else { | |
| 166 $title ="[no Title]"; | |
| 167 $author = "[no Author]"; | |
| 168 } | |
| 1 | 169 } |
| 170 | |
| 171 $linkedBooks = include "../php/read/getLinkedBooks.php"; | |
| 172 $xml = new SimpleXMLElement($linkedBooks); | |
| 173 | |
| 174 $recommended = ""; | |
| 175 $linkedRecommended = ""; | |
| 176 for($i=0;$i<sizeof($xml->isbn);$i++){ | |
| 177 $linkedISBN = $xml->isbn[$i]; | |
|
49
a67bf725e87b
put both paths in include_path and depend on that
Charlie Root
parents:
23
diff
changeset
|
178 include "db.php"; |
| 1 | 179 $query = "CALL b_getBookInfo('$linkedISBN', $countryCode)"; |
| 180 //echo $query; | |
| 181 $res = mysqli_query($link, $query) or exit( mysqli_error( $link )); | |
| 182 if ( mysqli_num_rows( $res ) > 0 ) | |
| 183 { | |
| 184 $rows=mysqli_fetch_array($res, MYSQLI_ASSOC); | |
|
23
d606320ec331
post-5.7-upgrade efforts to reduce dropped connections, db insertion fails
Charlie Root
parents:
19
diff
changeset
|
185 mysqli_close($link); |
| 1 | 186 $titleL = $rows["Title"]; |
| 187 $authorL = $rows["Author"]; | |
| 188 } | |
| 189 else | |
| 190 { | |
|
23
d606320ec331
post-5.7-upgrade efforts to reduce dropped connections, db insertion fails
Charlie Root
parents:
19
diff
changeset
|
191 mysqli_close($link); |
| 1 | 192 $bookLDetails = getAmazonDet($linkedISBN,1,'uk'); |
| 193 $bookLXML = new SimpleXMLElement($bookLDetails); | |
| 19 | 194 if ($bookLXML->Items && |
| 195 $bookLXML->Items->Item[0] && | |
| 196 $bookLXML->Items->Item[0]->ItemAttributes) { | |
| 197 $attrs=$bookLXML->Items->Item[0]->ItemAttributes; | |
| 198 if ($attrs->Title) { | |
| 199 $titleL = $attrs->Title; } | |
| 200 else { | |
| 201 $titleL = ""; } | |
| 202 if ($attrs->Author) { | |
| 203 $authorL = $attrs->Author; } | |
| 204 else { | |
| 205 $authorL = ""; } | |
| 206 } | |
| 207 else { | |
| 208 $titleL = ""; } | |
| 1 | 209 } |
| 210 if($titleL != "") | |
| 211 { | |
| 212 $recommended .= " $titleL by $authorL,"; | |
| 213 $underAuthor = str_replace(" ","_",$authorL); | |
| 214 $underTitle = str_replace(" ","_",$titleL); | |
| 215 $linkedRecommended .= "<a href=\"http://www.YourNextRead.com/uk/#!isbn=$linkedISBN/$underTitle" . "_by_$authorL\">$titleL by $authorL</a>, "; | |
| 216 } | |
| 217 } | |
| 218 | |
| 219 $vote = "Vote on these recommendations!"; | |
| 220 | |
| 221 echo "<META NAME=\"Description\" CONTENT=\"YourNextRead recommended books for $title by $author:$recommended $vote\">"; | |
| 222 | |
| 223 echo "<title>YourNextRead (UK) Recommended Books for $title by $author</title>"; | |
| 224 echo "<div id=\"script\"></div><noscript> | |
| 225 <p>You need to have Javascript enabled to use YourNextRead - Sorry!<p> | |
| 226 <p>Please see instructions on how to switch this on, depending on which browser you use:<p> | |
| 227 <ul> | |
| 228 <li><a href=\"http://www.ehow.com/how_2033406_enable-javascript-firefox.html\">Firefox</a></li> | |
| 229 <li><a href=\"http://www.chromefans.org/chrome-tutorial/how-to-enable-or-disable-javascript-in-google-chrome.htm\">Chrome</a></li> | |
| 230 <li><a href=\"http://support.microsoft.com/gp/howtoscript\">Internet Explorer</a></li> | |
| 231 </ul> | |
| 232 <p>Thank you for using YourNextRead<p> | |
| 233 <img src=\"http://www.yournextread.com/images/topleft.gif\" alt=\"YourNextRead\"/> | |
| 234 </noscript>"; | |
| 235 if($iPhone && !$iPad) | |
| 236 { | |
| 237 echo "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />"; | |
| 238 echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksMob/books.nocache.js\"></script>"; | |
| 239 } | |
| 240 else | |
| 241 { | |
| 242 echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../raphael-min.js\"></script>"; | |
| 243 echo $launchScript;//"<script type=\"text/javascript\" language=\"javascript\" src=\"../books/books.nocache.js\"></script>"; | |
| 244 } | |
| 245 | |
| 246 echo "</head>"; | |
| 247 | |
| 248 echo "<body>"; | |
| 249 echo "<p>Recommended Books for <b>$title</b> by <b>$author</b>:"; | |
| 250 echo $linkedRecommended . "</p>"; | |
| 251 echo "<p>" . $vote . "</p>"; | |
| 252 | |
| 253 echo "Change to <a href=\"http://www.YourNextRead.com/de/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead Germany</a>, "; | |
| 254 echo "Change to <a href=\"http://www.YourNextRead.com/ca/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead Canada</a>, "; | |
| 255 echo "Change to <a href=\"http://www.YourNextRead.com/fr/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead France</a>, "; | |
| 256 echo "Change to <a href=\"http://www.YourNextRead.com/us/#!isbn=$isbn/$title" . "_by_$author\">YourNextRead USA</a>"; | |
| 257 echo ", See this on <a href=\"http://www.YourNextPresent.com/uk/#!isbn=$isbn\">YourNextPresent</a>, "; | |
| 258 echo "Switch to <a href=\"http://www.YourNextFilm.com/uk/\">YourNextFilm</a>, "; | |
| 259 echo "Switch to <a href=\"http://www.YourNextGame.com/uk/\">YourNextGame</a>"; | |
| 260 } | |
| 261 catch(Exception $e) | |
| 262 { | |
| 263 echo 'Message: ' .$e->getMessage(); | |
| 264 } | |
| 265 } | |
| 266 } | |
| 267 else | |
| 268 { | |
| 269 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!\">"; | |
| 270 | |
| 271 echo "<title>YourNextRead: Book Recommendations (UK)</title>"; | |
| 272 //the title will get changed dynamically in the GWT code | |
| 273 echo "<div id=\"script\"></div><noscript> | |
| 274 <p>You need to have Javascript enabled to use YourNextRead - Sorry!<p> | |
| 275 <p>Please see instructions on how to switch this on, depending on which browser you use:<p> | |
| 276 <ul> | |
| 277 <li><a href=\"http://www.ehow.com/how_2033406_enable-javascript-firefox.html\">Firefox</a></li> | |
| 278 <li><a href=\"http://www.chromefans.org/chrome-tutorial/how-to-enable-or-disable-javascript-in-google-chrome.htm\">Chrome</a></li> | |
| 279 <li><a href=\"http://support.microsoft.com/gp/howtoscript\">Internet Explorer</a></li> | |
| 280 </ul> | |
| 281 <p>Thank you for using YourNextRead<p> | |
| 282 <img src=\"http://www.yournextread.com/images/topleft.gif\" alt=\"YourNextRead\"/> | |
| 283 </noscript>"; | |
| 284 if($iPhone && !$iPad) | |
| 285 { | |
| 286 echo "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />"; | |
| 287 echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../booksMob/books.nocache.js\"></script>"; | |
| 288 } | |
| 289 else | |
| 290 { | |
| 291 echo "<script type=\"text/javascript\" language=\"javascript\" src=\"../raphael-min.js\"></script>"; | |
| 292 echo $launchScript;//"<script type=\"text/javascript\" language=\"javascript\" src=\"../books/books.nocache.js\"></script>"; | |
| 293 } | |
| 294 | |
| 295 echo "</head>"; | |
| 296 | |
| 297 echo "<body>"; | |
| 298 echo "<div id=\"fb-root\"></div> | |
| 299 <script type=\"text/javascript\" src=\"http://connect.facebook.net/en_US/all.js\"></script> | |
| 300 <script type=\"text/javascript\"> | |
| 301 FB.init({ | |
| 302 appId : '128245333876633', | |
| 303 status : true, // check login status | |
| 304 cookie : true, // enable cookies to allow the server to access the session | |
| 305 xfbml : true // parse XFBML | |
| 306 }); | |
| 307 </script>"; | |
| 308 echo "<script type=\"text/javascript\"> | |
| 309 var obj = new Object; | |
| 310 obj.height=960; | |
| 311 FB.Canvas.setSize(obj); | |
| 312 </script>"; | |
| 313 } | |
| 314 } | |
| 315 ?> | |
| 316 | |
| 317 <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe> | |
| 318 | |
| 319 <script type="text/javascript"> | |
| 320 var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); | |
| 321 document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); | |
| 322 </script> | |
| 323 <script type="text/javascript"> | |
| 324 try { | |
| 325 var pageTracker = _gat._getTracker("UA-15026249-1"); | |
| 326 pageTracker._setDomainName("none"); | |
| 327 pageTracker._setAllowLinker(true); | |
| 328 pageTracker._trackPageview(); | |
| 329 } catch(err) {}</script> | |
| 330 </body> | |
| 331 </html> |
