Browse Source

ユーザーのトップとイラストページ

諏訪子 1 year ago
parent
commit
5ba83b4dbe
6 changed files with 208 additions and 4 deletions
  1. 25 0
      include/pagination.php
  2. 60 0
      include/usermenu.php
  3. 31 0
      www/style.css
  4. 12 0
      www/userhead.php
  5. 67 0
      www/users/illusts/index.php
  6. 13 4
      www/users/index.php

+ 25 - 0
include/pagination.php

@@ -0,0 +1,25 @@
+      <div class="pagination">
+        <span class="userbtn<?= $page == 1 ? " now" : "" ?>">
+<?php if ($page == 1) { ?>
+          最初
+<?php } else { ?>
+          <a href="<?= $cur."&page=1" ?>">最初</a>
+<?php } ?>
+        </span>
+<?php for ($i = 1; $i <= $sum; $i++) { ?>
+        <span class="userbtn<?= $page == $i ? " now" : "" ?>">
+<?php if ($page == $i) { ?>
+          <?= $i ?>
+<?php } else { ?>
+          <a href="<?= $cur."&page=".$i ?>"><?= $i ?></a>
+<?php } ?>
+        </span>
+<?php } ?>
+        <span class="userbtn<?= $page == $sum ? " now" : "" ?>">
+<?php if ($page == $sum) { ?>
+          最後
+<?php } else { ?>
+          <a href="<?= $cur."&page=".$sum ?>">最後</a>
+<?php } ?>
+        </span>
+      </div>

+ 60 - 0
include/usermenu.php

@@ -0,0 +1,60 @@
+      <img src="/userhead.php?id=<?= $id ?>" alt="<?= $title ?>" style="background-size: cover;" />
+<?php
+  if ($now == "home") {
+?>
+        <span class="userbtn now">トップ</span>
+<?php
+  } else {
+?>
+        <a href="/users/?id=<?= $id ?>" class="userbtn">トップ</a>
+<?php
+  }
+?>
+<?php
+  if ($res->bookmarkCount->public->illust > 0 || $res->bookmarkCount->public->novel > 0) {
+    if ($now == "bookmark") {
+?>
+        <span class="userbtn now">ブックマーク</span>
+<?php
+    } else {
+?>
+        <a href="/users/bookmarks/?id=<?= $id ?>" class="userbtn">ブックマーク</a>
+<?php
+    }
+  }
+  if (count((array)$res->illusts) > 0) {
+    if ($now == "illust") {
+?>
+        <span class="userbtn now">イラスト</span>
+<?php
+    } else {
+?>
+        <a href="/users/illusts/?id=<?= $id ?>" class="userbtn">イラスト</a>
+<?php
+    }
+  }
+  if (count((array)$res->manga) > 0) {
+    if ($now == "manga") {
+?>
+      <span class="userbtn now">漫画</span>
+<?php
+    } else {
+?>
+      <a href="/users/manga/?id=<?= $id ?>" class="userbtn">漫画</a>
+<?php
+    }
+  }
+  if (count((array)$res->novels) > 0) {
+    if ($now == "novel") {
+?>
+      <span class="userbtn now">小説</span>
+<?php
+    } else {
+?>
+      <a href="/users/novels/?id=<?= $id ?>" class="userbtn">小説</a>
+<?php
+    }
+  }
+  unset($title);
+  unset($now);
+?>

+ 31 - 0
www/style.css

