Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html >
- <html>
- <head>
- <title>Swagl | Results: <?php echo($qry); ?></title>
- <link rel="icon" type="image/png" href="favicon.ico" />
- <link href="css/results.css?version=1" rel="stylesheet" type="text/css">
- <script>
- var counter = 1;
- setInterval(function(){
- var myCanvas = document.getElementById('myCanvas');
- var ctx = myCanvas.getContext('2d');
- var img = new Image;
- img.onload = function(){
- ctx.drawImage(img,0,0);
- };
- // I had 4 images in my folder so I checked with 4.
- if(counter == 4) counter = 1;
- // assuming that your image sequence is named 1.jpg, 2.jpg, 3.jpg ....
- img.src = 'img/'+ counter + '.jpg';
- document.getElementById('myCanvas').onclick = function(e){
- window.location.href = 'http://www.google.com';};
- counter++;
- // I set the interval to 100 ms, increase or decrease as per your need.
- // If you don't want loop use clearTimeout()
- },10000);
- // works until I add this line.
- </script>
- </head>
- <body bgcolor="#0099CC">
- <div id="header">
- <a href="index.html"><img src="img/logo.png" alt="Swagl" border="0" /></a><br>
- <form action="newbing.php" method="GET">
- <input type="text" name="search" style="width: 60%;"
- <?php echo 'value="' . $qry . '"'; ?> /> <input type="hidden"
- name="str" <?php echo 'value="' . $client . '"'; ?> /> <input
- type="submit" value="FIND IT NOW!" />
- </form>
- </div>
- <div id="contentarea" style="border: #0099CC;">
- <div id="resultsarea">
- SEARCH RESULTS
- You searched for: <br>
- <?php
- /**
- * Created by PhpStorm.
- * User: scottmiller
- * Date: 4/24/2018
- * Time: 11:37 AM
- */
- // NOTE: Be sure to uncomment the following line in your php.ini file.
- // ;extension=php_openssl.dll
- // **********************************************
- // *** Update or verify the following values. ***
- // **********************************************
- // Replace the accessKey string value with your valid access key.
- $accessKey = 'c668749bc6a149ccb3c910b7842925cf';
- // Verify the endpoint URI. At this writing, only one endpoint is used for Bing
- // search APIs. In the future, regional endpoints may be available. If you
- // encounter unexpected authorization errors, double-check this value against
- // the endpoint for your Bing Web search instance in your Azure dashboard.
- $endpoint = 'https://api.cognitive.microsoft.com/bing/v5.0/search';
- $term = $_GET['search'];
- function BingWebSearch ($url, $key, $query) {
- // Prepare HTTP request
- // NOTE: Use the key 'http' even if you are making an HTTPS request. See:
- // http://php.net/manual/en/function.stream-context-create.php
- $headers = "Ocp-Apim-Subscription-Key: $key\r\n";
- $options = array ('http' => array (
- 'header' => $headers,
- 'method' => 'GET'));
- // Perform the Web request and get the JSON response
- $context = stream_context_create($options);
- $result = file_get_contents($url . "?q=" . urlencode($query).'&count=50', false, $context);
- // Extract Bing HTTP headers
- $headers = array();
- foreach ($http_response_header as $k => $v) {
- $h = explode(":", $v, 2);
- if (isset($h[1]))
- if (preg_match("/^BingAPIs-/", $h[0]) || preg_match("/^X-MSEdge-/", $h[0]))
- $headers[trim($h[0])] = trim($h[1]);
- }
- return array($headers, $result);
- }
- print $term ;
- echo "<BR><BR><BR>";
- list($headers, $json) = BingWebSearch($endpoint, $accessKey, $term);
- /* print "\nRelevant Headers:\n\n";
- foreach ($headers as $k => $v) {
- print $k . ": " . $v . "\n";
- } /*
- /* print "\nJSON Response:\n\n";
- echo json_encode(json_decode($json), JSON_PRETTY_PRINT); */
- $array=json_decode($json,true);
- foreach ($array["webPages"]["value"] as $k){
- echo '<div id="'.'name">'.$k["name"].'</div>';
- echo '<a href = '.$k["url"];
- echo '<BR>';
- echo $k["displayUrl"].'</a>';
- echo '<BR>';
- echo $k["snippet"];
- echo '<BR>';
- echo '<BR>';
- }
- $noffset=urlencode($_GET['offset']+15);
- $poffset=urlencode($_GET['offset']-15);
- echo '<a href = '.$url.'?search='.$term.'&count=50&offset='.$poffset.'>Previous </a>';
- echo '<a href = '.$url.'?search='.$term.'&count=50&offset='.$noffset.'>Next</a>';
- echo '</div>';
- ?>
- <div id = "ad"><canvas id="myCanvas" width="250" height="250"></canvas></div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement