aboutsummaryrefslogtreecommitdiffstats
path: root/view.php
diff options
context:
space:
mode:
authorSquibid <me@zacharyscheiman.com>2023-09-22 18:08:37 -0400
committerSquibid <me@zacharyscheiman.com>2023-09-22 18:08:37 -0400
commit472092fe43ad7da9feb4a8c0b4bf216b20c063b9 (patch)
tree6200ad064861b167684483c38e7db9ad05519e7e /view.php
downloadwallheaven-472092fe43ad7da9feb4a8c0b4bf216b20c063b9.tar.gz
wallheaven-472092fe43ad7da9feb4a8c0b4bf216b20c063b9.tar.bz2
wallheaven-472092fe43ad7da9feb4a8c0b4bf216b20c063b9.zip
inital commit
Diffstat (limited to '')
-rw-r--r--view.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/view.php b/view.php
new file mode 100644
index 0000000..bbc707b
--- /dev/null
+++ b/view.php
@@ -0,0 +1,55 @@
+<head>
+ <title>WallHeaven</title>
+ <meta name="description" content="Wallpaper proxy">
+</head>
+<?php
+ include('scrapers/wallhaven.php');
+ include('style/header.php');
+ include('misc/tools.php');
+ $config = require('config.php');
+
+ if ((!$_POST['purity'] && !$_POST['wall']) && $_GET['w']) {
+ $_POST['purity'] = $_GET['p'];
+ $wall = getwallpaper("https://wallhaven.cc/api/v1/w/".$_GET['w']);
+ $_POST['wall'] = $wall["path"];
+ }
+ /* get wallpaper id and get info from api */
+ preg_match("/(?!.*-)([A-Za-z0-9]+)/", $_POST['wall'], $matches);
+ if ($_POST['purity'] === "nsfw")
+ $apikey = $config["frontends"]["wallhaven"]["apikey"];
+ else
+ $apikey = "";
+ $res = getwallpaper("https://wallhaven.cc/api/v1/w/$matches[0]?apikey=$apikey");
+?>
+<div id='wallmaster'>
+<div id='wallpaperinfo'>
+<div id='uploader'>
+<?php
+ printf("<img src='/proxy.php?i=%s' width=64 height=64>\n<br>\n", $res["uploader"]["avatar"]["medium"]);
+ printf("<a href='/query.php?q=@%s'><span title='%s'>%s</span></a>\n<br>\n", $res["uploader"]["username"], $res["uploader"]["group"], $res["uploader"]["username"]);
+ printf("<span title='%s'>%s old</span>\n", $res["created_at"], timesince(strtotime($res["created_at"])));
+?>
+ </div>
+<?php
+ printf("<hr><details id='tags' open><summary>Tags<a id='similar' href='/query.php?q=like:%s'>Similar Wallpapers</a></summary>\n", $matches[0]);
+ foreach ($res["tags"] as $tags)
+ printf("<span title='%s' id='%s'><a href='/query.php?q=id:%s'>%s</a></span>\n", $tags["alias"], $tags["purity"], $tags["id"], $tags["name"]);
+?>
+</details>
+<hr><details id='properties' open><summary>Properties</summary>
+<?php
+ printf("<p>Category <span id='category'>%s</span></p>\n", ucfirst($res["category"]));
+ printf("<p>Purity <span id='%s'>%s</span></p>\n", $res["purity"], toupperpurity($res["purity"]));
+ printf("<p>Resolution <span id='resolution'>%s</span></p>\n", $res["resolution"]);
+ printf("<p>File Size <span id='size'>%s</span></p>\n", humanfilesize($res["file_size"]));
+ printf("<p>Share <span><a id='share' href='/view.php?w=%s&p=%s'>%s</a></span></p>\n", $matches[0], $_POST['purity'], $matches[0]);
+?>
+</details>
+<hr>
+</div>
+<div id='bwallpaperview'>
+<?php
+ printf("<img src='/proxy.php?i=%s' alt='loading image...'>\n", $_POST['wall']);
+?>
+</div>
+</div>