forked from Ahwxorg/Binternet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
55 lines (46 loc) · 1.5 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php require "misc/header.php"; ?>
<title>
<?php
$query = htmlspecialchars(trim($_REQUEST["q"]));
echo $query;
?> - Pinternet</title>
</head>
<body>
<form class="searchContainer" method="get" autocomplete="off">
<h1><a class="no-decoration" href="./"><span>P</span>inter<span>n</span>et</a></h1>
<input type="text" name="q"
<?php
$query_encoded = urlencode($query);
if (1 > strlen($query) || strlen($query) > 64)
{
header("Location: ./");
die();
}
echo "value=\"$query\"";
?>
<br>
<hr>
</form>
<?php
$query = $_GET['q'];
$baseurl = "https://pinterest.com/resource/BaseSearchResource/get/?data=%7B%22options%22%3A%7B%22query%22%3A%22{}%22%7D%7D";
$search = function($query) use($baseurl)
{
$url = str_replace("{}", str_replace(" ", "%20", $query), $baseurl);
$json = file_get_contents($url);
$data = json_decode($json);
$images = array();
foreach ($data->{"resource_response"}->{"data"}->{"results"} as $result)
{
$image = $result->{"images"}->{"orig"};
$url = $image->{"url"};
array_push($images, $url);
echo "<a href='/image_proxy.php?url=", $url, "'>";
echo "<img src='/image_proxy.php?url=", $url, "'></a>";
}
return $images;
};
$images = $search("$query");
echo "<br><br><br><br>";
include "misc/footer.php";
?>