aboutsummaryrefslogtreecommitdiffstats
path: root/misc
diff options
context:
space:
mode:
authorSquibid <me@zacharyscheiman.com>2023-12-27 14:50:22 -0500
committerSquibid <me@zacharyscheiman.com>2023-12-27 14:50:22 -0500
commitede8620428aa27de24a9a556f5d71ee6a25ac32f (patch)
treec7239fdb1567aac3c291643600abfc4e2121d6ec /misc
parentc33a109f4846db21ca06e76826064348b9ee77e8 (diff)
parent3274ca1700480fe68ad4ec6ea2e43d5aa6edb543 (diff)
downloadwallheaven-fd8414e1bef5821e82213d88686b21a90fd73519.tar.gz
wallheaven-fd8414e1bef5821e82213d88686b21a90fd73519.tar.bz2
wallheaven-fd8414e1bef5821e82213d88686b21a90fd73519.zip
Merge branch 'dev'HEAD1.0master
Diffstat (limited to '')
-rw-r--r--misc/tools.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/misc/tools.php b/misc/tools.php
index 602722e..0fec976 100644
--- a/misc/tools.php
+++ b/misc/tools.php
@@ -1,4 +1,7 @@
<?php
+ include_once('scrapers/wallhaven.php');
+ $config = require(__DIR__.'/../config.php');
+
function timesince($time) {
$time = time() - $time;
$timeunits = [
@@ -37,4 +40,24 @@
return strtoupper($str);
return $str;
}
+
+ function humanquery($q, $nsfw = false) {
+ global $config;
+ if ($nsfw)
+ $apikey = $config["frontends"]["wallhaven"]["apikey"];
+ else
+ $apikey = "";
+
+ if (preg_match("/id:[0-9+]/", $q)) {
+ $info = gettaginfo("https://wallhaven.cc/api/v1/tag/".preg_replace("/id:/", "", $q));
+ $q = preg_replace("/id:[0-9]+/", $info["name"], $q);
+ }
+ if (preg_match("/like:([A-Za-z0-9]+)/", $q, $matches)) {
+ $id = preg_replace("/like:/", "", $matches[0]);
+ $wall = getwallpaper("https://wallhaven.cc/api/v1/w/$id?apikey=$apikey");
+ $q = $q."<span id='triangle'></span><img src='/proxy.php?i=".$wall["thumbs"]["orig"]."'>";
+ }
+
+ return $q;
+ }
?>