aboutsummaryrefslogtreecommitdiff
path: root/out
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2021-12-12 11:19:38 +0100
committerMinteck <contact@minteck.org>2021-12-12 11:19:38 +0100
commitdc8f78256944885108f1d52b822c8677bf9d964c (patch)
tree38ea776d4fe8d9d11c28448246afa8af4886351a /out
downloadwolfeye-php-dc8f78256944885108f1d52b822c8677bf9d964c.tar.gz
wolfeye-php-dc8f78256944885108f1d52b822c8677bf9d964c.tar.bz2
wolfeye-php-dc8f78256944885108f1d52b822c8677bf9d964c.zip
Initial commit
Diffstat (limited to 'out')
-rw-r--r--out/index.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/out/index.php b/out/index.php
new file mode 100644
index 0000000..cefe36b
--- /dev/null
+++ b/out/index.php
@@ -0,0 +1,42 @@
+<?php
+
+if (!isset($_GET['q']) || !isset($_GET['u']) || !isset($_GET['i'])) {
+ header("Location: /");
+ die();
+}
+
+$_GET['q'] = strtolower(substr($_GET['q'], 0, 200));
+$_GET['q'] = preg_replace("/[^A-Za-z0-9 ]/", '', preg_replace("/[\.]/", ' ', $_GET['q']));
+
+$data = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/private/db.json"), true);
+
+if ($_GET['i'] !== "_off" && isset($data["entries"][$_GET['i']])) {
+ header("Location: " . $data["entries"][$_GET['i']]["url"]);
+ die();
+} elseif ($_GET['i'] === "_off") {
+ $domains = [];
+
+ foreach ($data["entries"] as $id => $entry) {
+ $domain = explode("/", $entry["url"])[2];
+ $sim = similar_text($domain, $_GET['q'], $perc);
+ if (substr($domain, 0, 4) === "www.") {
+ $domainstr = substr($domain, 4);
+ } else {
+ $domainstr = $domain;
+ }
+ $domains[] = [
+ "id" => $id,
+ "url" => "https://" . $domain . "/",
+ "domain" => $domainstr,
+ "relevance" => $perc / 50 - 1
+ ];
+ }
+
+ usort($domains, function($a, $b) {
+ return $a['relevance'] <=> $b['relevance'];
+ });
+
+ $domains = array_reverse($domains);
+ header("Location: " . $domains[0]['url']);
+ die();
+} \ No newline at end of file