Advertisement
smaction

swagl

Apr 30th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1.  
  2. <!DOCTYPE html >
  3. <html>
  4. <head>
  5. <title>Swagl | Results: <?php echo($qry); ?></title>
  6. <link rel="icon" type="image/png" href="favicon.ico" />
  7. <link href="css/results.css?version=1" rel="stylesheet" type="text/css">
  8. <script>
  9. var counter = 1;
  10. setInterval(function(){
  11. var myCanvas = document.getElementById('myCanvas');
  12. var ctx = myCanvas.getContext('2d');
  13. var img = new Image;
  14. img.onload = function(){
  15. ctx.drawImage(img,0,0);
  16. };
  17.  
  18. // I had 4 images in my folder so I checked with 4.
  19. if(counter == 4) counter = 1;
  20.  
  21. // assuming that your image sequence is named 1.jpg, 2.jpg, 3.jpg ....
  22. img.src = 'img/'+ counter + '.jpg';
  23. document.getElementById('myCanvas').onclick = function(e){
  24. window.location.href = 'http://www.google.com';};
  25.  
  26.  
  27. counter++;
  28.  
  29.  
  30. // I set the interval to 100 ms, increase or decrease as per your need.
  31. // If you don't want loop use clearTimeout()
  32. },10000);
  33. // works until I add this line.
  34.  
  35. </script>
  36. </head>
  37. <body bgcolor="#0099CC">
  38. <div id="header">
  39. <a href="index.html"><img src="img/logo.png" alt="Swagl" border="0" /></a><br>
  40. <form action="newbing.php" method="GET">
  41. <input type="text" name="search" style="width: 60%;"
  42. <?php echo 'value="' . $qry . '"'; ?> /> <input type="hidden"
  43. name="str" <?php echo 'value="' . $client . '"'; ?> /> <input
  44. type="submit" value="FIND IT NOW!" />
  45. </form>
  46. </div>
  47. <div id="contentarea" style="border: #0099CC;">
  48. <div id="resultsarea">
  49. SEARCH RESULTS
  50.  
  51. You searched for: <br>
  52. <?php
  53. /**
  54. * Created by PhpStorm.
  55. * User: scottmiller
  56. * Date: 4/24/2018
  57. * Time: 11:37 AM
  58. */
  59.  
  60.  
  61. // NOTE: Be sure to uncomment the following line in your php.ini file.
  62. // ;extension=php_openssl.dll
  63.  
  64. // **********************************************
  65. // *** Update or verify the following values. ***
  66. // **********************************************
  67.  
  68. // Replace the accessKey string value with your valid access key.
  69. $accessKey = 'c668749bc6a149ccb3c910b7842925cf';
  70.  
  71. // Verify the endpoint URI. At this writing, only one endpoint is used for Bing
  72. // search APIs. In the future, regional endpoints may be available. If you
  73. // encounter unexpected authorization errors, double-check this value against
  74. // the endpoint for your Bing Web search instance in your Azure dashboard.
  75. $endpoint = 'https://api.cognitive.microsoft.com/bing/v5.0/search';
  76.  
  77. $term = $_GET['search'];
  78.  
  79. function BingWebSearch ($url, $key, $query) {
  80. // Prepare HTTP request
  81. // NOTE: Use the key 'http' even if you are making an HTTPS request. See:
  82. // http://php.net/manual/en/function.stream-context-create.php
  83. $headers = "Ocp-Apim-Subscription-Key: $key\r\n";
  84.  
  85. $options = array ('http' => array (
  86. 'header' => $headers,
  87. 'method' => 'GET'));
  88.  
  89. // Perform the Web request and get the JSON response
  90. $context = stream_context_create($options);
  91. $result = file_get_contents($url . "?q=" . urlencode($query).'&count=50', false, $context);
  92.  
  93. // Extract Bing HTTP headers
  94. $headers = array();
  95. foreach ($http_response_header as $k => $v) {
  96. $h = explode(":", $v, 2);
  97. if (isset($h[1]))
  98. if (preg_match("/^BingAPIs-/", $h[0]) || preg_match("/^X-MSEdge-/", $h[0]))
  99. $headers[trim($h[0])] = trim($h[1]);
  100. }
  101.  
  102. return array($headers, $result);
  103. }
  104.  
  105.  
  106.  
  107. print $term ;
  108. echo "<BR><BR><BR>";
  109.  
  110. list($headers, $json) = BingWebSearch($endpoint, $accessKey, $term);
  111.  
  112. /* print "\nRelevant Headers:\n\n";
  113. foreach ($headers as $k => $v) {
  114. print $k . ": " . $v . "\n";
  115. } /*
  116.  
  117. /* print "\nJSON Response:\n\n";
  118. echo json_encode(json_decode($json), JSON_PRETTY_PRINT); */
  119.  
  120. $array=json_decode($json,true);
  121.  
  122.  
  123.  
  124. foreach ($array["webPages"]["value"] as $k){
  125. echo '<div id="'.'name">'.$k["name"].'</div>';
  126. echo '<a href = '.$k["url"];
  127. echo '<BR>';
  128. echo $k["displayUrl"].'</a>';
  129. echo '<BR>';
  130. echo $k["snippet"];
  131. echo '<BR>';
  132. echo '<BR>';
  133.  
  134. }
  135. $noffset=urlencode($_GET['offset']+15);
  136. $poffset=urlencode($_GET['offset']-15);
  137. echo '<a href = '.$url.'?search='.$term.'&count=50&offset='.$poffset.'>Previous </a>';
  138. echo '<a href = '.$url.'?search='.$term.'&count=50&offset='.$noffset.'>Next</a>';
  139. echo '</div>';
  140.  
  141. ?>
  142. <div id = "ad"><canvas id="myCanvas" width="250" height="250"></canvas></div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement