最初コミット
このコミットが含まれているのは:
コミット
6fc61a1d08
|
@ -0,0 +1 @@
|
|||
/config.php
|
|
@ -0,0 +1,39 @@
|
|||
# spliti
|
||||
|
||||
mixi向けプライバシーUI。
|
||||
|
||||
## 設置方法
|
||||
|
||||
### すべてのOS
|
||||
|
||||
```sh
|
||||
$domain="example.com"
|
||||
cd /var/www/htdocs
|
||||
git clone https://gitler.moe/TechnicalSuwako/spliti.git && cd spliti
|
||||
mv config.example.php config.php
|
||||
find . -type f -name "/etc/nginx/sites-enabled/spliti.conf" -exec sed -i 's/spliti.076.moe/$domain/g'
|
||||
```
|
||||
|
||||
### Linux
|
||||
|
||||
```sh
|
||||
cp srv/nginx.conf /etc/nginx/sites-enabled/spliti.conf
|
||||
find . -type f -name "/etc/nginx/sites-enabled/spliti.conf" -exec sed -i 's/ドメイン名/$domain/g'
|
||||
/etc/init.d/nginx restart
|
||||
```
|
||||
|
||||
### FreeBSD
|
||||
|
||||
```sh
|
||||
cp srv/nginx.conf /usr/local/etc/nginx/sites-enabled/spliti.conf
|
||||
find . -type f -name "/usr/local/etc/nginx/sites-enabled/spliti.conf" -exec sed -i 's/ドメイン名/$domain/g'
|
||||
service nginx restart
|
||||
```
|
||||
|
||||
### OpenBSD
|
||||
|
||||
```sh
|
||||
cat /etc/httpd.conf srv/httpd.conf > /etc/httpd.conf
|
||||
find . -type f -name "/etc/httpd.conf" -exec sed -i 's/ドメイン名/$domain/g'
|
||||
rcctl restart httpd
|
||||
```
|
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
define("DOMAIN", "https://spliti.076.moe");
|
||||
?>
|
|
@ -0,0 +1,27 @@
|
|||
|
||||
server "ドメイン名" {
|
||||
listen on * port 80
|
||||
location "/.well-known/acme-challenge/*" {
|
||||
root "/acme"
|
||||
request strip 2
|
||||
}
|
||||
block return 301 "https://$SERVER_NAME$REQUEST_URI"
|
||||
}
|
||||
|
||||
server "ドメイン名" {
|
||||
listen on * tls port 443
|
||||
root "/htdocs/ドメイン名/www"
|
||||
directory index "index.php"
|
||||
tls {
|
||||
certificate "/etc/ssl/ドメイン名.fullchain.pem"
|
||||
key "/etc/ssl/private/ドメイン名.key"
|
||||
}
|
||||
connection { max requests 500, timeout 3600 }
|
||||
location "/*" {
|
||||
fastcgi socket "/run/php-fpm.sock"
|
||||
}
|
||||
location "/.well-known/acme-challenge/*" {
|
||||
root "/acme"
|
||||
request strip 2
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
server {
|
||||
server_name ドメイン名;
|
||||
root /var/www/htdocs/www;
|
||||
index index.php;
|
||||
|
||||
location / {
|
||||
satisfy any;
|
||||
allow all;
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
try_files $uri =404;
|
||||
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
|
||||
listen 443 ssl http2;
|
||||
ssl_certificate /etc/letsencrypt/live/ドメイン名/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/ドメイン名/privkey.pem;
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
}
|
||||
|
||||
server {
|
||||
if ($host = ドメイン名) { return 301 https://$host$request_uri; }
|
||||
|
||||
listen 80;
|
||||
server_name ドメイン名;
|
||||
|
||||
return 404;
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
include("../config.php");
|
||||
|
||||
/* ページのタイトル */
|
||||
function gettitle (string $str): string {
|
||||
preg_match("/<title>(.*)<\/title>/", $str, $matches);
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
function getimg (string $str): string {
|
||||
preg_match('/<img class="NEWS_tempPhoto__picture" src="(.*)" alt="">/', $str, $matches);
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
function getdesc (string $str): string {
|
||||
$res = preg_replace('/<div class="newsArticle">(.*?)<\/div>/s', "", $str);
|
||||
return strip_tags($res);
|
||||
}
|
||||
|
||||
/* 記事かの確認 */
|
||||
function isarticle (string $url): bool {
|
||||
$chk = explode("=", $url);
|
||||
if (isset($chk[0]) && $chk[0] == "view_news.pl?id" && isset($chk[1]) && isset($chk[2])) {
|
||||
$chk2 = explode("&", $chk[1]);
|
||||
if (isset($chk2[1]) && $chk2[1] == "media_id") return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* 記事だけが残るまで消す */
|
||||
function rmbloat (string $body): string {
|
||||
$res = preg_replace('/<!DOCTYPE html>(.*?)<div class="newsArticle">/s', "", $body);
|
||||
$res = preg_replace('/<!--\/newsArticle-->(.*?)<\/html>/s', "", $res);
|
||||
$res = preg_replace('/<p class="reactions">(.*?)<\/p>/s', "", $res);
|
||||
$res = preg_replace('/<ul class="diaryUtility\d*">(.*?)<\/ul>/s', "", $res);
|
||||
$res = preg_replace('/<table>(.*?)<\/table>/s', "", $res);
|
||||
$res = preg_replace('/<div class="adsense0(.*?)<\/div>/s', "", $res);
|
||||
$res = preg_replace('/<div class="adsense(.*?)<\/div>/s', "", $res);
|
||||
$res = preg_replace('/<div class="subInfo">(.*?)<\/div>/s', "", $res);
|
||||
$res = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $res);
|
||||
$res = str_replace("<!--article_image-->", "", $res);
|
||||
$res = str_replace("<!--/article_image-->", "", $res);
|
||||
$res = preg_replace("/<!--(.*)-->/", "", $res);
|
||||
$res = str_replace("<!--", "", $res);
|
||||
return trim("<div class=\"newsArticle\">\n".trim($res))."\n </div>\n";
|
||||
}
|
||||
|
||||
/* 記事の受取 */
|
||||
function get (string $url = ""): array {
|
||||
$res = [];
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, "https://news.mixi.jp/".$url);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
"HTTP/1.0",
|
||||
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
||||
"Accept-Language: en-US,en;q=0.5",
|
||||
"Connection: keep-alive",
|
||||
"User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0"
|
||||
]);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
$body = mb_convert_encoding(curl_exec($ch), "UTF-8", "EUC-JP");
|
||||
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
if ($body && $httpCode == 200) {
|
||||
$res["status"] = $httpCode;
|
||||
if ($url == "") $res["page"] = "front";
|
||||
else $res["page"] = "news";
|
||||
$res["title"] = gettitle($body);
|
||||
$res["content"] = rmbloat($body);
|
||||
$res["img"] = getimg($body);
|
||||
$res["desc"] = getdesc($res["content"]);
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
// URLを受け取って、mixiにわかれるURLに変更
|
||||
$gurl = str_replace("/?url=", "", htmlspecialchars($_SERVER["REQUEST_URI"]));
|
||||
|
||||
// デフォルト=エラー
|
||||
$out = ["status" => 404, "page" => "notfound", "title" => "見つけられない", "content" => '<div class="newsArticle"><div class="articleHeading02"><div class="headingArea"><h1>見つけられなかった</h1></div></div><div class="contents clearfix"><div class="article decoratable"><p>ごめんね!</p></div></div>', "img" => ""];
|
||||
|
||||
// $gurlは「/」だったら、トップページを表示する。記事だったら、記事を表示する。
|
||||
if ($gurl == "/") $out = ["status" => 200, "page" => "front", "title" => "トップページ", "content" => '<div class="newsArticle"><div class="articleHeading02"><div class="headingArea"><h1>使い方</h1></div></div><div class="contents clearfix"><div class="article decoratable"><p><code>https://news.mixi.jp/view_news.pl?id=********&media_id=***</code>→<code>'.DOMAIN.'/?url=view_news.pl?id=********&media_id=***</code><br />例えば:<code>https://news.mixi.jp/view_news.pl?id=7327623&media_id=4</code>→<code>'.DOMAIN.'/?url=view_news.pl?id=7327047&media_id=262</code></p></div></div>', "img" => ""];
|
||||
else if (isarticle($gurl)) $out = get($gurl);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<meta content="text/html; charset=euc-jp" http-equiv="content-type" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta property="og:title" content="<?= $out["title"] ?>" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:description" content="<?= $out["title"] ?>" />
|
||||
<meta property="og:url" content="<?= $gurl ?>" />
|
||||
<meta name="thumbnail" content="<?= $out["img"] ?>" />
|
||||
<title>spliti 〜 <?= $out["title"] ?></title>
|
||||
<link rel="stylesheet" type="text/css" href="/style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<?= $out["content"] ?>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,59 @@
|
|||
html {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #232629;
|
||||
color: #fcfcfc;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #ea5fea;
|
||||
}
|
||||
|
||||
h2 {
|
||||
clear: left;
|
||||
line-height: 1.5;
|
||||
margin: 15px 0 10px;
|
||||
padding: 0 0 0 15px;
|
||||
border-left: 6px solid #f976de;
|
||||
font-weight: bold;
|
||||
font-size: 166%;
|
||||
}
|
||||
|
||||
code {
|
||||
background: #e68be6;
|
||||
padding: 1px;
|
||||
border-radius: 4px;
|
||||
border: 1px #fcfcfc solid;
|
||||
margin: 4px;
|
||||
color: #232629;
|
||||
line-height: 2.5;
|
||||
}
|
||||
|
||||
.newsArticle {
|
||||
width: calc(100% - 20px);
|
||||
max-width: 1200px;
|
||||
background: #31363b;
|
||||
border: 2px solid #4d4d4d;
|
||||
border-radius: 10px;
|
||||
margin: auto;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.NEWS_tempPhoto {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.NEWS_tempPhoto__picture {
|
||||
max-width: 400px;
|
||||
max-height: 400px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.NEWS_tempPhoto__captionText {
|
||||
color: #ccc;
|
||||
text-align: center;
|
||||
font-size: 86%;
|
||||
}
|
読み込み中…
新しいイシューから参照