@@ -10,6 +10,7 @@ body {
 
 a {
   color: #ea5fea;
+  text-decoration: none;
 }
 
 h2 {
@@ -47,6 +48,7 @@ h2 {
   color: #fcfcfc;
   font-size: 20px;
   width: 100%;
+  border-radius: 4px;
 }
 
 .searchbar {
@@ -76,6 +78,35 @@ h2 {
   margin: auto;
 }
 
+.userbtn {
+  background: #ea5fea;
+  color: #fcfcfc;
+  padding: 4px;
+  border: 1px solid #ffc8ff;
+  border-radius: 2px;
+  margin: 12px 4px 4px;
+  display: inline-block;
+}
+
+.userbtn > a {
+  color: #fcfcfc;
+}
+
+.now {
+  background: #a499a4;
+  color: #4d4d4d;
+  border: 1px solid #bdbdbd;
+}
+
+.now > a {
+  color: #4d4d4d;
+}
+
+.pagination {
+  width: 100%;
+  margin: auto;
+}
+
 .footer {
   text-align: center;
   margin-top: 32px;

+ 12 - 0
www/userhead.php

@@ -0,0 +1,12 @@
+<?php
+  require_once("../config.php");
+  $id = (int)$_GET["id"];
+
+  header("Content-type: image/jpg");
+
+  $ch = curl_init();
+  curl_setopt($ch, CURLOPT_URL, "https://embed.pixiv.net/user_profile.php?id=".$id);
+  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+  curl_exec($ch);
+  curl_close($ch);
+?>

+ 67 - 0
www/users/illusts/index.php

@@ -0,0 +1,67 @@
+<?php
+  require_once("../../../api.php");
+  require_once("../../../include/lib.php");
+  if (!isset($_GET["id"])) header("Location: /404.php");
+  $id = (int)$_GET["id"];
+  $page = isset($_GET["page"]) ? (int)$_GET["page"] : 1;
+  if ($page < 1) $page = 1;
+  $pagemax = 40;
+  $offset = $pagemax * ($page - 1);
+  $res = get("user/".$id."/profile/all");
+  if (!isset($res->body)) {
+    header("Location: /404.php");
+    die();
+  }
+  $top = get("user/".$id."/profile/top");
+  $res = $res->body;
+  $top = $top->body;
+  if (count((array)$res->illusts) == 0) header("Location: /404.php");
+  $out = ["title" => $top->extraData->meta->title, "desc" => $top->extraData->meta->description];
+
+  $index = 0;
+  $illusts = count((array)$res->illusts);
+  $iurl = "user/".$id."/profile/illusts?";
+
+  foreach ($res->illusts as $k => $v) {
+    $index++;
+    if ($index <= $offset) continue;
+    if ($index >= ($pagemax+$offset)+1) break;
+    $iurl .= "ids[]=".$k."&";
+  }
+
+  $iurl .= "work_category=illustManga&is_first_page=0";
+  unset($index);
+?>
+
+<?php
+  include("../../../include/header.php");
+  $title = $top->extraData->meta->ogp->title;
+  $now = "illust";
+  include("../../../include/usermenu.php");
+  unset($res);
+?>
+      <hr />
+<?php
+  if ($illusts > 0) {
+?>
+      <h2>イラスト</h2>
+<?php
+    $i = get($iurl);
+    foreach ($i->body->works as $k => $v) {
+?>
+      <div class="searchres">
+        <a href="/artworks/?id=<?= $v->id ?>">
+          <img src="<?= imgprx($v->url) ?>" alt="<?= $v->alt ?>">
+          <?= $v->title ?>
+        </a>
+      </div>
+<?php
+    }
+  }
+
+  unset($top);
+  $cur = "/users/illusts/?id=".$id;
+  $sum = ceil($illusts/$pagemax);
+  include("../../../include/pagination.php");
+  include("../../../include/footer.php");
+?>

+ 13 - 4
www/users/index.php

@@ -1,5 +1,6 @@
 <?php
   require_once("../../api.php");
+  if (!isset($_GET["id"])) header("Location: /404.php");
   $id = (int)$_GET["id"];
   $res = get("user/".$id."/profile/all");
   if (!isset($res->body)) {
@@ -9,13 +10,21 @@
   $top = get("user/".$id."/profile/top");
   $res = $res->body;
   $top = $top->body;
-  //print_r($top->extraData->meta);exit;
   $out = ["title" => $top->extraData->meta->title, "desc" => $top->extraData->meta->description];
 ?>
 
-<?php include("../../include/header.php"); ?>
-<img src="<?= $top->extraData->meta->ogp->image ?>" alt="<?= $top->extraData->meta->ogp->title ?>" />
+<?php
+  include("../../include/header.php");
+  $title = $top->extraData->meta->ogp->title;
+  $now = "home";
+  include("../../include/usermenu.php");
+  unset($res);
+?>
+<hr />
 <p>
-  <?= nl2br($top->extraData->meta->ogp->description) ?>
+  <?= nl2br($top->extraData->meta->twitter->description) ?>
 </p>
+<?php
+  unset($top);
+?>
 <?php include("../../include/footer.php"); ?>