Browse Source

プロクシーしている画像を保存したら、正しいファイル名として保存する様に

諏訪子 1 year ago
parent
commit
6b4cf3feae
10 changed files with 51 additions and 10 deletions
  1. 1 0
      config.example.php
  2. 18 3
      include/header.php
  3. 12 0
      www/artwork.php
  4. 7 4
      www/artworks/index.php
  5. 1 0
      www/index.php
  6. BIN
      www/logo.png
  7. 7 0
      www/proxy.php
  8. 1 0
      www/search/index.php
  9. 2 2
      www/users/illusts/index.php
  10. 2 1
      www/users/index.php

+ 1 - 0
config.example.php

@@ -1,3 +1,4 @@
 <?php
+  define("SITEURL", "https://pixiv.owacon.moe");
   define("SESSION_ID", "XXXXXXXX_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
 ?>

+ 18 - 3
include/header.php

@@ -3,12 +3,27 @@
   <head>
     <meta content="text/html; charset=euc-jp" http-equiv="content-type" />
     <meta name="viewport" content="width=device-width, initial-scale=1" />
-    <?php if (isset($out["desc"])) { ?>
+<?php if (isset($out["desc"])) { ?>
+    <meta property="og:site_name" content="vixip" />
     <meta property="og:title" content="vixip 〜 <?= htmlspecialchars($out["title"]) ?>" />
     <meta property="og:type" content="article" />
     <meta property="og:description" content="<?= htmlspecialchars($out["desc"]) ?>" />
-    <meta property="og:url" content="<?= $gurl ?>" />
-    <?php } ?>
+    <meta property="og:url" content="<?= SITEURL.$cur ?>" />
+    <link rel="canonical" href="<?= SITEURL.$cur ?>" />
+    <meta property="twitter:card" content="summary_large_image" />
+    <meta property="twitter:url" content="<?= SITEURL.$cur ?>" />
+    <meta property="twitter:title" content="vixip 〜 <?= htmlspecialchars($out["title"]) ?>" />
+    <meta property="twitter:description" content="<?= htmlspecialchars($out["desc"]) ?>" />
+<?php if (isset($out["img_sec"])) { ?>
+    <meta property="twitter:image" content="<?= SITEURL."/".$out["img_sec"].".php?".($out["img_sec"] == "artwork" ? "illust_" : "")."id=".$out["img_id"] ?>" />
+    <meta property="og:image" content="<?= SITEURL."/".$out["img_sec"].".php?".($out["img_sec"] == "artwork" ? "illust_" : "")."id=".$out["img_id"] ?>" />
+<?php } else { ?>
+    <meta property="twitter:image" content="<?= SITEURL ?>/logo.png" />
+    <meta property="og:image" content="<?= SITEURL ?>/logo.png" />
+<?php } ?>
+    <meta name="robots" content="max-image-preview:large" />
+    <meta name="description" content="<?= htmlspecialchars($out["desc"]) ?>" />
+<?php } ?>
     <?php if (isset($out["img"])) { ?><meta name="thumbnail" content="<?= $out["img"] ?>" /><?php } ?>
     <title>vixip 〜 <?= htmlspecialchars($out["title"]) ?></title>
     <link rel="stylesheet" type="text/css" href="/style.css" />

+ 12 - 0
www/artwork.php

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

+ 7 - 4
www/artworks/index.php

@@ -3,6 +3,7 @@
   require_once("../../include/lib.php");
   if (!isset($_GET["id"])) header("Location: /404.php");
   $id = (int)$_GET["id"];
+  $cur = "/artworks/?id=".$id;
   $res = get("illust/".$id);
   if (!isset($res->body)) {
     header("Location: /404.php");
@@ -13,7 +14,7 @@
     $com = get("illusts/comments/roots?illust_id=".$id);
   }
   $rec = get("illust/".$id."/recommend/init?limit=".$rpsize);
-  $out = ["title" => $res->alt, "desc" => $res->description];
+  $out = ["title" => $res->alt, "desc" => $res->description, "img_sec" => "artwork", "img_id" => $id];
   $icon = "";
   foreach ($res->userIllusts as $k => $v) {
     if (is_null($v)) continue;
@@ -24,9 +25,11 @@
 <?php include("../../include/header.php"); ?>
     <div style="text-align: center;">
 <?php for ($i = 0; $i < $res->pageCount; $i++) { ?>
-      <a href="<?= imgprx(str_replace("_p0", "_p".$i, $res->urls->original)) ?>">
-        <img src="<?= imgprx(str_replace("_p0_", "_p".$i."_", $res->urls->regular)) ?>" alt="<?= $res->illustTitle ?>" />
-      </a>
+      <p>
+        <a href="<?= imgprx(str_replace("_p0", "_p".$i, $res->urls->original)) ?>">
+          <img src="<?= imgprx(str_replace("_p0_", "_p".$i."_", $res->urls->regular)) ?>" alt="<?= $res->illustTitle ?>" />
+        </a>
+      </p>
 <?php } ?>
     </div>
     <h1><?= $res->illustTitle ?></h1>

+ 1 - 0
www/index.php

@@ -2,6 +2,7 @@
   require_once("../api.php");
   require_once("../include/lib.php");
   $res = (array)get("top/illust");
+  $cur = "/";
   $out = ["title" => "トップ", "desc" => ""];
 ?>
 

BIN
www/logo.png


+ 7 - 0
www/proxy.php

@@ -1,11 +1,18 @@
 <?php
   require_once("../config.php");
   $url = htmlspecialchars($_GET["url"]);
+
+  // ファイル類
   $ext = explode(".", $url);
   $ext = $ext[array_key_last($ext)];
   if ($ext == "jpg") $ext = "jpeg";
 
+  // ファイル名
+  $fname = explode("/", $url);
+  $fname = $fname[array_key_last($fname)];
+
   header("Content-type: image/".$ext);
+  header("Content-Disposition: filename=\"".$fname."\"");
 
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL, "https://".$url);

+ 1 - 0
www/search/index.php

@@ -6,6 +6,7 @@
     header("Location: /");
     die();
   }
