64 lines
2.6 KiB
PHP
64 lines
2.6 KiB
PHP
<?php
|
|
include('scrapers/wallhaven.php');
|
|
include('style/header.php');
|
|
include('misc/tools.php');
|
|
$config = require('config.php');
|
|
|
|
if ($_POST['purity'] == "nsfw" || $_GET['p'] == "nsfw")
|
|
$apikey = $config["frontends"]["wallhaven"]["apikey"];
|
|
else
|
|
$apikey = "";
|
|
if ((!$_POST['purity'] && !$_POST['wall']) && $_GET['w']) {
|
|
$_POST['purity'] = $_GET['p'];
|
|
$wall = getwallpaper("https://wallhaven.cc/api/v1/w/$_GET[w]?apikey=$apikey");
|
|
$_POST['wall'] = $wall["path"];
|
|
}
|
|
/* set meta tag */
|
|
printf("<meta property='twitter:image:src' content='/proxy.php?i=%s'>", $_POST['wall']);
|
|
printf("<meta property='twitter:card' content='summary_large_image'>");
|
|
/* get wallpaper id and get info from api */
|
|
preg_match("/(?!.*-)([A-Za-z0-9]+)/", $_POST['wall'], $matches);
|
|
$res = getwallpaper("https://wallhaven.cc/api/v1/w/$matches[0]?apikey=$apikey");
|
|
?>
|
|
<div id='wallmaster'>
|
|
<div id='bwallpaperview'>
|
|
<?php
|
|
if ($_GET['p'] == "nsfw" && !$apikey)
|
|
printf("<p id='error'>Server doesn't have an apikey, cannot view image.</p>");
|
|
?>
|
|
<div>
|
|
<label>
|
|
<input type="checkbox">
|
|
<?php
|
|
printf("<img src='/proxy.php?i=%s'>\n", $_POST['wall']);
|
|
?>
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<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&%s=on&%s=on'>Similar Wallpapers</a></summary>\n", $matches[0], ucfirst($res["category"]), toupperpurity($res["purity"]));
|
|
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>
|