index.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. require_once("../../api.php");
  3. require_once("../../include/lib.php");
  4. $q = htmlspecialchars($_GET["q"]);
  5. if (!isset($q) || $q == "" || is_null($q)) {
  6. header("Location: /");
  7. die();
  8. }
  9. $cur = "/search/?q=".$q;
  10. $res = get("search/artworks/".$q);
  11. if ($res->error) die();
  12. if (!isset($res->body)) {
  13. header("Location: /404.php");
  14. die();
  15. }
  16. $res = $res->body;
  17. $out = ["title" => $res->alt, "desc" => $res->description];
  18. ?>
  19. <?php include("../../include/header.php"); ?>
  20. <?php
  21. foreach ($res->relatedTags as $t) {
  22. ?>
  23. <a href="/search/?q=<?= $t ?>">#<?= $t ?></a>
  24. <?php
  25. }
  26. ?>
  27. <h2>結果</h2>
  28. <?php
  29. foreach ($res->illustManga->data as $r) {
  30. if (is_null($r->id)) continue;
  31. ?>
  32. <div class="searchres">
  33. <a href="/artworks/?id=<?= $r->id ?>">
  34. <img src="<?= imgprx($r->url) ?>" alt="<?= $r->alt ?>" />
  35. <?= $r->title ?>
  36. </a>
  37. <br />
  38. <a href="/users/?id=<?= $r->userId ?>">
  39. <img src="<?= imgprx($r->profileImageUrl) ?>" alt="<?= $r->userName ?>" style="width: 24px; height: 24px;" />
  40. <?= $r->userName ?>
  41. </a>
  42. </div>
  43. <?php
  44. }
  45. ?>
  46. <?php include("../../include/footer.php"); ?>