commit 6fc61a1d0830f23265460a330179ce1418399882 Author: テクニカル諏訪子 Date: Wed Mar 8 04:55:38 2023 +0900 最初コミット diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b74decb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/config.php diff --git a/README.md b/README.md new file mode 100644 index 0000000..e15059e --- /dev/null +++ b/README.md @@ -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 +``` diff --git a/config.example.php b/config.example.php new file mode 100644 index 0000000..f048352 --- /dev/null +++ b/config.example.php @@ -0,0 +1,3 @@ + diff --git a/srv/httpd.conf b/srv/httpd.conf new file mode 100644 index 0000000..ce3c92b --- /dev/null +++ b/srv/httpd.conf @@ -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 + } +} diff --git a/srv/nginx.conf b/srv/nginx.conf new file mode 100644 index 0000000..82e4930 --- /dev/null +++ b/srv/nginx.conf @@ -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; +} diff --git a/www/index.php b/www/index.php new file mode 100644 index 0000000..cdef118 --- /dev/null +++ b/www/index.php @@ -0,0 +1,104 @@ +(.*)<\/title>/", $str, $matches); + return $matches[1]; + } + + function getimg (string $str): string { + preg_match('//', $str, $matches); + return $matches[1]; + } + + function getdesc (string $str): string { + $res = preg_replace('/
(.*?)<\/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('/(.*?)
/s', "", $body); + $res = preg_replace('/(.*?)<\/html>/s', "", $res); + $res = preg_replace('/

(.*?)<\/p>/s', "", $res); + $res = preg_replace('/

    (.*?)<\/ul>/s', "", $res); + $res = preg_replace('/(.*?)<\/table>/s', "", $res); + $res = preg_replace('/
    (.*?)<\/div>/s', "", $res); + $res = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $res); + $res = str_replace("", "", $res); + $res = str_replace("", "", $res); + $res = preg_replace("//", "", $res); + $res = str_replace("