From 0d7c0a88797d5360cd97fc32a95aa3e20ef810e7 Mon Sep 17 00:00:00 2001 From: Daichimarukana Date: Sun, 8 Jun 2025 22:35:36 +0900 Subject: [PATCH] uwuzu v1.5.4 Combeny --- .well-known/webfinger/index.php | 2 - actor/index.php | 4 +- admin/addadmin.php | 19 +++++- admin/index.php | 20 ++++++- admin/setup_db_php.php | 19 +++++- admin/setup_uwuzu_db.php | 19 +++++- admin/success.php | 20 ++++++- api/me/index.php | 4 +- api/ueuse/get.php | 14 ++--- api/ueuse/index.php | 14 ++--- api/ueuse/mentions.php | 14 ++--- api/ueuse/replies.php | 14 ++--- api/ueuse/search.php | 14 ++--- api/users/index.php | 4 +- function/function.php | 49 ++++++++++++---- js/view_function.js | 100 +++++++++++++++++++++++++++----- server/uwuzuinfo.txt | 4 +- server/uwuzurelease.txt | 10 ++++ update.json | 41 ++++++++----- 19 files changed, 295 insertions(+), 90 deletions(-) diff --git a/.well-known/webfinger/index.php b/.well-known/webfinger/index.php index 1267e3b..cf2b2f1 100644 --- a/.well-known/webfinger/index.php +++ b/.well-known/webfinger/index.php @@ -12,8 +12,6 @@ if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ $domain = $_SERVER['HTTP_HOST']; - require('../../db.php'); - // データベースに接続 try { $option = array( diff --git a/actor/index.php b/actor/index.php index 5a633f1..e543141 100644 --- a/actor/index.php +++ b/actor/index.php @@ -77,13 +77,13 @@ if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ "icon" => array( "type" => "Image", "mediaType" => "image/".$icon_kakucho_ci."", - "url" => "https://".$domain."/".$userData["iconname"]."", + "url" => localcloudURLtoAPI(localcloudURL($userData["iconname"])), ), "image" => array( "type" => "Image", "mediaType" => "image/".$icon_kakucho_ci."", - "url" => "https://".$domain."/".$userData["headname"]."", + "url" => localcloudURLtoAPI(localcloudURL($userData["headname"])), ), /*"publicKey" => array( diff --git a/admin/addadmin.php b/admin/addadmin.php index 3605ef6..5db44f6 100644 --- a/admin/addadmin.php +++ b/admin/addadmin.php @@ -3,7 +3,6 @@ require('../db.php'); //関数呼び出し //- EXIF require('../function/function.php'); -blockedIP($_SERVER['REMOTE_ADDR']); if(file_exists("../settings_admin/plugin_settings/amazons3_settings.php")){ require_once '../settings_admin/plugin_settings/amazons3_settings.php'; if(AMS3_CHKS == "true"){ @@ -58,6 +57,24 @@ try { // 接続エラーのときエラー内容を取得する $error_message[] = $e->getMessage(); } +if(empty($error_message)){ + $stmt = $pdo->prepare(" + SELECT COUNT(*) + FROM information_schema.tables + WHERE table_schema = :schema AND table_name = :table + LIMIT 1 + "); + $stmt->execute([ + ':schema' => DB_NAME, + ':table' => "ipblock", + ]); + + $exists = $stmt->fetchColumn() > 0; + + if ($exists) { + blockedIP($_SERVER['REMOTE_ADDR']); + } +} $aduser = "yes"; diff --git a/admin/index.php b/admin/index.php index a57d229..e01627c 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1,7 +1,6 @@ getMessage(); } + + if(empty($error_message)){ + $stmt = $pdo->prepare(" + SELECT COUNT(*) + FROM information_schema.tables + WHERE table_schema = :schema AND table_name = :table + LIMIT 1 + "); + $stmt->execute([ + ':schema' => DB_NAME, + ':table' => "ipblock", + ]); + + $exists = $stmt->fetchColumn() > 0; + + if ($exists) { + blockedIP($_SERVER['REMOTE_ADDR']); + } + } $aduser = "yes"; diff --git a/admin/setup_db_php.php b/admin/setup_db_php.php index 0313aec..0a51a06 100644 --- a/admin/setup_db_php.php +++ b/admin/setup_db_php.php @@ -2,7 +2,6 @@ require('../db.php'); require("../function/function.php"); -blockedIP($_SERVER['REMOTE_ADDR']); $softwarefile = "../server/uwuzuinfo.txt"; $softwaredata = file_get_contents($softwarefile); @@ -50,6 +49,24 @@ if(!(empty(DB_NAME) && empty(DB_HOST) && empty(DB_USER) && empty(DB_PASS))){ // 接続エラーのときエラー内容を取得する $error_message[] = $e->getMessage(); } + if(empty($error_message)){ + $stmt = $pdo->prepare(" + SELECT COUNT(*) + FROM information_schema.tables + WHERE table_schema = :schema AND table_name = :table + LIMIT 1 + "); + $stmt->execute([ + ':schema' => DB_NAME, + ':table' => "ipblock", + ]); + + $exists = $stmt->fetchColumn() > 0; + + if ($exists) { + blockedIP($_SERVER['REMOTE_ADDR']); + } + } $aduser = "yes"; diff --git a/admin/setup_uwuzu_db.php b/admin/setup_uwuzu_db.php index d2a1f14..c455449 100644 --- a/admin/setup_uwuzu_db.php +++ b/admin/setup_uwuzu_db.php @@ -1,7 +1,6 @@ getMessage(); } + if(empty($error_message)){ + $stmt = $pdo->prepare(" + SELECT COUNT(*) + FROM information_schema.tables + WHERE table_schema = :schema AND table_name = :table + LIMIT 1 + "); + $stmt->execute([ + ':schema' => DB_NAME, + ':table' => "ipblock", + ]); + + $exists = $stmt->fetchColumn() > 0; + + if ($exists) { + blockedIP($_SERVER['REMOTE_ADDR']); + } + } $aduser = "yes"; diff --git a/admin/success.php b/admin/success.php index 82ccb9d..c0560b8 100644 --- a/admin/success.php +++ b/admin/success.php @@ -1,7 +1,6 @@ getMessage(); } +if(empty($error_message)){ + $stmt = $pdo->prepare(" + SELECT COUNT(*) + FROM information_schema.tables + WHERE table_schema = :schema AND table_name = :table + LIMIT 1 + "); + $stmt->execute([ + ':schema' => DB_NAME, + ':table' => "ipblock", + ]); + + $exists = $stmt->fetchColumn() > 0; + + if ($exists) { + blockedIP($_SERVER['REMOTE_ADDR']); + } +} + $aduser = "yes"; $options = array( diff --git a/api/me/index.php b/api/me/index.php index bba5adb..b203d6b 100644 --- a/api/me/index.php +++ b/api/me/index.php @@ -161,8 +161,8 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { 'username' => decode_yajirushi(htmlspecialchars_decode($userdata["username"])), 'userid' => decode_yajirushi(htmlspecialchars_decode($userdata["userid"])), 'profile' => decode_yajirushi(htmlspecialchars_decode($userdata["profile"])), - 'user_icon' => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userdata["iconname"])), - 'user_header' => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userdata["headname"])), + 'user_icon' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($userdata["iconname"])))), + 'user_header' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($userdata["headname"])))), 'registered_date' => decode_yajirushi(htmlspecialchars_decode($userdata["datetime"])), 'followee' => $followee, 'followee_cnt' => $userdata["follow_cnt"], diff --git a/api/ueuse/get.php b/api/ueuse/get.php index 52172bd..62b11ed 100644 --- a/api/ueuse/get.php +++ b/api/ueuse/get.php @@ -120,8 +120,8 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { $now_userdata = array( "username" => decode_yajirushi(htmlspecialchars_decode($userData['username'])), "userid" => decode_yajirushi(htmlspecialchars_decode($userData['userid'])), - "user_icon" => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userData['iconname'])), - "user_head" => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userData['headname'])), + "user_icon" => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($userData['iconname'])))), + "user_head" => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($userData['headname'])))), ); } @@ -136,11 +136,11 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { 'replyid' => decode_yajirushi(htmlspecialchars_decode($ueusedata["rpuniqid"])), 'text' => decode_yajirushi(htmlspecialchars_decode($ueusedata["ueuse"])), 'account' => $now_userdata, - 'photo1' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo1"]))), - 'photo2' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo2"]))), - 'photo3' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo3"]))), - 'photo4' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo4"]))), - 'video1' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["video1"]))), + 'photo1' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo1"])))), + 'photo2' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo2"])))), + 'photo3' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo3"])))), + 'photo4' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo4"])))), + 'video1' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["video1"])))), 'favorite' => $favorite, 'favorite_cnt' => decode_yajirushi(htmlspecialchars_decode($ueusedata["favorite_cnt"])), 'datetime' => decode_yajirushi(htmlspecialchars_decode($ueusedata["datetime"])), diff --git a/api/ueuse/index.php b/api/ueuse/index.php index 5c46c84..a811e55 100644 --- a/api/ueuse/index.php +++ b/api/ueuse/index.php @@ -134,8 +134,8 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { $now_userdata = array( "username" => decode_yajirushi(htmlspecialchars_decode($userData['username'])), "userid" => decode_yajirushi(htmlspecialchars_decode($userData['userid'])), - "user_icon" => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userData['iconname'])), - "user_head" => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userData['headname'])), + "user_icon" => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($userData['iconname'])))), + "user_head" => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($userData['headname'])))), ); } @@ -150,11 +150,11 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { 'replyid' => decode_yajirushi(htmlspecialchars_decode($ueusedata["rpuniqid"])), 'text' => decode_yajirushi(htmlspecialchars_decode($ueusedata["ueuse"])), 'account' => $now_userdata, - 'photo1' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo1"]))), - 'photo2' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo2"]))), - 'photo3' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo3"]))), - 'photo4' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo4"]))), - 'video1' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["video1"]))), + 'photo1' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo1"])))), + 'photo2' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo2"])))), + 'photo3' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo3"])))), + 'photo4' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo4"])))), + 'video1' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["video1"])))), 'favorite' => $favorite, 'favorite_cnt' => decode_yajirushi(htmlspecialchars_decode($ueusedata["favorite_cnt"])), 'datetime' => decode_yajirushi(htmlspecialchars_decode($ueusedata["datetime"])), diff --git a/api/ueuse/mentions.php b/api/ueuse/mentions.php index 71decf4..2f8fa88 100644 --- a/api/ueuse/mentions.php +++ b/api/ueuse/mentions.php @@ -132,8 +132,8 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { $now_userdata = array( "username" => decode_yajirushi(htmlspecialchars_decode($userData['username'])), "userid" => decode_yajirushi(htmlspecialchars_decode($userData['userid'])), - "user_icon" => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userData['iconname'])), - "user_head" => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userData['headname'])), + "user_icon" => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($userData['iconname'])))), + "user_head" => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($userData['headname'])))), ); } @@ -148,11 +148,11 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { 'replyid' => decode_yajirushi(htmlspecialchars_decode($ueusedata["rpuniqid"])), 'text' => decode_yajirushi(htmlspecialchars_decode($ueusedata["ueuse"])), 'account' => $now_userdata, - 'photo1' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo1"]))), - 'photo2' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo2"]))), - 'photo3' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo3"]))), - 'photo4' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo4"]))), - 'video1' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["video1"]))), + 'photo1' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo1"])))), + 'photo2' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo2"])))), + 'photo3' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo3"])))), + 'photo4' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo4"])))), + 'video1' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["video1"])))), 'favorite' => $favorite, 'favorite_cnt' => decode_yajirushi(htmlspecialchars_decode($ueusedata["favorite_cnt"])), 'datetime' => decode_yajirushi(htmlspecialchars_decode($ueusedata["datetime"])), diff --git a/api/ueuse/replies.php b/api/ueuse/replies.php index a9b15b0..c2a9669 100644 --- a/api/ueuse/replies.php +++ b/api/ueuse/replies.php @@ -143,8 +143,8 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { $now_userdata = array( "username" => decode_yajirushi(htmlspecialchars_decode($userData['username'])), "userid" => decode_yajirushi(htmlspecialchars_decode($userData['userid'])), - "user_icon" => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userData['iconname'])), - "user_head" => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userData['headname'])), + "user_icon" => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($userData['iconname'])))), + "user_head" => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($userData['headname'])))), ); } @@ -159,11 +159,11 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { 'replyid' => decode_yajirushi(htmlspecialchars_decode($ueusedata["rpuniqid"])), 'text' => decode_yajirushi(htmlspecialchars_decode($ueusedata["ueuse"])), 'account' => $now_userdata, - 'photo1' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo1"]))), - 'photo2' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo2"]))), - 'photo3' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo3"]))), - 'photo4' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo4"]))), - 'video1' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["video1"]))), + 'photo1' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo1"])))), + 'photo2' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo2"])))), + 'photo3' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo3"])))), + 'photo4' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo4"])))), + 'video1' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["video1"])))), 'favorite' => $favorite, 'favorite_cnt' => decode_yajirushi(htmlspecialchars_decode($ueusedata["favorite_cnt"])), 'datetime' => decode_yajirushi(htmlspecialchars_decode($ueusedata["datetime"])), diff --git a/api/ueuse/search.php b/api/ueuse/search.php index 22ffea4..0e8a2fb 100644 --- a/api/ueuse/search.php +++ b/api/ueuse/search.php @@ -146,8 +146,8 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { $now_userdata = array( "username" => decode_yajirushi(htmlspecialchars_decode($userData['username'])), "userid" => decode_yajirushi(htmlspecialchars_decode($userData['userid'])), - "user_icon" => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userData['iconname'])), - "user_head" => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userData['headname'])), + "user_icon" => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($userData['iconname'])))), + "user_head" => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($userData['headname'])))), ); } @@ -162,11 +162,11 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { 'replyid' => decode_yajirushi(htmlspecialchars_decode($ueusedata["rpuniqid"])), 'text' => decode_yajirushi(htmlspecialchars_decode($ueusedata["ueuse"])), 'account' => $now_userdata, - 'photo1' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo1"]))), - 'photo2' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo2"]))), - 'photo3' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo3"]))), - 'photo4' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["photo4"]))), - 'video1' => decode_yajirushi(htmlspecialchars_decode(str_replace('../', 'https://' . $_SERVER['HTTP_HOST'] . '/', $ueusedata["video1"]))), + 'photo1' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo1"])))), + 'photo2' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo2"])))), + 'photo3' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo3"])))), + 'photo4' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["photo4"])))), + 'video1' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($ueusedata["video1"])))), 'favorite' => $favorite, 'favorite_cnt' => decode_yajirushi(htmlspecialchars_decode($ueusedata["favorite_cnt"])), 'datetime' => decode_yajirushi(htmlspecialchars_decode($ueusedata["datetime"])), diff --git a/api/users/index.php b/api/users/index.php index 5d55c39..a8859fa 100644 --- a/api/users/index.php +++ b/api/users/index.php @@ -177,8 +177,8 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { 'username' => decode_yajirushi(htmlspecialchars_decode($userdata["username"])), 'userid' => decode_yajirushi(htmlspecialchars_decode($userdata["userid"])), 'profile' => decode_yajirushi(htmlspecialchars_decode($userdata["profile"])), - 'user_icon' => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userdata["iconname"])), - 'user_header' => decode_yajirushi(htmlspecialchars_decode("https://".$domain."/".$userdata["headname"])), + 'user_icon' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($userdata["iconname"])))), + 'user_header' => decode_yajirushi(htmlspecialchars_decode(localcloudURLtoAPI(localcloudURL($userdata["headname"])))), 'registered_date' => decode_yajirushi(htmlspecialchars_decode($userdata["datetime"])), 'followee' => $followee, 'followee_cnt' => $userdata["follow_cnt"], diff --git a/function/function.php b/function/function.php index d58827e..bad9237 100644 --- a/function/function.php +++ b/function/function.php @@ -634,7 +634,9 @@ function uploadAmazonS3($tmp_name){ function deleteAmazonS3($url){ $key = explode("/", mb_substr(parse_url($url, PHP_URL_PATH), 1)); - array_shift($key);//最初の一個を消す + if ($key[0] == AMS3_BUCKET_NM) { + array_shift($key); + } $key = implode("/", $key); $credentials = [ @@ -1778,17 +1780,17 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ } function delete_ueuse($uniqid, $userid, $account_id){ - if(file_exists("../settings_admin/plugin_settings/amazons3_settings.php")){ - require_once '../settings_admin/plugin_settings/amazons3_settings.php'; + if(file_exists(__DIR__ . "/../settings_admin/plugin_settings/amazons3_settings.php")){ + require_once __DIR__ . '/../settings_admin/plugin_settings/amazons3_settings.php'; if(AMS3_CHKS == "true"){ - if(file_exists("../plugin/aws/aws-autoloader.php")){ - require_once '../plugin/aws/aws-autoloader.php'; + if(file_exists(__DIR__ . "/../plugin/aws/aws-autoloader.php")){ + require_once __DIR__ . '/../plugin/aws/aws-autoloader.php'; }else{ - actionLog(null, "error", "uploadAmazonS3", null, "AWS SDK for PHPが見つかりませんでした!", 4); + actionLog(null, "error", "delete_ueuse", null, "AWS SDK for PHPが見つかりませんでした!", 4); } } }else{ - actionLog(null, "error", "uploadAmazonS3", null, "amazons3_settings.phpが見つかりませんでした!", 3); + actionLog(null, "error", "delete_ueuse", null, "amazons3_settings.phpが見つかりませんでした!", 3); } if (safetext(isset($uniqid)) && safetext(isset($userid)) && safetext(isset($account_id))){ @@ -2388,11 +2390,11 @@ function deleteUser($pdo, $userid, $step, $job_uniqid){ } if($step == "delete_account"){ - if(file_exists("../settings_admin/plugin_settings/amazons3_settings.php")){ - require_once '../settings_admin/plugin_settings/amazons3_settings.php'; + if(file_exists(__DIR__ . "/../settings_admin/plugin_settings/amazons3_settings.php")){ + require_once __DIR__ . '/../settings_admin/plugin_settings/amazons3_settings.php'; if(AMS3_CHKS == "true"){ - if(file_exists("../plugin/aws/aws-autoloader.php")){ - require_once '../plugin/aws/aws-autoloader.php'; + if(file_exists(__DIR__ . "/../plugin/aws/aws-autoloader.php")){ + require_once __DIR__ . '/../plugin/aws/aws-autoloader.php'; }else{ actionLog(null, "error", "uploadAmazonS3", null, "AWS SDK for PHPが見つかりませんでした!", 4); } @@ -2861,6 +2863,31 @@ function getJob($pdo, $userid){ } } +function localcloudURL($url){ + if(!($url == null || $url == "" || $url == "none")){ + if(filter_var($url, FILTER_VALIDATE_URL)){ + return $url; + }else{ + return "../" . $url; + } + }else{ + return null; + } +} + +function localcloudURLtoAPI($text){ + if(!($text == null || $text == "" || $text == "none")){ + $domain = $_SERVER['HTTP_HOST']; + $address = localcloudURL($text); + if(strpos($address, '../') !== false){ + $address = "https://".$domain."/".str_replace('../', '', $address); + } + return $address; + }else{ + return null; + } +} + function safetext($text){ // テキストの安全化 return htmlspecialchars(preg_replace('/[\x00-\x08\x0b\x0c\x0e-\x1f]/', '', $text), ENT_QUOTES, 'UTF-8', false); diff --git a/js/view_function.js b/js/view_function.js index c1aa0d8..8a6c34d 100644 --- a/js/view_function.js +++ b/js/view_function.js @@ -12,8 +12,24 @@ const mentionCache = {}; const fetchingMentions = false; async function replaceMentions(text) { + const placeholders = []; + let index = 0; + + text = text.replace(/]*>.*?<\/a>/gi, (match) => { + const placeholder = `\u2063{{PLACEHOLDER${index}}}\u2063`; + placeholders.push(match); + index++; + return placeholder; + }); + const mentionMatches = [...text.matchAll(/@([a-zA-Z0-9_]+)/g)]; - if (mentionMatches.length === 0) return text; + if (mentionMatches.length === 0) { + placeholders.forEach((original, i) => { + text = text.replace(`\u2063{{PLACEHOLDER${i}}}\u2063`, original); + }); + return text; + } + const uniqueMentions = [...new Set(mentionMatches.map(match => match[1]))]; const mentionsToFetch = uniqueMentions.filter(userID => !mentionCache[userID]); @@ -42,7 +58,6 @@ async function replaceMentions(text) { resolve(); }, error: function() { - // すべて失敗扱いでそのまま for (const name of mentionsToFetch) { mentionCache[name] = `@${name}`; } @@ -52,17 +67,48 @@ async function replaceMentions(text) { }); } - // 実際の置換 text = text.replace(/@([a-zA-Z0-9_]+)/g, (_, id) => mentionCache[id] || `@${id}`); + + placeholders.forEach((original, i) => { + text = text.replace(`\u2063{{PLACEHOLDER${i}}}\u2063`, original); + }); + return text; } -const emojiCache = {}; // 絵文字キャッシュ -const fetchingEmojis = {}; // 同時問い合わせ防止(Promiseキャッシュ) +const CACHE_KEY = 'emojiCache'; +const CACHE_EXPIRY_KEY = 'emojiCacheExpiry'; +const CACHE_LIFETIME_MS = 24 * 60 * 60 * 1000; // 24時間 + +let emojiCache = {}; +let fetchingEmojis = {}; + +(function loadEmojiCache() { + const savedCache = localStorage.getItem(CACHE_KEY); + const savedExpiry = localStorage.getItem(CACHE_EXPIRY_KEY); + + if (savedCache && savedExpiry && Date.now() < Number(savedExpiry)) { + try { + emojiCache = JSON.parse(savedCache); + } catch (e) { + localStorage.removeItem(CACHE_KEY); + localStorage.removeItem(CACHE_EXPIRY_KEY); + } + } else { + localStorage.removeItem(CACHE_KEY); + localStorage.removeItem(CACHE_EXPIRY_KEY); + } +})(); + +function saveEmojiCache() { + localStorage.setItem(CACHE_KEY, JSON.stringify(emojiCache)); + localStorage.setItem(CACHE_EXPIRY_KEY, (Date.now() + CACHE_LIFETIME_MS).toString()); +} async function replaceCustomEmojis(text) { const emojiMatches = [...text.matchAll(/:([a-zA-Z0-9_]+):/g)]; if (emojiMatches.length === 0) return text; + const uniqueEmojis = [...new Set(emojiMatches.map(match => match[1]))]; const emojisToFetch = uniqueEmojis.filter(name => !emojiCache[name] && !fetchingEmojis[name]); @@ -72,46 +118,61 @@ async function replaceCustomEmojis(text) { url: '../function/get_customemoji.php', method: 'POST', data: { - emoji: emojisToFetch.join(','), // カンマ区切りで送信 + emoji: emojisToFetch.join(','), userid: global_userid, account_id: global_account_id }, dataType: 'json', timeout: 30000, - success: function(response) { + success: function (response) { if (response.success && response.emojis) { for (const name of emojisToFetch) { - if (response.emojis[name]) { - const emoji = response.emojis[name]; - emojiCache[name] = `:${emoji.emojiname}:`; - } else { - emojiCache[name] = `:${name}:`; // 存在しない場合は元のまま + if (response.success && response.emojis) { + for (const name of emojisToFetch) { + if (response.emojis[name]) { + const emoji = response.emojis[name]; + emojiCache[name] = emoji.emojipath; + } else { + emojiCache[name] = null; + } + } } } } else { for (const name of emojisToFetch) { - emojiCache[name] = `:${name}:`; + emojiCache[name] = null; } } + saveEmojiCache(); resolve(); }, - error: function() { + error: function () { for (const name of emojisToFetch) { - emojiCache[name] = `:${name}:`; + emojiCache[name] = null; } + saveEmojiCache(); resolve(); } }); }); + emojisToFetch.forEach(name => { fetchingEmojis[name] = fetchPromise; }); await fetchPromise; } + await Promise.all(uniqueEmojis.map(name => fetchingEmojis[name])); - text = text.replace(/:([a-zA-Z0-9_]+):/g, (_, name) => emojiCache[name] || `:${name}:`); + text = text.replace(/:([a-zA-Z0-9_]+):/g, (_, name) => { + const url = emojiCache[name]; + if (url === undefined) return `:${name}:`; // 未取得 + if (url === null) return `:${name}:`; // 存在しない + + return `:${name}:`; // ここで生成 + }); + return text; } @@ -153,6 +214,13 @@ function formatMarkdown(text) { const placeholders = {}; let placeholderIndex = 0; + // URLをプレースホルダーに退避 + text = text.replace(/]*>[\s\S]*?<\/a>/g, (match) => { + const key = `\u2063{{PLACEHOLDER${placeholderIndex++}}}\u2063`; + placeholders[key] = match; // 元の文字列を保存 + return key; + }); + // 複数行インラインコード(バッククォート3つ)を検出して、
で囲む
     text = text.replace(/```([\s\S]+?)```/g, (match, code) => {
         const key = `\u2063{{PLACEHOLDER${placeholderIndex++}}}\u2063`;
diff --git a/server/uwuzuinfo.txt b/server/uwuzuinfo.txt
index 3f584cd..5ec6b55 100644
--- a/server/uwuzuinfo.txt
+++ b/server/uwuzuinfo.txt
@@ -1,4 +1,4 @@
 uwuzu
-1.5.3
-2025/05/12
+1.5.4
+2025/06/08
 daichimarukana,putonfps
\ No newline at end of file
diff --git a/server/uwuzurelease.txt b/server/uwuzurelease.txt
index c57bd07..153fcaa 100644
--- a/server/uwuzurelease.txt
+++ b/server/uwuzurelease.txt
@@ -1,6 +1,16 @@
 ## リリースノートだぜぇぇぇぇぇぇい!!!!!!!
 ここにはuwuzuの更新情報を載せてくぜぇ~!(いやまてテンションおかしいだろ...)
 
+## Version 1.5.4 (Combeny)
+2025/06/08
+fix: uwuzuのセットアップ時にエラーが発生して進めなくなる問題を修正しました。
+fix: @useridの含まれるURLの表示がおかしくなってしまう問題を修正しました。
+fix: オブジェクトストレージにアップロードされたファイルが正常に削除されていないのにもかかわらず削除された判定となってしまっている可能性のある問題を修正しました。
+fix: API・ActivityPub用エンドポイントで、オブジェクトストレージを使用してアップロードされたファイルのURLが正常に返されない問題を修正しました。
+fix: URL内にアンダーバーが含まれていると、正常にハイパーリンク化されない問題を修正しました。
+chg: 絵文字の読み込みを初めの一回以降省略することでタイムラインの読み込みを高速化しました!
+    なお、絵文字の削除等で正常に絵文字が表示されなくなった場合はその他ページよりキャッシュクリアをしてください。
+
 ## Version 1.5.3 (Combeny)
 2025/05/12
 fix: ユーズに何も引用などしていない通常のリユーズがある場合にユーズを削除しようとした場合にエラーが発生する恐れのある問題を修正しました!
diff --git a/update.json b/update.json
index 9b80f3f..3375da1 100644
--- a/update.json
+++ b/update.json
@@ -1,22 +1,37 @@
 {
     "software": "uwuzu",
-    "version": "1.5.3",
-    "release_date": "2025/05/12",
-    "release_notes": "このアップデートにはアカウント削除に失敗する問題の修正や、ユーズのMarkdownの解析に失敗する問題の修正が含まれます!詳細はリリースノートをご覧ください。",
+    "version": "1.5.4",
+    "release_date": "2025/06/08",
+    "release_notes": "このアップデートにはユーズのMarkdownの解析に失敗する問題の修正やuwuzuのセットアップが行えなくなってしまう問題の修正が含まれます!詳細はリリースノートをご覧ください。",
     "notices": "アップデート前にデータのバックアップを行うことをおすすめします!\nまた、アップデート後はキャッシュクリアをお忘れなく!",
     "files": {
         "overwrite": [
-            "/js/view_function.js",
+            "/.well-known/webfinger/index.php",
+            "/actor/index.php",
+            "/admin/addadmin.php",
+            "/admin/index.php",
+            "/admin/setup_db_php.php",
+            "/admin/setup_uwuzu_db.php",
+            "/admin/success.php",
+            "/api/favorite/change.php",
+            "/api/favorite/get.php",
+            "/api/me/index.php",
+            "/api/ueuse/create.php",
+            "/api/ueuse/delete.php",
+            "/api/ueuse/get.php",
+            "/api/ueuse/index.php",
+            "/api/ueuse/mentions.php",
+            "/api/ueuse/replies.php",
+            "/api/ueuse/search.php",
+            "/api/users/follow.php",
+            "/api/users/index.php",
+            "/api/users/unfollow.php",
             "/function/function.php",
-            "/addauthcode.php",
-            "/authcodechk.php",
-            "/authlogin.php",
-            "/check.php",
-            "/index.php",
-            "/login.php",
-            "/new_select.php",
-            "/new.php",
-            "/success.php",
+            "/js/nsfw_event.js",
+            "/js/unsupported.js",
+            "/js/view_function.js",
+            "/others/cache_clear.php",
+            "/others/index.php",
 
             "/server/uwuzuabout.txt",
             "/server/uwuzuinfo.txt",