+  $cur = "/search/?q=".$q;
   $res = get("search/artworks/".$q);
   if ($res->error) die();
 

+ 2 - 2
www/users/illusts/index.php

@@ -3,6 +3,7 @@
   require_once("../../../include/lib.php");
   if (!isset($_GET["id"])) header("Location: /404.php");
   $id = (int)$_GET["id"];
+  $cur = "/users/illusts/?id=".$id;
   $page = isset($_GET["page"]) ? (int)$_GET["page"] : 1;
   if ($page < 1) $page = 1;
   $pagemax = 40;
@@ -16,7 +17,7 @@
   $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];
+  $out = ["title" => $top->extraData->meta->title, "desc" => $top->extraData->meta->description, "img_sec" => "userhead", "img_id" => $id];
 
   $index = 0;
   $illusts = count((array)$res->illusts);
@@ -60,7 +61,6 @@
   }
 
   unset($top);
-  $cur = "/users/illusts/?id=".$id;
   $sum = ceil($illusts/$pagemax);
   include("../../../include/pagination.php");
   include("../../../include/footer.php");

+ 2 - 1
www/users/index.php

@@ -2,6 +2,7 @@
   require_once("../../api.php");
   if (!isset($_GET["id"])) header("Location: /404.php");
   $id = (int)$_GET["id"];
+  $cur = "/users/?id=".$id;
   $res = get("user/".$id."/profile/all");
   if (!isset($res->body)) {
     header("Location: /404.php");
@@ -10,7 +11,7 @@
   $top = get("user/".$id."/profile/top");
   $res = $res->body;
   $top = $top->body;
-  $out = ["title" => $top->extraData->meta->title, "desc" => $top->extraData->meta->description];
+  $out = ["title" => $top->extraData->meta->title, "desc" => $top->extraData->meta->description, "img_sec" => "userhead", "img_id" => $id];
 ?>
 
 <?php