aboutsummaryrefslogtreecommitdiffstats
path: root/view.php
blob: bbc707b8a0f20eeff088bfcf806093171c0e252b (plain) (blame)
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
<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>