From 7fd6bcbc0588561885e4372095db5fee228895eb Mon Sep 17 00:00:00 2001 From: Daichimarukana Date: Fri, 27 Dec 2024 17:37:41 +0900 Subject: [PATCH] uwuzu v1.4.8 Funium --- admin/addadmin.php | 14 +- admin/index.php | 2 +- api/favorite/change.php | 127 +++++ api/favorite/get.php | 127 +++++ api/me/index.php | 8 +- api/migration-api.php | 8 +- api/serverinfo-api.php | 8 +- api/ueuse/create.php | 8 +- api/ueuse/delete.php | 8 +- api/ueuse/get.php | 8 +- api/ueuse/index.php | 8 +- api/ueuse/mentions.php | 8 +- api/ueuse/replies.php | 8 +- api/ueuse/search.php | 8 +- api/users/follow.php | 60 +-- api/users/index.php | 8 +- api/users/unfollow.php | 58 +- api/v1/instance.php | 8 +- authlogin.php | 16 +- bookmark/index.php | 16 +- check.php | 8 +- css/home.css | 139 ++++- emoji/index.php | 16 +- favorite/favorite.php | 60 +-- function/function.php | 494 +++++++++++++++++- home/index.php | 120 ++++- js/console_notice.js | 2 +- migration/index.php | 8 +- new.php | 13 +- nextpage/bookmark.php | 3 + nextpage/emojiview.php | 3 + nextpage/foryoupage.php | 315 +++++++++++ nextpage/ftlpage.php | 3 + nextpage/nextpage.php | 3 + nextpage/notification.php | 3 + nextpage/searchpage.php | 19 +- nextpage/ueusepage.php | 3 + nextpage/userlikepage.php | 3 + nextpage/usermediapage.php | 3 + nextpage/userpage.php | 3 + nodeinfo/2.1/index.php | 10 +- notice/addnotice.php | 16 +- notice/index.php | 16 +- notification/index.php | 16 +- others/account_migration.php | 17 +- others/account_migration_done.php | 16 +- others/index.php | 18 +- others/token.php | 16 +- passrecovery/startrecovery.php | 81 +-- require/noscript_modal.php | 2 +- require/tutorial.php | 3 +- search/index.php | 48 +- server/uwuzuinfo.txt | 4 +- server/uwuzurelease.txt | 34 ++ settings/addauthcode.php | 16 +- settings/index.php | 24 +- settings/success.php | 16 +- settings_admin/actionlog_admin.php | 347 ++++++++++++ settings_admin/ad_admin.php | 16 +- settings_admin/addemoji_admin.php | 18 +- settings_admin/api/update_query.php | 2 +- settings_admin/codeadmin.php | 16 +- settings_admin/customize_admin.php | 16 +- settings_admin/maintenance_admin.php | 16 +- settings_admin/moderation_admin.php | 16 +- settings_admin/overview_admin.php | 16 +- settings_admin/plugin_admin.php | 16 +- .../plugin_settings/phpmailer_settings.php | 14 +- settings_admin/role_admin.php | 16 +- settings_admin/serveradmin.php | 16 +- settings_admin/settings_left_menu.php | 1 + settings_admin/update_admin.php | 16 +- settings_admin/useradmin.php | 16 +- settings_admin/userinfo.php | 27 +- ueuse/index.php | 16 +- unsupported.php | 2 +- update.json | 86 ++- user/index.php | 210 ++------ user/report.php | 26 +- user/success.php | 16 +- uwuzu_database.sql | 32 +- uwuzu_error_code.txt | 1 + 82 files changed, 2267 insertions(+), 797 deletions(-) create mode 100644 api/favorite/change.php create mode 100644 api/favorite/get.php create mode 100644 nextpage/foryoupage.php create mode 100644 settings_admin/actionlog_admin.php diff --git a/admin/addadmin.php b/admin/addadmin.php index c6a45e4..76a649a 100644 --- a/admin/addadmin.php +++ b/admin/addadmin.php @@ -104,7 +104,7 @@ if( !empty($_POST['btn_submit']) ) { $localFilePathhead = '../img/deficon/icon.png'; // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename = uniqid() . '-'.$userid.'.png'; + $newFilename = createUniqId() . '-'.$userid.'.png'; // 保存先のパスを生成 $uploadedPath = 'usericons/' . $newFilename; @@ -142,10 +142,10 @@ if( !empty($_POST['btn_submit']) ) { if(check_mime($uploadedFile['tmp_name']) == "image/webp"){ // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename = uniqid() . '-'.$userid.'.webp'; + $newFilename = createUniqId() . '-'.$userid.'.webp'; }else{ // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename = uniqid() . '-'.$userid.'.' . $extension; + $newFilename = createUniqId() . '-'.$userid.'.' . $extension; } // 保存先のパスを生成 $uploadedPath = 'usericons/' . $newFilename; @@ -178,7 +178,7 @@ if( !empty($_POST['btn_submit']) ) { $localFilePathhead = '../img/defhead/head.png'; // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename = uniqid() . '-'.$userid.'.png'; + $newFilename = createUniqId() . '-'.$userid.'.png'; // 保存先のパスを生成 $uploadedPath = 'userheads/' . $newFilename; @@ -314,6 +314,9 @@ if( !empty($_POST['btn_submit']) ) { $enc_mailadds = ""; } + $other_settings = []; + $other_settings_json = json_encode($other_settings); + try { $role = "official"; @@ -325,7 +328,7 @@ if( !empty($_POST['btn_submit']) ) { $loginid = hash('sha3-512', $LoginIdBytes); // SQL作成 - $stmt = $pdo->prepare("INSERT INTO account (username, userid, password, loginid, mailadds, profile, iconname, headname, role, datetime, admin, encryption_ivkey) VALUES (:username, :userid, :password, :loginid, :mailadds, :profile, :iconname, :headname, :role, :datetime, :admin ,:encryption_ivkey)"); + $stmt = $pdo->prepare("INSERT INTO account (username, userid, password, loginid, mailadds, profile, iconname, headname, role, datetime, admin, encryption_ivkey, other_settings) VALUES (:username, :userid, :password, :loginid, :mailadds, :profile, :iconname, :headname, :role, :datetime, :admin, :encryption_ivkey, :other_settings)"); // アイコン画像 $stmt->bindValue(':iconname', $iconName, PDO::PARAM_STR); @@ -342,6 +345,7 @@ if( !empty($_POST['btn_submit']) ) { $stmt->bindParam(':profile', $profile, PDO::PARAM_STR); $stmt->bindParam(':role', $role, PDO::PARAM_STR); $stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR); + $stmt->bindParam(':other_settings', $other_settings_json, PDO::PARAM_STR); $stmt->bindParam(':encryption_ivkey', $iv, PDO::PARAM_STR); diff --git a/admin/index.php b/admin/index.php index e253236..4c7e33e 100644 --- a/admin/index.php +++ b/admin/index.php @@ -167,7 +167,7 @@ $pdo = null; これらのデータをあなたが知っているのであれば早速セットアップを開始しましょう!

- セットアップ中にエラーに遭遇した場合はuwuzu.comを確認し、解消に向けて取り組みましょう!

+ セットアップ中にエラーに遭遇した場合はdocs.uwuzu.xyzを確認し、解消に向けて取り組みましょう!

Already setが設定済みでNot setが未設定です。
diff --git a/api/favorite/change.php b/api/favorite/change.php new file mode 100644 index 0000000..9641b57 --- /dev/null +++ b/api/favorite/change.php @@ -0,0 +1,127 @@ + PDO::ERRMODE_EXCEPTION, + PDO::MYSQL_ATTR_MULTI_STATEMENTS => false + ); + $pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); +} catch(PDOException $e) { + // 接続エラーのときエラー内容を取得する + $error_message[] = $e->getMessage(); +} + +$Get_Post_Json = file_get_contents("php://input"); +if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { + //トークン取得 + if(!(empty($_GET['token']))){ + $token = safetext($_GET['token']); + }else{ + $post_json = json_decode($Get_Post_Json, true); + if(isset($post_json["token"])){ + $token = safetext($post_json["token"]); + }else{ + $err = "input_not_found"; + $response = array( + 'error_code' => $err, + ); + echo json_encode($response, JSON_UNESCAPED_UNICODE); + exit; + } + } + if($token == ""){ + $err = "input_not_found"; + $response = array( + 'error_code' => $err, + ); + echo json_encode($response, JSON_UNESCAPED_UNICODE); + exit; + } + + session_start(); + + if( !empty($pdo) ) { + $userQuery = $pdo->prepare("SELECT username, userid, role, follow, follower FROM account WHERE token = :token"); + $userQuery->bindValue(':token', $token); + $userQuery->execute(); + $userData = $userQuery->fetch(); + + if(empty($userData["userid"])){ + $err = "token_invalid"; + $response = array( + 'error_code' => $err, + ); + echo json_encode($response, JSON_UNESCAPED_UNICODE); + exit; + }elseif($userData["role"] === "ice"){ + $err = "this_account_has_been_frozen"; + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); + exit; + }else{ + //本文取得 + if(!(empty($_GET['uniqid']))){ + $fav_uniqid = safetext($_GET['uniqid']); + }elseif(!(empty($post_json["uniqid"]))){ + $fav_uniqid = safetext($post_json["uniqid"]); + } + + if(!(empty($fav_uniqid))){ + $res = addFavorite($pdo, $fav_uniqid, $userData["userid"]); + if($res[0] === true){ + $response = array( + 'favorite_list' => decode_yajirushi(htmlspecialchars_decode($res[2])), + 'success' => true + ); + echo json_encode($response, JSON_UNESCAPED_UNICODE); + }else{ + $err = "input_not_found"; + $response = array( + 'error_code' => $err, + ); + echo json_encode($response, JSON_UNESCAPED_UNICODE); + } + }else{ + $err = "input_not_found"; + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); + } + } + } +}else{ + $err = "input_not_found"; + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); +} +?> \ No newline at end of file diff --git a/api/favorite/get.php b/api/favorite/get.php new file mode 100644 index 0000000..2666386 --- /dev/null +++ b/api/favorite/get.php @@ -0,0 +1,127 @@ + PDO::ERRMODE_EXCEPTION, + PDO::MYSQL_ATTR_MULTI_STATEMENTS => false + ); + $pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); +} catch(PDOException $e) { + // 接続エラーのときエラー内容を取得する + $error_message[] = $e->getMessage(); +} + +$Get_Post_Json = file_get_contents("php://input"); +if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { + //トークン取得 + if(!(empty($_GET['token']))){ + $token = safetext($_GET['token']); + }else{ + $post_json = json_decode($Get_Post_Json, true); + if(isset($post_json["token"])){ + $token = safetext($post_json["token"]); + }else{ + $err = "input_not_found"; + $response = array( + 'error_code' => $err, + ); + echo json_encode($response, JSON_UNESCAPED_UNICODE); + exit; + } + } + if($token == ""){ + $err = "input_not_found"; + $response = array( + 'error_code' => $err, + ); + echo json_encode($response, JSON_UNESCAPED_UNICODE); + exit; + } + + session_start(); + + if( !empty($pdo) ) { + $userQuery = $pdo->prepare("SELECT username, userid, role, follow, follower FROM account WHERE token = :token"); + $userQuery->bindValue(':token', $token); + $userQuery->execute(); + $userData = $userQuery->fetch(); + + if(empty($userData["userid"])){ + $err = "token_invalid"; + $response = array( + 'error_code' => $err, + ); + echo json_encode($response, JSON_UNESCAPED_UNICODE); + exit; + }elseif($userData["role"] === "ice"){ + $err = "this_account_has_been_frozen"; + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); + exit; + }else{ + //本文取得 + if(!(empty($_GET['uniqid']))){ + $fav_uniqid = safetext($_GET['uniqid']); + }elseif(!(empty($post_json["uniqid"]))){ + $fav_uniqid = safetext($post_json["uniqid"]); + } + + if(!(empty($fav_uniqid))){ + $res = getFavorite($pdo, $fav_uniqid); + if($res[0] === true){ + $response = array( + 'favorite_list' => decode_yajirushi(htmlspecialchars_decode($res[2])), + 'success' => true + ); + echo json_encode($response, JSON_UNESCAPED_UNICODE); + }else{ + $err = "input_not_found"; + $response = array( + 'error_code' => $err, + ); + echo json_encode($response, JSON_UNESCAPED_UNICODE); + } + }else{ + $err = "input_not_found"; + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); + } + } + } +}else{ + $err = "input_not_found"; + $response = array( + 'error_code' => $err, + ); + + echo json_encode($response, JSON_UNESCAPED_UNICODE); +} +?> \ No newline at end of file diff --git a/api/me/index.php b/api/me/index.php index 69f1ab0..7624b07 100644 --- a/api/me/index.php +++ b/api/me/index.php @@ -8,13 +8,7 @@ header("Content-Type: application/json"); header("charset=utf-8"); header("Access-Control-Allow-Origin: *"); -function decode_yajirushi($postText){ - $postText = str_replace('←', '←', $postText); - $postText = str_replace('↓', '↓', $postText); - $postText = str_replace('↑', '↑', $postText); - $postText = str_replace('→', '→', $postText); - return $postText; -} + $pdo = null; try { diff --git a/api/migration-api.php b/api/migration-api.php index 78cf11a..8ec61c1 100644 --- a/api/migration-api.php +++ b/api/migration-api.php @@ -4,13 +4,7 @@ header("Content-Type: application/json"); header("charset=utf-8"); header("Access-Control-Allow-Origin: *"); -function decode_yajirushi($postText){ - $postText = str_replace('←', '←', $postText); - $postText = str_replace('↓', '↓', $postText); - $postText = str_replace('↑', '↑', $postText); - $postText = str_replace('→', '→', $postText); - return $postText; -} + function random_iv($length = 16){ return substr(str_shuffle('1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'), 0, $length); } diff --git a/api/serverinfo-api.php b/api/serverinfo-api.php index 23a787f..0f125a1 100644 --- a/api/serverinfo-api.php +++ b/api/serverinfo-api.php @@ -24,13 +24,7 @@ for( $i=0;$i<$cnt;$i++ ){ $uwuzuinfo[$i] = ($softwaredata[$i]); } -function decode_yajirushi($postText){ - $postText = str_replace('←', '←', $postText); - $postText = str_replace('↓', '↓', $postText); - $postText = str_replace('↑', '↑', $postText); - $postText = str_replace('→', '→', $postText); - return $postText; -} + require('../db.php'); $datetime = array(); diff --git a/api/ueuse/create.php b/api/ueuse/create.php index ea95dd7..f8b85a6 100644 --- a/api/ueuse/create.php +++ b/api/ueuse/create.php @@ -18,13 +18,7 @@ header("Content-Type: application/json"); header("charset=utf-8"); header("Access-Control-Allow-Origin: *"); -function decode_yajirushi($postText){ - $postText = str_replace('←', '←', $postText); - $postText = str_replace('↓', '↓', $postText); - $postText = str_replace('↑', '↑', $postText); - $postText = str_replace('→', '→', $postText); - return $postText; -} + $pdo = null; try { diff --git a/api/ueuse/delete.php b/api/ueuse/delete.php index 34b7bf0..b464824 100644 --- a/api/ueuse/delete.php +++ b/api/ueuse/delete.php @@ -8,13 +8,7 @@ header("Content-Type: application/json"); header("charset=utf-8"); header("Access-Control-Allow-Origin: *"); -function decode_yajirushi($postText){ - $postText = str_replace('←', '←', $postText); - $postText = str_replace('↓', '↓', $postText); - $postText = str_replace('↑', '↑', $postText); - $postText = str_replace('→', '→', $postText); - return $postText; -} + $pdo = null; try { diff --git a/api/ueuse/get.php b/api/ueuse/get.php index ef5dcd4..b88c632 100644 --- a/api/ueuse/get.php +++ b/api/ueuse/get.php @@ -8,13 +8,7 @@ header("Content-Type: application/json"); header("charset=utf-8"); header("Access-Control-Allow-Origin: *"); -function decode_yajirushi($postText){ - $postText = str_replace('←', '←', $postText); - $postText = str_replace('↓', '↓', $postText); - $postText = str_replace('↑', '↑', $postText); - $postText = str_replace('→', '→', $postText); - return $postText; -} + $pdo = null; try { diff --git a/api/ueuse/index.php b/api/ueuse/index.php index 76abcf2..bf7f651 100644 --- a/api/ueuse/index.php +++ b/api/ueuse/index.php @@ -8,13 +8,7 @@ header("Content-Type: application/json"); header("charset=utf-8"); header("Access-Control-Allow-Origin: *"); -function decode_yajirushi($postText){ - $postText = str_replace('←', '←', $postText); - $postText = str_replace('↓', '↓', $postText); - $postText = str_replace('↑', '↑', $postText); - $postText = str_replace('→', '→', $postText); - return $postText; -} + $pdo = null; diff --git a/api/ueuse/mentions.php b/api/ueuse/mentions.php index 38e3072..afbc041 100644 --- a/api/ueuse/mentions.php +++ b/api/ueuse/mentions.php @@ -8,13 +8,7 @@ header("Content-Type: application/json"); header("charset=utf-8"); header("Access-Control-Allow-Origin: *"); -function decode_yajirushi($postText){ - $postText = str_replace('←', '←', $postText); - $postText = str_replace('↓', '↓', $postText); - $postText = str_replace('↑', '↑', $postText); - $postText = str_replace('→', '→', $postText); - return $postText; -} + $pdo = null; diff --git a/api/ueuse/replies.php b/api/ueuse/replies.php index 63435b6..c8bf595 100644 --- a/api/ueuse/replies.php +++ b/api/ueuse/replies.php @@ -8,13 +8,7 @@ header("Content-Type: application/json"); header("charset=utf-8"); header("Access-Control-Allow-Origin: *"); -function decode_yajirushi($postText){ - $postText = str_replace('←', '←', $postText); - $postText = str_replace('↓', '↓', $postText); - $postText = str_replace('↑', '↑', $postText); - $postText = str_replace('→', '→', $postText); - return $postText; -} + $pdo = null; diff --git a/api/ueuse/search.php b/api/ueuse/search.php index a803c2b..4fb6ee2 100644 --- a/api/ueuse/search.php +++ b/api/ueuse/search.php @@ -8,13 +8,7 @@ header("Content-Type: application/json"); header("charset=utf-8"); header("Access-Control-Allow-Origin: *"); -function decode_yajirushi($postText){ - $postText = str_replace('←', '←', $postText); - $postText = str_replace('↓', '↓', $postText); - $postText = str_replace('↑', '↑', $postText); - $postText = str_replace('→', '→', $postText); - return $postText; -} + $pdo = null; diff --git a/api/users/follow.php b/api/users/follow.php index b522917..79e0abe 100644 --- a/api/users/follow.php +++ b/api/users/follow.php @@ -18,13 +18,7 @@ header("Content-Type: application/json"); header("charset=utf-8"); header("Access-Control-Allow-Origin: *"); -function decode_yajirushi($postText){ - $postText = str_replace('←', '←', $postText); - $postText = str_replace('↓', '↓', $postText); - $postText = str_replace('↑', '↑', $postText); - $postText = str_replace('→', '→', $postText); - return $postText; -} + $pdo = null; @@ -107,50 +101,16 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { if(!(empty($Follow_userdata))){ if(!($userid == $Follow_userdata['userid'])){ - $followerList = explode(',', $Follow_userdata['follower']); - if (!(in_array($userid, $followerList))) { - // 自分が相手をフォローしていない場合、相手のfollowerカラムと自分のfollowカラムを更新 - $followerList[] = $userid; - $newFollowerList = implode(',', $followerList); - - // UPDATE文を実行してフォロー情報を更新 - $updateQuery = $pdo->prepare("UPDATE account SET follower = :follower WHERE userid = :userid"); - $updateQuery->bindValue(':follower', $newFollowerList, PDO::PARAM_STR); - $updateQuery->bindValue(':userid', $Follow_userdata['userid'], PDO::PARAM_STR); - $res = $updateQuery->execute(); - - // 自分のfollowカラムを更新 - $myflwlist = explode(',', $userData['follow']); - $myflwlist[] = $userData['userid']; - $newFollowList = implode(',', array_unique($myflwlist)); - - $updateQuery = $pdo->prepare("UPDATE account SET follow = :follow WHERE userid = :userid"); - $updateQuery->bindValue(':follow', $newFollowList, PDO::PARAM_STR); - $updateQuery->bindValue(':userid', $userid, PDO::PARAM_STR); - $res_follow = $updateQuery->execute(); - - $datetime = date("Y-m-d H:i:s"); - $pdo->beginTransaction(); - - send_notification($follow_userid, $userid, "🎉" . $userid . "さんにフォローされました!🎉", "" . $userid . "さんにフォローされました。", "/@" . $userid . "", "follow"); - - if ($res && $res_follow) { - //フォロー完了 - $response = array( - 'userid' => decode_yajirushi(htmlspecialchars_decode($Follow_userdata["userid"])), - 'success' => true - ); - echo json_encode($response, JSON_UNESCAPED_UNICODE); - } else { - $err = "db_error_".$e->getMessage(); - $response = array( - 'error_code' => $err, - ); - echo json_encode($response, JSON_UNESCAPED_UNICODE); - } - $stmt = null; + $res = follow_user($pdo, $Follow_userdata['userid'], $userid); + if($res === true){ + //フォロー完了 + $response = array( + 'userid' => decode_yajirushi(htmlspecialchars_decode($Follow_userdata["userid"])), + 'success' => true + ); + echo json_encode($response, JSON_UNESCAPED_UNICODE); }else{ - $err = "already_been_completed"; + $err = "could_not_complete"; $response = array( 'error_code' => $err, ); diff --git a/api/users/index.php b/api/users/index.php index bfd078e..fe6f398 100644 --- a/api/users/index.php +++ b/api/users/index.php @@ -8,13 +8,7 @@ header("Content-Type: application/json"); header("charset=utf-8"); header("Access-Control-Allow-Origin: *"); -function decode_yajirushi($postText){ - $postText = str_replace('←', '←', $postText); - $postText = str_replace('↓', '↓', $postText); - $postText = str_replace('↑', '↑', $postText); - $postText = str_replace('→', '→', $postText); - return $postText; -} + $pdo = null; diff --git a/api/users/unfollow.php b/api/users/unfollow.php index 39742c2..97efd93 100644 --- a/api/users/unfollow.php +++ b/api/users/unfollow.php @@ -18,13 +18,7 @@ header("Content-Type: application/json"); header("charset=utf-8"); header("Access-Control-Allow-Origin: *"); -function decode_yajirushi($postText){ - $postText = str_replace('←', '←', $postText); - $postText = str_replace('↓', '↓', $postText); - $postText = str_replace('↑', '↑', $postText); - $postText = str_replace('→', '→', $postText); - return $postText; -} + $pdo = null; @@ -108,52 +102,20 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { if(!(empty($Follow_userdata))){ if(!($userid == $Follow_userdata['userid'])){ - $followerList = explode(',', $Follow_userdata['follower']); - if (in_array($userid, $followerList)) { - // 自分が相手をフォローしている場合、相手のfollowerカラムと自分のfollowカラムを更新 - $followerList = array_diff($followerList, array($userid)); - $newFollowerList = implode(',', $followerList); - - // UPDATE文を実行してフォロー情報を更新 - $updateQuery = $pdo->prepare("UPDATE account SET follower = :follower WHERE userid = :userid"); - $updateQuery->bindValue(':follower', $newFollowerList, PDO::PARAM_STR); - $updateQuery->bindValue(':userid', $Follow_userdata['userid'], PDO::PARAM_STR); - $res = $updateQuery->execute(); - - $myflwlist = explode(',', $myfollowlist); - $delfollowList = array_diff($myflwlist, array($Follow_userdata['userid'])); - $deluserid = implode(',', $delfollowList); - - // 自分のfollowカラムから相手のユーザーIDを削除 - $updateQuery = $pdo->prepare("UPDATE account SET follow = :follow WHERE userid = :userid"); - $updateQuery->bindValue(':follow', $deluserid, PDO::PARAM_STR); - $updateQuery->bindValue(':userid', $userid, PDO::PARAM_STR); - $res_follow = $updateQuery->execute(); - - if ($res && $res_follow) { - $response = array( - 'userid' => decode_yajirushi(htmlspecialchars_decode($Follow_userdata["userid"])), - 'success' => true - ); - echo json_encode($response, JSON_UNESCAPED_UNICODE); - exit; - } else { - $err = "db_error_".$e->getMessage(); - $response = array( - 'error_code' => $err, - ); - echo json_encode($response, JSON_UNESCAPED_UNICODE); - exit; - } - - $stmt = null; + $res = follow_user($pdo, $Follow_userdata['userid'], $userid); + if($res === true){ + //フォロー完了 + $response = array( + 'userid' => decode_yajirushi(htmlspecialchars_decode($Follow_userdata["userid"])), + 'success' => true + ); + echo json_encode($response, JSON_UNESCAPED_UNICODE); }else{ - $err = "already_been_completed"; + $err = "could_not_complete"; $response = array( 'error_code' => $err, ); echo json_encode($response, JSON_UNESCAPED_UNICODE); - exit; } }else{ $err = "you_cant_it_to_yourself"; diff --git a/api/v1/instance.php b/api/v1/instance.php index 3262ab3..c8f699c 100644 --- a/api/v1/instance.php +++ b/api/v1/instance.php @@ -2,13 +2,7 @@ require("../../function/function.php"); $serversettings_file = "../../server/serversettings.ini"; $serversettings = parse_ini_file($serversettings_file, true); -function decode_yajirushi($postText){ - $postText = str_replace('←', '←', $postText); - $postText = str_replace('↓', '↓', $postText); - $postText = str_replace('↑', '↑', $postText); - $postText = str_replace('→', '→', $postText); - return $postText; -} + if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ header("Content-Type: application/json"); header("charset=utf-8"); diff --git a/authlogin.php b/authlogin.php index 620943e..a0bc939 100644 --- a/authlogin.php +++ b/authlogin.php @@ -181,28 +181,28 @@ if( !empty($_POST['btn_submit']) ) { } setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $row["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $row["username"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, @@ -293,28 +293,28 @@ if( !empty($_POST['btn_submit']) ) { } setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $row["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $row["username"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, diff --git a/bookmark/index.php b/bookmark/index.php index ebf8d9a..0574335 100644 --- a/bookmark/index.php +++ b/bookmark/index.php @@ -65,28 +65,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, @@ -121,28 +121,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, diff --git a/check.php b/check.php index 2ec0ada..6320414 100644 --- a/check.php +++ b/check.php @@ -193,28 +193,28 @@ if( !empty($_POST['btn_submit']) ) { } setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $userData["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, diff --git a/css/home.css b/css/home.css index db44ea8..ec3d99b 100644 --- a/css/home.css +++ b/css/home.css @@ -3270,7 +3270,12 @@ label>input { transform: translateY(-1%); } } - +.modal-content .modal-follow-area{ + max-height: 220px; + overflow: scroll; + border-radius: 10px; + margin-bottom: 16px; +} .Image_modal { display: none; position: fixed; @@ -4490,7 +4495,7 @@ hr{ display: flex; } .tlchange .btn{ - width: 45%; + width: 30%; line-height: 32px; margin-left: auto; margin-right: auto; @@ -5724,6 +5729,85 @@ noscript .noscript_modal .inner .center_text p{ font-weight: bold; } +.actionlog { + margin-top: 12px; + margin-bottom: 12px; + border-radius: 10px; + padding: 0px 12px; + background-color: var(--background-color); + border: 1px solid var(--border-color); + width: auto; + min-height: 32px; /* 閉じた状態での最小高さ */ + line-height: 32px; +} + +.actionlog details { + padding: 0px; + margin-top: 8px; + margin-bottom: 0px; + text-align: left; + color: var(--text-color); + font-family: var(--Mono-fonts), sans-serif; + word-wrap: break-word; + font-size: 18px; + font-weight: bold; +} +.actionlog details span { + margin: 0px 6px 0px 4px; + padding: 2px 6px; + border-radius: 32px; + font-family: var(--Mono-fonts), sans-serif; + font-weight: normal; + font-size: 16px; +} +.actionlog details .INFO { + background-color: color-mix(in srgb, var(--background-color) 90%, var(--success)); + border: solid 1px var(--success); + color: var(--success); +} +.actionlog details .NOTICE { + background-color: color-mix(in srgb, var(--background-color) 90%, var(--good)); + border: solid 1px var(--good); + color: var(--good); +} +.actionlog details .WARNING { + background-color: color-mix(in srgb, var(--background-color) 90%, var(--warn)); + border: solid 1px var(--warn); + color: var(--warn); +} +.actionlog details .ERROR { + background-color: color-mix(in srgb, var(--background-color) 90%, var(--danger)); + border: solid 1px var(--danger); + color: var(--danger); +} +.actionlog details .CRITICAL { + background-color: color-mix(in srgb, var(--background-color) 90%, var(--error)); + border: solid 1px var(--error); + color: var(--error); +} +.actionlog summary { + display: block; + list-style: none; + padding: 0px; + line-height: 32px; + overflow: hidden; +} +.actionlog summary::-webkit-details-marker { + display: none; +} +.actionlog p { + margin-top: 4px; + margin-bottom: 4px; + text-align: left; + color: var(--text-color); + font-family: var(--Mono-fonts), sans-serif; + word-wrap: break-word; + font-size: 14px; + line-height: 22px; + font-weight: normal; +} + + /*------------------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------スマホ向け--------------------------------------------------*/ /*--------------------------------------------------ここから--------------------------------------------------*/ @@ -6597,7 +6681,7 @@ noscript .noscript_modal .inner .center_text p{ overflow-wrap: break-word; margin-top: auto; margin-bottom: auto; - margin-left: -6px; + margin-left: 0px; font-size: 16px; color:var(--text-color); text-decoration: none; @@ -6609,7 +6693,7 @@ noscript .noscript_modal .inner .center_text p{ overflow-wrap: break-word; margin-top: 12px; margin-bottom: 6px; - margin-left: -6px; + margin-left: 0px; font-size: 18px; color:var(--text-color); text-decoration: none; @@ -6622,7 +6706,7 @@ noscript .noscript_modal .inner .center_text p{ margin-top: auto; margin-bottom: auto; margin-left: auto; - margin-right: -6px; + margin-right: 0px; text-align: right; font-size: 12px; color:var(--subtext-color); @@ -6677,7 +6761,7 @@ noscript .noscript_modal .inner .center_text p{ overflow-wrap: break-word; margin-top: auto; margin-bottom: auto; - margin-left: -6px; + margin-left: 0px; font-size: 16px; color:var(--text-color); text-decoration: none; @@ -6689,7 +6773,7 @@ noscript .noscript_modal .inner .center_text p{ overflow-wrap: break-word; margin-top: 12px; margin-bottom: 6px; - margin-left: -6px; + margin-left: 0px; font-size: 18px; color:var(--text-color); text-decoration: none; @@ -6702,7 +6786,7 @@ noscript .noscript_modal .inner .center_text p{ margin-top: auto; margin-bottom: auto; margin-left: auto; - margin-right: -6px; + margin-right: 0px; text-align: right; font-size: 12px; color:var(--subtext-color); @@ -6713,7 +6797,7 @@ noscript .noscript_modal .inner .center_text p{ overflow-wrap: break-word; margin-top: 32px; margin-bottom: auto; - margin-left: -6px; + margin-left: 0px; font-size: 16px; color:var(--link-color); text-decoration: none; @@ -6846,6 +6930,9 @@ noscript .noscript_modal .inner .center_text p{ transform: translateY(-1%); } } + .modal-content .modal-follow-area{ + max-height: 40dvh; + } .Image_modal{ -moz-box-sizing: border-box; box-sizing: border-box; @@ -6890,24 +6977,24 @@ noscript .noscript_modal .inner .center_text p{ display: flex; } .tlchange .off{ - width: 45%; + width: 30%; line-height: 24px; margin-left: auto; margin-right: auto; overflow-wrap: break-word; margin-top: 12px; margin-bottom: 12px; - font-size: 20px; + font-size: 24px; } .tlchange .on{ - width: 45%; + width: 30%; line-height: 24px; margin-left: auto; margin-right: auto; overflow-wrap: break-word; margin-top: 12px; margin-bottom: 12px; - font-size: 20px; + font-size: 24px; } .hny{ @@ -8224,4 +8311,30 @@ noscript .noscript_modal .inner .center_text p{ .emoji_admin p{ color:var(--dark-text-color); } + + .actionlog { + background-color: var(--dark-background-color); + border: solid 1px var(--dark-background-color); + } + .actionlog details { + color: var(--dark-text-color); + } + .actionlog details .INFO { + background-color: color-mix(in srgb, var(--dark-background-color) 90%, var(--success)); + } + .actionlog details .NOTICE { + background-color: color-mix(in srgb, var(--dark-background-color) 90%, var(--good)); + } + .actionlog details .WARNING { + background-color: color-mix(in srgb, var(--dark-background-color) 90%, var(--warn)); + } + .actionlog details .ERROR { + background-color: color-mix(in srgb, var(--dark-background-color) 90%, var(--danger)); + } + .actionlog details .CRITICAL { + background-color: color-mix(in srgb, var(--dark-background-color) 90%, var(--error)); + } + .actionlog p { + color: var(--dark-text-color); + } } \ No newline at end of file diff --git a/emoji/index.php b/emoji/index.php index 4cb4d11..70684ff 100644 --- a/emoji/index.php +++ b/emoji/index.php @@ -69,28 +69,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, @@ -125,28 +125,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, diff --git a/favorite/favorite.php b/favorite/favorite.php index e67cc2c..c2dfd80 100644 --- a/favorite/favorite.php +++ b/favorite/favorite.php @@ -19,66 +19,20 @@ if (safetext(isset($_POST['uniqid'])) && safetext(isset($_POST['userid'])) && sa } // データベース接続の設定 - $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST, DB_USER, DB_PASS, array( - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, - )); - - $query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); + $query = $pdo->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); $query->execute(array(':userid' => $userId)); $result2 = $query->fetch(); if($result2["loginid"] === $loginid){ + $res = addFavorite($pdo, $postUniqid, $userId); - try { - $pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS); - - // 投稿のいいね情報を取得 - $stmt = $pdo->prepare("SELECT account,ueuse,favorite FROM ueuse WHERE uniqid = :uniqid"); - $stmt->bindValue(':uniqid', $postUniqid, PDO::PARAM_STR); - $stmt->execute(); - $post = $stmt->fetch(PDO::FETCH_ASSOC); - - if (!(empty($post))) { - $favoriteList = explode(',', $post['favorite']); - $index = array_search($userId, $favoriteList); - - if ($index === false) { - // ユーザーIDを追加 - $favoriteList[] = $userId; - - send_notification(safetext($post['account']),$userId,"".$userId."さんがいいねしました!",safetext($post['ueuse']),"/!".$postUniqid."","favorite"); - - } else { - // ユーザーIDを削除 - array_splice($favoriteList, $index, 1); - } - - // 新しいいいね情報を更新 - $newFavorite = implode(',', $favoriteList); - $updateQuery = $pdo->prepare("UPDATE ueuse SET favorite = :favorite WHERE uniqid = :uniqid"); - $updateQuery->bindValue(':favorite', $newFavorite, PDO::PARAM_STR); - $updateQuery->bindValue(':uniqid', $postUniqid, PDO::PARAM_STR); - $res = $updateQuery->execute(); - - if ($res) { - echo json_encode(['success' => true, 'newFavorite' => $newFavorite]); - exit; - } else { - echo json_encode(['success' => false, 'error' => 'いいねの更新に失敗しました。']); - exit; - } - - - } else { - echo json_encode(['success' => false, 'error' => '投稿が見つかりません。']); - exit; - } - } catch(PDOException $e) { - echo json_encode(['success' => false, 'error' => 'データベースエラー:' . $e->getMessage()]); + if ($res[0] === true) { + echo json_encode(['success' => true, 'newFavorite' => $res[2]]); + exit; + } else { + echo json_encode(['success' => false, 'error' => 'いいねの更新に失敗しました。']); exit; } } diff --git a/function/function.php b/function/function.php index 9c0711b..0ff1cd5 100644 --- a/function/function.php +++ b/function/function.php @@ -131,7 +131,7 @@ function base64_mime($Base64,$userid){ delete_exif($extension, $temp_file); - $newFilename = uniqid() . '-' . $userid . '.' . $extension; + $newFilename = createUniqId() . '-' . $userid . '.' . $extension; $uploadedPath = '../ueuseimages/' . $newFilename; $result = copy($temp_file, "../".$uploadedPath); @@ -624,10 +624,11 @@ function send_notification($to,$from,$title,$message,$url,$category){ ); $pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); } catch(PDOException $e) { + actionLog($from, "error", "send_notification", $to, $e, 4); return false; } - if(!($to == $from)){ + if(!($to == $from) || $category === "system" || $category === "other"){ $query = $pdo->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); $query->execute(array(':userid' => $from)); $result = $query->fetch(); @@ -722,6 +723,7 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ ); $pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); } catch(PDOException $e) { + actionLog($userid, "error", "send_ueuse", null, $e, 4); return false; } @@ -780,7 +782,7 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ // アップロードされたファイルの拡張子を取得 $extension = pathinfo($uploadedFile['name'], PATHINFO_EXTENSION); // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename = uniqid() . '-'.$userid.'.' . $extension; + $newFilename = createUniqId() . '-'.$userid.'.' . $extension; // 保存先のパスを生成 $uploadedPath = '../ueuseimages/' . $newFilename; // EXIF削除 @@ -823,7 +825,7 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ // アップロードされたファイルの拡張子を取得 $extension2 = pathinfo($uploadedFile2['name'], PATHINFO_EXTENSION); // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename2 = uniqid() . '-'.$userid.'.' . $extension2; + $newFilename2 = createUniqId() . '-'.$userid.'.' . $extension2; // 保存先のパスを生成 $uploadedPath2 = '../ueuseimages/' . $newFilename2; // EXIF削除 @@ -865,7 +867,7 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ // アップロードされたファイルの拡張子を取得 $extension3 = pathinfo($uploadedFile3['name'], PATHINFO_EXTENSION); // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename3 = uniqid() . '-'.$userid.'.' . $extension3; + $newFilename3 = createUniqId() . '-'.$userid.'.' . $extension3; // 保存先のパスを生成 $uploadedPath3 = '../ueuseimages/' . $newFilename3; // EXIF削除 @@ -906,7 +908,7 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ // アップロードされたファイルの拡張子を取得 $extension4 = pathinfo($uploadedFile4['name'], PATHINFO_EXTENSION); // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename4 = uniqid() . '-'.$userid.'.' . $extension4; + $newFilename4 = createUniqId() . '-'.$userid.'.' . $extension4; // 保存先のパスを生成 $uploadedPath4 = '../ueuseimages/' . $newFilename4; // EXIF削除 @@ -945,7 +947,7 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ // アップロードされたファイルの拡張子を取得 $extensionVideo = strtolower(pathinfo($uploadedVideo['name'], PATHINFO_EXTENSION)); // 小文字に変換 // 正しい拡張子の場合、新しいファイル名を生成 - $newFilenameVideo = uniqid() . '-'.$userid.'.' . $extensionVideo; + $newFilenameVideo = createUniqId() . '-'.$userid.'.' . $extensionVideo; // 保存先のパスを生成 $uploadedPathVideo = '../ueusevideos/' . $newFilenameVideo; // ファイルを移動 @@ -1033,6 +1035,7 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ } catch(Exception $e) { // エラーが発生した時はロールバック $pdo->rollBack(); + actionLog($userid, "error", "send_ueuse", null, $e, 4); } }elseif((!empty($rpUniqid)) && empty($ruUniqid)){ $toUserIdQuery = $pdo->prepare("SELECT account FROM ueuse WHERE uniqid = :ueuseid ORDER BY datetime ASC LIMIT 1"); @@ -1086,6 +1089,7 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ } catch(Exception $e) { // エラーが発生した時はロールバック $pdo->rollBack(); + actionLog($userid, "error", "send_ueuse", null, $e, 4); } }elseif(empty($rpUniqid) && (!empty($ruUniqid))){ $toUserIdQuery = $pdo->prepare("SELECT account FROM ueuse WHERE uniqid = :ueuseid ORDER BY datetime ASC LIMIT 1"); @@ -1140,6 +1144,7 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ } catch(Exception $e) { // エラーが発生した時はロールバック $pdo->rollBack(); + actionLog($userid, "error", "send_ueuse", null, $e, 4); } } if( $res ) { @@ -1152,10 +1157,12 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ // プリペアドステートメントを削除 $stmt = null; }else{ + actionLog($userid, "error", "send_ueuse", null, $error_message, 0); return $error_message; } }else{ $error_message[] = "投稿回数のレート制限を超過しています。(OVER_RATE_LIMIT)"; + actionLog($userid, "error", "send_ueuse", null, $error_message, 0); return $error_message; } } @@ -1176,6 +1183,7 @@ function delete_ueuse($uniqid, $userid, $account_id){ } catch (PDOException $e) { // 接続エラーのときエラー内容を取得する $error_message[] = $e->getMessage(); + actionLog($userid, "error", "delete_ueuse", null, $e, 4); } $query = $pdo->prepare('SELECT * FROM ueuse WHERE uniqid = :uniqid limit 1'); @@ -1250,10 +1258,12 @@ function delete_ueuse($uniqid, $userid, $account_id){ if (!($res)){ $pdo->rollBack(); $error_message[] = "リユーズの削除ができませんでした。"; + actionLog($userid, "error", "delete_ueuse", null, $error_message, 3); } } catch(PDOException $e) { $pdo->rollBack(); $error_message[] = 'データベースエラー:' . $e->getMessage(); + actionLog($userid, "error", "delete_ueuse", null, $e, 4); } } @@ -1272,6 +1282,7 @@ function delete_ueuse($uniqid, $userid, $account_id){ } } catch(PDOException $e) { $pdo->rollBack(); + actionLog($userid, "error", "delete_ueuse", null, $e, 4); return [false, "削除に失敗しました!"]; } } @@ -1285,11 +1296,442 @@ function delete_ueuse($uniqid, $userid, $account_id){ return [true, "削除に成功しました!"]; } } +// SQL操作関数pdo引っ張ってくるように変更(あとでほかもする) +function follow_user($pdo, $to_userid, $userid){ + if (!(empty($pdo)) && !(empty($to_userid)) && !(empty($userid))){ + $myData = getUserData($pdo, $userid); + $userData = getUserData($pdo, $to_userid); + if (empty($myData) || empty($userData)) { + return false; + } + + $other_settings_me = is_OtherSettings($pdo, $userid); + $other_settings_user = is_OtherSettings($pdo, $to_userid); + if($other_settings_me === true && $other_settings_user === true){ + // トランザクションを開始 + $pdo->beginTransaction(); + try { + // フォローボタンが押された場合の処理 + $followerList = explode(',', $userData['follower']); + if (!(in_array($userid, $followerList))) { + // 自分が相手をフォローしていない場合、相手のfollowerカラムと自分のfollowカラムを更新 + $followerList[] = $userid; + $newFollowerList = implode(',', $followerList); + + // UPDATE文を実行してフォロー情報を更新 + $updateQuery = $pdo->prepare("UPDATE account SET follower = :follower WHERE userid = :userid"); + $updateQuery->bindValue(':follower', $newFollowerList, PDO::PARAM_STR); + $updateQuery->bindValue(':userid', $userData['userid'], PDO::PARAM_STR); + $res = $updateQuery->execute(); + + // 自分のfollowカラムを更新 + $myflwlist = explode(',', $myData["follow"]); + $myflwlist[] = $userData['userid']; + $newFollowList = implode(',', array_unique($myflwlist)); + + $updateQuery = $pdo->prepare("UPDATE account SET follow = :follow WHERE userid = :userid"); + $updateQuery->bindValue(':follow', $newFollowList, PDO::PARAM_STR); + $updateQuery->bindValue(':userid', $userid, PDO::PARAM_STR); + $res_follow = $updateQuery->execute(); + + send_notification($userData["userid"], $userid, "🎉" . $userid . "さんにフォローされました!🎉", "" . $userid . "さんにフォローされました。", "/@" . $userid . "", "follow"); + + if ($res && $res_follow) { + $pdo->commit(); + return true; + } else { + $pdo->rollBack(); + actionLog($userid, "error", "unfollow_user", $to_userid, "フォロー解除に失敗", 3); + return false; + } + }else{ + return true; + } + } catch (Exception $e) { + $pdo->rollBack(); + actionLog($userid, "error", "unfollow_user", $to_userid, $e, 4); + return false; + } + }else{ + return false; + } + }else{ + return false; + } +} +function unfollow_user($pdo, $to_userid, $userid){ + if (!(empty($pdo)) && !(empty($to_userid)) && !(empty($userid))){ + $myData = getUserData($pdo, $userid); + $userData = getUserData($pdo, $to_userid); + + if (empty($myData) || empty($userData)) { + return false; + } + + $other_settings_me = is_OtherSettings($pdo, $userid); + $other_settings_user = is_OtherSettings($pdo, $to_userid); + if($other_settings_me === true && $other_settings_user === true){ + // トランザクションを開始 + $pdo->beginTransaction(); + try { + // フォロー解除ボタンが押された場合の処理 + $followerList = explode(',', $userData['follower']); + if (in_array($userid, $followerList)) { + // 自分が相手をフォローしている場合、相手のfollowerカラムと自分のfollowカラムを更新 + $followerList = array_diff($followerList, array($userid)); + $newFollowerList = implode(',', $followerList); + + // UPDATE文を実行してフォロー情報を更新 + $updateQuery = $pdo->prepare("UPDATE account SET follower = :follower WHERE userid = :userid"); + $updateQuery->bindValue(':follower', $newFollowerList, PDO::PARAM_STR); + $updateQuery->bindValue(':userid', $userData['userid'], PDO::PARAM_STR); + $res = $updateQuery->execute(); + + $myflwlist = explode(',', $myData["follow"]); + $delfollowList = array_diff($myflwlist, array($userData['userid'])); + $deluserid = implode(',', $delfollowList); + + // 自分のfollowカラムから相手のユーザーIDを削除 + $updateQuery = $pdo->prepare("UPDATE account SET follow = :follow WHERE userid = :userid"); + $updateQuery->bindValue(':follow', $deluserid, PDO::PARAM_STR); + $updateQuery->bindValue(':userid', $userid, PDO::PARAM_STR); + $res_follow = $updateQuery->execute(); + + if ($res && $res_follow) { + // コミット + $pdo->commit(); + return true; + } else { + // ロールバック + $pdo->rollBack(); + actionLog($userid, "error", "unfollow_user", $to_userid, "フォロー解除に失敗", 3); + return false; + } + }else{ + return true; + } + } catch (Exception $e) { + // ロールバック + $pdo->rollBack(); + actionLog($userid, "error", "unfollow_user", $to_userid, $e, 4); + return false; + } + }else{ + return false; + } + }else{ + return false; + } +} +function block_user($pdo, $to_userid, $userid){ + if (!(empty($pdo)) && !(empty($to_userid)) && !(empty($userid))){ + $myData = getUserData($pdo, $userid); + $userData = getUserData($pdo, $to_userid); + + if (empty($myData) || empty($userData)) { + return false; + } + + $other_settings_me = is_OtherSettings($pdo, $userid); + $other_settings_user = is_OtherSettings($pdo, $to_userid); + if($other_settings_me === true && $other_settings_user === true){ + // トランザクションを開始 + $pdo->beginTransaction(); + try { + // フォロー解除ボタンが押された場合の処理 + $blockList = explode(',', $myData['blocklist']); + if (!(in_array($userData['userid'], $blockList))) { + $blockList[] = $userData['userid']; + $newBlockList = implode(',', array_unique($blockList)); + + // UPDATE文を実行してフォロー情報を更新 + $updateQuery = $pdo->prepare("UPDATE account SET blocklist = :blocklist WHERE userid = :userid"); + $updateQuery->bindValue(':blocklist', $newBlockList, PDO::PARAM_STR); + $updateQuery->bindValue(':userid', $myData['userid'], PDO::PARAM_STR); + $res = $updateQuery->execute(); + + if ($res) { + // コミット + $pdo->commit(); + + $unfollow = unfollow_user($pdo, $to_userid, $userid); + if($unfollow === true){ + return true; + }else{ + return false; + } + } else { + // ロールバック + $pdo->rollBack(); + actionLog($userid, "error", "block_user", $to_userid, "ブロックに失敗", 3); + return false; + } + }else{ + return true; + } + } catch (Exception $e) { + // ロールバック + $pdo->rollBack(); + actionLog($userid, "error", "block_user", $to_userid, $e, 4); + return false; + } + }else{ + return false; + } + }else{ + return false; + } +} +function unblock_user($pdo, $to_userid, $userid){ + if (!(empty($pdo)) && !(empty($to_userid)) && !(empty($userid))){ + $myData = getUserData($pdo, $userid); + $userData = getUserData($pdo, $to_userid); + + if (empty($myData) || empty($userData)) { + return false; + } + + $other_settings_me = is_OtherSettings($pdo, $userid); + $other_settings_user = is_OtherSettings($pdo, $to_userid); + if($other_settings_me === true && $other_settings_user === true){ + // トランザクションを開始 + $pdo->beginTransaction(); + try { + // フォロー解除ボタンが押された場合の処理 + $blockList = explode(',', $myData['blocklist']); + if (in_array($userData['userid'], $blockList)) { + $blockList = array_diff($blockList, array($userData['userid'])); + $newBlockList = implode(',', $blockList); + + // UPDATE文を実行してフォロー情報を更新 + $updateQuery = $pdo->prepare("UPDATE account SET blocklist = :blocklist WHERE userid = :userid"); + $updateQuery->bindValue(':blocklist', $newBlockList, PDO::PARAM_STR); + $updateQuery->bindValue(':userid', $myData['userid'], PDO::PARAM_STR); + $res = $updateQuery->execute(); + + if ($res) { + // コミット + $pdo->commit(); + return true; + } else { + // ロールバック + $pdo->rollBack(); + actionLog($userid, "error", "unblock_user", $to_userid, "ブロック解除に失敗", 3); + return false; + } + }else{ + return true; + } + } catch (Exception $e) { + // ロールバック + $pdo->rollBack(); + actionLog($userid, "error", "unblock_user", $to_userid, $e, 4); + return false; + } + }else{ + return false; + } + }else{ + return false; + } +} +function addFavorite($pdo, $uniqid, $userid){ + if (!(empty($pdo)) && !(empty($uniqid)) && !(empty($userid))){ + $pdo->beginTransaction(); + try { + // 投稿のいいね情報を取得 + $stmt = $pdo->prepare("SELECT account,ueuse,favorite FROM ueuse WHERE uniqid = :uniqid"); + $stmt->bindValue(':uniqid', $uniqid, PDO::PARAM_STR); + $stmt->execute(); + $post = $stmt->fetch(PDO::FETCH_ASSOC); + + if (!(empty($post))) { + $favoriteList = explode(',', $post['favorite']); + $index = array_search($userid, $favoriteList); + + if ($index === false) { + // ユーザーIDを追加 + $favoriteList[] = $userid; + + send_notification(safetext($post['account']),$userid,"".$userid."さんがいいねしました!",safetext($post['ueuse']),"/!".$uniqid."","favorite"); + + } else { + // ユーザーIDを削除 + array_splice($favoriteList, $index, 1); + } + + // 新しいいいね情報を更新 + $newFavorite = implode(',', $favoriteList); + $updateQuery = $pdo->prepare("UPDATE ueuse SET favorite = :favorite WHERE uniqid = :uniqid"); + $updateQuery->bindValue(':favorite', $newFavorite, PDO::PARAM_STR); + $updateQuery->bindValue(':uniqid', $uniqid, PDO::PARAM_STR); + $res = $updateQuery->execute(); + + if ($res) { + $pdo->commit(); + return [true, "いいねに成功しました", $newFavorite]; + } else { + $pdo->rollBack(); + actionLog($userid, "error", "addFavorite", $uniqid, "いいねに失敗しました", 3); + return [false, "いいねに失敗しました", $post['favorite']]; + } + } else { + $pdo->rollBack(); + return [false, "投稿が見つかりませんでした", null]; + } + } catch(PDOException $e) { + actionLog($userid, "error", "addFavorite", $uniqid, $e, 4); + return [false, "データベースエラー", null]; + } + } +} +function getFavorite($pdo, $uniqid){ + if (!(empty($pdo)) && !(empty($uniqid))){ + + try { + // 投稿のいいね情報を取得 + $stmt = $pdo->prepare("SELECT account,ueuse,favorite FROM ueuse WHERE uniqid = :uniqid"); + $stmt->bindValue(':uniqid', $uniqid, PDO::PARAM_STR); + $stmt->execute(); + $post = $stmt->fetch(PDO::FETCH_ASSOC); + + if (!(empty($post))) { + return [true, "いいねを取得しました", $post['favorite']]; + } else { + return [false, "投稿が見つかりませんでした", null]; + } + } catch(PDOException $e) { + actionLog(null, "error", "getFavorite", $uniqid, $e, 4); + return [false, "データベースエラー", null]; + } + } +} +function getUserData($pdo, $userid) { + $query = $pdo->prepare("SELECT * FROM account WHERE userid = :userid"); + $query->bindValue(':userid', $userid, PDO::PARAM_STR); + $query->execute(); + return $query->fetch(); +} +function actionLog($userid, $type, $place, $target, $content, $importance){ + + if(empty($userid)){ + $userid = "uwuzu-fromsys"; + } + + switch ($importance) { + case 0: + $importance_level = 0; + break; + case 1: + $importance_level = 1; + break; + case 2: + $importance_level = 2; + break; + case 3: + $importance_level = 3; + break; + case 4: + $importance_level = 4; + break; + case "none": + $importance_level = 0; + break; + case "low": + $importance_level = 1; + break; + case "middle": + $importance_level = 2; + break; + case "high": + $importance_level = 3; + break; + case "critical": + $importance_level = 4; + break; + default: + $importance_level = 0; + break; + } + + if(empty($type)){ + $type = "none"; + } + + if(empty($target)){ + $target = "none"; + } + + if(empty($content)){ + $content = "none"; + } + if(is_array($content)){ + $content = implode(', ', $content); + } + + if(empty($place)){ + $place = "none"; + } + + // データベースに接続 + try { + $option = array( + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::MYSQL_ATTR_MULTI_STATEMENTS => false + ); + $pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); + } catch(PDOException $e) { + return false; + } + + if(!(empty($pdo))){ + $uniqid = createUniqId(); + $datetime = date('Y-m-d H:i:s'); + + // トランザクション開始 + $pdo->beginTransaction(); + + try { + // SQL作成 + $stmt = $pdo->prepare("INSERT INTO actionlog (uniqid, userid, type, place, target, content, importance, datetime) VALUES (:uniqid, :userid, :type, :place, :target, :content, :importance, :datetime)"); + + $stmt->bindParam(':uniqid', $uniqid, PDO::PARAM_STR); + $stmt->bindParam(':userid', $userid, PDO::PARAM_STR); + $stmt->bindParam(':type', $type, PDO::PARAM_STR); + $stmt->bindParam(':place', $place, PDO::PARAM_STR); + + $stmt->bindParam(':target', $target, PDO::PARAM_STR); + $stmt->bindParam(':content', $content, PDO::PARAM_STR); + $stmt->bindParam(':importance', $importance_level, PDO::PARAM_INT); + $stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR); + $res = $stmt->execute(); + if($res){ + $pdo->commit(); + return true; + }else{ + $pdo->rollBack(); + return false; + } + } catch(Exception $e) { + // エラーが発生した時はロールバック + // ここでログを残そうとすると無限ループ入るのでなし + $pdo->rollBack(); + return false; + } + } +} function safetext($text){ // テキストの安全化 return htmlspecialchars($text, ENT_QUOTES, 'UTF-8', false); } +function decode_yajirushi($postText){ + $postText = str_replace('←', '←', $postText); + $postText = str_replace('↓', '↓', $postText); + $postText = str_replace('↑', '↑', $postText); + $postText = str_replace('→', '→', $postText); + return $postText; +} function deleteDirectory($dir) { //ディレクトリを一括で消すやつ if (!is_dir($dir)) { @@ -1416,4 +1858,42 @@ function val_AddOtherSettings($dataname, $data, $jsontext){ return $ret; } +//ユーザーのOther_Settingsが既にあるかないか(なければ空のJSONを追加) +function is_OtherSettings($pdo, $userid, $add = true){ + $other_settings = getUserData($pdo, $userid)["other_settings"]; + if(empty($other_settings)){ + if($add === true){ + $new_data = []; + $new_json = json_encode($new_data); + + $pdo->beginTransaction(); + try { + // UPDATE文を実行してフォロー情報を更新 + $updateQuery = $pdo->prepare("UPDATE account SET other_settings = :other_settings WHERE userid = :userid"); + $updateQuery->bindValue(':other_settings', $new_json, PDO::PARAM_STR); + $updateQuery->bindValue(':userid', $userid, PDO::PARAM_STR); + $res = $updateQuery->execute(); + + if($res){ + $pdo->commit(); + return true; + }else{ + // ロールバック + $pdo->rollBack(); + actionLog($userid, "error", "is_OtherSettings", null, "空のOtherSettingsを追加できませんでした", 3); + return false; + } + } catch (Exception $e) { + // ロールバック + $pdo->rollBack(); + actionLog($userid, "error", "is_OtherSettings", null, $e, 4); + return false; + } + }else{ + return false; + } + }else{ + return true; + } +} ?> \ No newline at end of file diff --git a/home/index.php b/home/index.php index f307857..1dfd11e 100644 --- a/home/index.php +++ b/home/index.php @@ -78,28 +78,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, @@ -134,28 +134,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, @@ -323,7 +323,8 @@ if ("serviceWorker" in navigator) {
- + +
@@ -470,20 +471,55 @@ $(document).ready(function() { var account_id = ''; var pageNumber = 1; - var isLoading = false; - var mode = "local"; + var isLoading = false; - loadPosts(); + var mode = getCookie('mode') || "local"; - function loadPosts() { - if (isLoading) return; - isLoading = true; + if (mode == "foryou") { + $('#timeline_foryou').addClass('on'); + $('#timeline_local').removeClass('on'); + $('#timeline_follow').removeClass('on'); + } else if (mode == "local") { + $('#timeline_foryou').removeClass('on'); + $('#timeline_local').addClass('on'); + $('#timeline_follow').removeClass('on'); + } else if (mode == "follow") { + $('#timeline_foryou').removeClass('on'); + $('#timeline_local').removeClass('on'); + $('#timeline_follow').addClass('on'); + } + loadPosts(); + + function setCookie(name, value, days) { + var expires = ""; + if (days) { + var date = new Date(); + date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); + expires = "; expires=" + date.toUTCString(); + } + document.cookie = name + "=" + (value || "") + expires + "; path=/"; + } + + function getCookie(name) { + var nameEQ = name + "="; + var ca = document.cookie.split(';'); + for (var i = 0; i < ca.length; i++) { + var c = ca[i]; + while (c.charAt(0) == ' ') c = c.substring(1, c.length); + if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length); + } + return null; + } + + function loadPosts() { + if (isLoading) return; + isLoading = true; $("#loading").show(); - if(mode == "local"){ + if (mode == "local") { $.ajax({ url: '../nextpage/nextpage.php', // PHPファイルへのパス method: 'GET', - data: { page: pageNumber, userid: userid , account_id: account_id }, + data: { page: pageNumber, userid: userid, account_id: account_id }, dataType: 'html', timeout: 300000, success: function(response) { @@ -492,17 +528,17 @@ $(document).ready(function() { isLoading = false; $("#loading").hide(); }, - error: function (xhr, textStatus, errorThrown) { // エラーと判定された場合 + error: function(xhr, textStatus, errorThrown) { // エラーと判定された場合 isLoading = false; $("#loading").hide(); $("#error").show(); }, }); - }else if(mode == "follow"){ + } else if (mode == "follow") { $.ajax({ url: '../nextpage/ftlpage.php', // PHPファイルへのパス method: 'GET', - data: { page: pageNumber, userid: userid , account_id: account_id }, + data: { page: pageNumber, userid: userid, account_id: account_id }, dataType: 'html', timeout: 300000, success: function(response) { @@ -511,15 +547,49 @@ $(document).ready(function() { isLoading = false; $("#loading").hide(); }, - error: function (xhr, textStatus, errorThrown) { // エラーと判定された場合 + error: function(xhr, textStatus, errorThrown) { // エラーと判定された場合 isLoading = false; $("#loading").hide(); $("#error").show(); }, }); - } - } + } else if (mode == "foryou") { + $.ajax({ + url: '../nextpage/foryoupage.php', // PHPファイルへのパス + method: 'GET', + data: { page: pageNumber, userid: userid, account_id: account_id }, + dataType: 'html', + timeout: 300000, + success: function(response) { + $('#postContainer').append(response); + pageNumber++; + isLoading = false; + $("#loading").hide(); + }, + error: function(xhr, textStatus, errorThrown) { // エラーと判定された場合 + isLoading = false; + $("#loading").hide(); + $("#error").show(); + }, + }); + } + } + + $("#timeline_foryou").on('click', function(event) { + $('#timeline_foryou').addClass('on'); + $('#timeline_local').removeClass('on'); + $('#timeline_follow').removeClass('on'); + + event.preventDefault(); + $("#postContainer").empty(); + pageNumber = 1; + mode = "foryou"; + setCookie('mode', mode, 28); + loadPosts(); + }); + $("#timeline_local").on('click', function(event) { + $('#timeline_foryou').removeClass('on'); $('#timeline_local').addClass('on'); $('#timeline_follow').removeClass('on'); @@ -527,9 +597,12 @@ $(document).ready(function() { $("#postContainer").empty(); pageNumber = 1; mode = "local"; + setCookie('mode', mode, 28); loadPosts(); }); + $("#timeline_follow").on('click', function(event) { + $('#timeline_foryou').removeClass('on'); $('#timeline_local').removeClass('on'); $('#timeline_follow').addClass('on'); @@ -537,6 +610,7 @@ $(document).ready(function() { $("#postContainer").empty(); pageNumber = 1; mode = "follow"; + setCookie('mode', mode, 28); loadPosts(); }); diff --git a/js/console_notice.js b/js/console_notice.js index 9ecc196..04700da 100644 --- a/js/console_notice.js +++ b/js/console_notice.js @@ -18,7 +18,7 @@ console.log( "", ); console.log( - "自分で意図して行っていないのであれば%c今直ぐにこのツールを閉じて作業を中断してください。%c\n中断後、安全性の観点からセッショントークンの再生成をすることを強く推奨します。\nセッショントークンの再生性は以下のリンクより行えます。"+sesstoken_reset_url, + "自分で意図して行っていないのであれば%c今直ぐにこのツールを閉じて作業を中断してください。%c\n中断後、安全性の観点からセッショントークンの再生成をすることを強く推奨します。\nセッショントークンの再生性は以下のリンクより行えます。\n"+sesstoken_reset_url, "color:#FF4848; font-weight: bold;", "", ); diff --git a/migration/index.php b/migration/index.php index 3cdb74f..a5453f6 100644 --- a/migration/index.php +++ b/migration/index.php @@ -264,10 +264,10 @@ if( !empty($_POST['btn_submit']) ) { if(check_mime($temp_file) == "image/webp"){ // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename = uniqid() . '-'.$new_userid.'.webp'; + $newFilename = createUniqId() . '-'.$new_userid.'.webp'; }else{ // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename = uniqid() . '-'.$new_userid.'.' . $extension; + $newFilename = createUniqId() . '-'.$new_userid.'.' . $extension; } // 保存先のパスを生成 @@ -316,10 +316,10 @@ if( !empty($_POST['btn_submit']) ) { if(check_mime($temp_file) == "image/webp"){ // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename = uniqid() . '-'.$new_userid.'.webp'; + $newFilename = createUniqId() . '-'.$new_userid.'.webp'; }else{ // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename = uniqid() . '-'.$new_userid.'.' . $extension; + $newFilename = createUniqId() . '-'.$new_userid.'.' . $extension; } // 保存先のパスを生成 diff --git a/new.php b/new.php index 8f95261..a28becc 100644 --- a/new.php +++ b/new.php @@ -187,7 +187,7 @@ if( !empty($_POST['btn_submit']) ) { $localFilePathhead = 'img/deficon/icon.png'; // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename = uniqid() . '-'.$userid.'.png'; + $newFilename = createUniqId() . '-'.$userid.'.png'; // 保存先のパスを生成 $uploadedPath = 'usericons/' . $newFilename; @@ -226,10 +226,10 @@ if( !empty($_POST['btn_submit']) ) { if(check_mime($uploadedFile['tmp_name']) == "image/webp"){ // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename = uniqid() . '-'.$userid.'.webp'; + $newFilename = createUniqId() . '-'.$userid.'.webp'; }else{ // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename = uniqid() . '-'.$userid.'.' . $extension; + $newFilename = createUniqId() . '-'.$userid.'.' . $extension; } // 保存先のパスを生成 $uploadedPath = 'usericons/' . $newFilename; @@ -262,7 +262,7 @@ if( !empty($_POST['btn_submit']) ) { $localFilePathhead = 'img/defhead/head.png'; // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename = uniqid() . '-'.$userid.'.png'; + $newFilename = createUniqId() . '-'.$userid.'.png'; // 保存先のパスを生成 $uploadedPath = 'userheads/' . $newFilename; @@ -403,6 +403,8 @@ if( !empty($_POST['btn_submit']) ) { $enc_mailadds = ""; } + $other_settings = []; + $other_settings_json = json_encode($other_settings); try { @@ -415,7 +417,7 @@ if( !empty($_POST['btn_submit']) ) { $loginid = hash('sha3-512', $LoginIdBytes); // SQL作成 - $stmt = $pdo->prepare("INSERT INTO account (username, userid, password, loginid, mailadds, profile, iconname, headname, role, datetime, admin, encryption_ivkey) VALUES (:username, :userid, :password, :loginid, :mailadds, :profile, :iconname, :headname, :role, :datetime, :admin ,:encryption_ivkey)"); + $stmt = $pdo->prepare("INSERT INTO account (username, userid, password, loginid, mailadds, profile, iconname, headname, role, datetime, admin, encryption_ivkey, other_settings) VALUES (:username, :userid, :password, :loginid, :mailadds, :profile, :iconname, :headname, :role, :datetime, :admin, :encryption_ivkey, :other_settings)"); // アイコン画像 $stmt->bindValue(':iconname', $iconName, PDO::PARAM_STR); @@ -432,6 +434,7 @@ if( !empty($_POST['btn_submit']) ) { $stmt->bindParam(':profile', $profile, PDO::PARAM_STR); $stmt->bindParam(':role', $role, PDO::PARAM_STR); $stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR); + $stmt->bindParam(':other_settings', $other_settings_json, PDO::PARAM_STR); $stmt->bindParam(':encryption_ivkey', $iv, PDO::PARAM_STR); diff --git a/nextpage/bookmark.php b/nextpage/bookmark.php index a4376af..5b8d712 100644 --- a/nextpage/bookmark.php +++ b/nextpage/bookmark.php @@ -49,6 +49,9 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $itemsPerPage = 15; // 1ページあたりのユーズ数 $pageNumber = safetext(isset($_GET['page'])) ? safetext(intval($_GET['page'])) : 1; + if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){ + $pageNumber = 1; + } $offset = ($pageNumber - 1) * $itemsPerPage; $messages = array(); diff --git a/nextpage/emojiview.php b/nextpage/emojiview.php index 00846c7..1fd2ce5 100644 --- a/nextpage/emojiview.php +++ b/nextpage/emojiview.php @@ -24,6 +24,9 @@ if (isset($_GET['userid']) && isset($_GET['account_id']) && isset($_GET['search_ $itemsPerPage = 50; $pageNumber = safetext(isset($_GET['page'])) ? safetext(intval($_GET['page'])) : 1; + if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){ + $pageNumber = 1; + } $offset = ($pageNumber - 1) * $itemsPerPage; // データベース接続の設定 diff --git a/nextpage/foryoupage.php b/nextpage/foryoupage.php new file mode 100644 index 0000000..35e0d45 --- /dev/null +++ b/nextpage/foryoupage.php @@ -0,0 +1,315 @@ + PDO::ERRMODE_EXCEPTION, + PDO::MYSQL_ATTR_MULTI_STATEMENTS => false + ); + $pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option); +} catch (PDOException $e) { + // 接続エラーのときエラー内容を取得する + $error_message[] = $e->getMessage(); +} + +if (isset($_GET['userid']) && isset($_GET['account_id'])) { + $userid = safetext($_GET['userid']); + $loginid = safetext($_GET['account_id']); + + // データベース接続の設定 + $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST, DB_USER, DB_PASS, array( + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, + PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, + )); + + $query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); + + $query->execute(array(':userid' => $userid)); + + $result2 = $query->fetch(); + + if(!(empty($result2["loginid"]))){ + if($result2["loginid"] === $loginid){ + + $aduserinfoQuery = $pdo->prepare("SELECT username,userid,loginid,admin,role,sacinfo,blocklist,bookmark FROM account WHERE userid = :userid"); + $aduserinfoQuery->bindValue(':userid', safetext($userid)); + $aduserinfoQuery->execute(); + $res = $aduserinfoQuery->fetch(); + $myblocklist = safetext($res["blocklist"]); + $mybookmark = safetext($res["bookmark"]); + + $itemsPerPage = 15; // 1ページあたりのユーズ数 + $pageNumber = safetext(isset($_GET['page'])) ? safetext(intval($_GET['page'])) : 1; + if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){ + $pageNumber = 1; + } + $offset = ($pageNumber - 1) * $itemsPerPage; + + $messages = array(); + + if (!empty($pdo)) { + //------------------------------------------すべてのユーズを取得---------------------------------------------- + $all_sql = "SELECT ueuse.* + FROM ueuse + LEFT JOIN account ON ueuse.account = account.userid + WHERE ueuse.rpuniqid = '' AND account.role != 'ice' + ORDER BY ueuse.datetime DESC + LIMIT :offset, :itemsPerPage"; + + $all_stmt = $pdo->prepare($all_sql); + $all_stmt->bindValue(':offset', $offset, PDO::PARAM_INT); + $all_stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT); + $all_stmt->execute(); + + while ($row = $all_stmt->fetch(PDO::FETCH_ASSOC)) { + $all_messages[] = $row; + } + if(empty($all_messages)){ + $all_messages = []; + } + + //------------------------------------------人気なユーズを取得(バズってるやつ)---------------------------------------------- + $day_count_sql = "SELECT ueuse.* + FROM ueuse + LEFT JOIN account ON ueuse.account = account.userid + WHERE ueuse.datetime >= NOW() - INTERVAL 7 DAY AND ueuse.rpuniqid = '' AND account.role != 'ice' + ORDER BY ueuse.datetime DESC + LIMIT 1000"; + $cnt_stmt = $pdo->prepare($day_count_sql); + $cnt_stmt->execute(); + $Before7daysPosts = $cnt_stmt->fetchAll(PDO::FETCH_ASSOC); + + // 結果が15件に満たない場合 + if(count($Before7daysPosts) < 15){ + $get_day = 90; + }elseif(count($Before7daysPosts) > 15 && count($Before7daysPosts) < 150){ + $get_day = 31; + }elseif(count($Before7daysPosts) > 150 && count($Before7daysPosts) < 750){ + $get_day = 7; + }elseif(count($Before7daysPosts) > 750){ + $get_day = 5; + }else{ + $get_day = 2; + } + + $get_day = $get_day * (2 ** floor($pageNumber / 3)); + + $pop_sql = "SELECT + ueuse.*, + (LENGTH(ueuse.favorite) - LENGTH(REPLACE(ueuse.favorite, ',', '')) - 1) AS favorite_count, + (SELECT COUNT(*) FROM ueuse AS reuse WHERE reuse.ruuniqid = ueuse.uniqid) AS reuse_count, + ((LENGTH(ueuse.favorite) - LENGTH(REPLACE(ueuse.favorite, ',', '')) - 1) + + (SELECT COUNT(*) FROM ueuse AS reuse WHERE reuse.ruuniqid = ueuse.uniqid)) AS total_score + FROM + ueuse + LEFT JOIN account ON ueuse.account = account.userid + WHERE + ueuse.datetime >= NOW() - INTERVAL :getday DAY + AND + ueuse.rpuniqid = '' + AND + account.role != 'ice' + ORDER BY + total_score DESC + LIMIT :offset, :itemsPerPage; + "; + + $pop_stmt = $pdo->prepare($pop_sql); + $pop_stmt->bindValue(':getday', $get_day, PDO::PARAM_INT); + $pop_stmt->bindValue(':offset', $offset, PDO::PARAM_INT); + $pop_stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT); + $pop_stmt->execute(); + + while ($row = $pop_stmt->fetch(PDO::FETCH_ASSOC)) { + $pop_messages[] = $row; + } + if(empty($flw_messages)){ + $pop_messages = []; + } + + //------------------------------------------フォローしているユーザーから取得---------------------------------------------- + $followList = explode(',', getUserData($pdo, $userid)["follow"]); + + foreach ($followList as $followUserId) { + $flw_sql = "SELECT ueuse.* + FROM ueuse + LEFT JOIN account ON ueuse.account = account.userid + WHERE ueuse.rpuniqid = '' AND account.role != 'ice' AND ueuse.account = :follow_account AND ueuse.datetime >= NOW() - INTERVAL :getday DAY + ORDER BY ueuse.datetime DESC + LIMIT :offset, :itemsPerPage"; + + $flw_stmt = $pdo->prepare($flw_sql); + $flw_stmt->bindValue(':getday', $get_day, PDO::PARAM_INT); + $flw_stmt->bindValue(':offset', $offset, PDO::PARAM_INT); + $flw_stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT); + $flw_stmt->bindValue(':follow_account', $followUserId, PDO::PARAM_STR); + $flw_stmt->execute(); + + while ($row = $flw_stmt->fetch(PDO::FETCH_ASSOC)) { + $flw_messages[] = $row; + } + } + if(!(empty($flw_messages))){ + usort($flw_messages, function($a, $b) { + return strtotime($b['datetime']) - strtotime($a['datetime']); + }); + }else{ + $flw_messages = []; + } + + //------------------------------------------いいねやリユーズを頻繁にするような好きっぽそうなユーザーの投稿を取得-------------------------------------- + $fav_sql = "SELECT ueuse.*, + (LENGTH(ueuse.favorite) - LENGTH(REPLACE(ueuse.favorite, ',', '')) - 1) AS favorite_count + FROM ueuse + WHERE FIND_IN_SET(:userid, ueuse.favorite) > 0 + ORDER BY ueuse.datetime DESC + LIMIT 100 + "; + $fav_stmt = $pdo->prepare($fav_sql); + $fav_stmt->bindValue(':userid', $userid, PDO::PARAM_STR); + $fav_stmt->execute(); + while ($row = $fav_stmt->fetch(PDO::FETCH_ASSOC)) { + $fav_ueuse_lists[] = $row; + } + if(!(empty($fav_ueuse_lists))){ + $many_fav_accounts = array_column($fav_ueuse_lists, 'account'); + $many_fav_account_counts = array_count_values($many_fav_accounts); + arsort($many_fav_account_counts); + $top_fav_accounts = array_slice($many_fav_account_counts, 0, 15, true); + + foreach ($top_fav_accounts as $favUserId => $count) { + $favget_sql = "SELECT ueuse.* + FROM ueuse + LEFT JOIN account ON ueuse.account = account.userid + WHERE ueuse.rpuniqid = '' AND account.role != 'ice' AND ueuse.account = :fav_account AND ueuse.datetime >= NOW() - INTERVAL :getday DAY + ORDER BY ueuse.datetime DESC + LIMIT :offset, :itemsPerPage"; + + $favget_stmt = $pdo->prepare($favget_sql); + $favget_stmt->bindValue(':getday', $get_day, PDO::PARAM_INT); + $favget_stmt->bindValue(':offset', $offset, PDO::PARAM_INT); + $favget_stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT); + $favget_stmt->bindValue(':fav_account', $favUserId, PDO::PARAM_STR); + $favget_stmt->execute(); + + while ($row = $favget_stmt->fetch(PDO::FETCH_ASSOC)) { + $favget_messages[] = $row; + } + } + if(empty($favget_messages)){ + $favget_messages = []; + } + }else{ + $favget_messages = []; + } + + //基本的には人気・フォロー中・いいねする事が多いユーザーのユーズでTLを構成するけど全部出きったらLTLと同じにする + if(empty($pop_messages) && empty($flw_messages) && empty($favget_messages)){ + $messages = $all_messages; + }elseif(count(array_merge($pop_messages, $flw_messages, $favget_messages)) < 15){ + $total_messages = array_unique(array_merge($all_messages, $pop_messages, $flw_messages, $favget_messages), SORT_REGULAR); + shuffle($total_messages); + $messages = array_slice($total_messages, 0, 15); + }else{ + $total_messages = array_unique(array_merge($pop_messages, $flw_messages, $favget_messages), SORT_REGULAR); + shuffle($total_messages); + $messages = array_slice($total_messages, 0, 15); + } + + // ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える + foreach ($messages as &$message) { + $userQuery = $pdo->prepare("SELECT username, userid, profile, role, iconname, headname, sacinfo FROM account WHERE userid = :userid"); + $userQuery->bindValue(':userid', $message["account"]); + $userQuery->execute(); + $userData = $userQuery->fetch(); + + if ($userData) { + $message['iconname'] = $userData['iconname']; + $message['headname'] = $userData['headname']; + $message['username'] = $userData['username']; + $message['sacinfo'] = $userData['sacinfo']; + $message['role'] = $userData['role']; + } + + //リプライ数取得 + $rpQuery = $pdo->prepare("SELECT COUNT(*) as reply_count FROM ueuse WHERE rpuniqid = :rpuniqid"); + $rpQuery->bindValue(':rpuniqid', $message['uniqid']); + $rpQuery->execute(); + $rpData = $rpQuery->fetch(PDO::FETCH_ASSOC); + + if ($rpData){ + $message['reply_count'] = $rpData['reply_count']; + } + + //リユーズ数取得 + $ruQuery = $pdo->prepare("SELECT COUNT(*) as reuse_count FROM ueuse WHERE ruuniqid = :ruuniqid"); + $ruQuery->bindValue(':ruuniqid', $message['uniqid']); + $ruQuery->execute(); + $ruData = $ruQuery->fetch(PDO::FETCH_ASSOC); + + if ($ruData){ + $message['reuse_count'] = $ruData['reuse_count']; + } + } + //adsystem------------------ + + $message['ads'] = "false"; + + $today = date("Y-m-d H:i:s"); + + $adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()"); + $adsQuery->bindValue(':today', $today); + $adsQuery->execute(); + $adsresult = $adsQuery->fetch(); + if(!(empty($adsresult))){ + $message['ads'] = "true"; + $message['ads_url'] = $adsresult["url"]; + $message['ads_img_url'] = $adsresult["image_url"]; + $message['ads_memo'] = $adsresult["memo"]; + } + //-------------------------- + + if(!empty($messages)){ + foreach ($messages as $value) { + if (false === strpos($myblocklist, ','.safetext($value['account']))) { + if(!($value["role"] === "ice")){ + $fav = $value['favorite']; // コンマで区切られたユーザーIDを含む変数 + + // コンマで区切って配列に分割し、要素数を数える + $favIds = explode(',', $fav); + $value["favcnt"] = count($favIds)-1; + + $value["bookmark"] = $mybookmark; + + $messageDisplay = new MessageDisplay($value, $userid); // $userid をコンストラクタに渡す + $messageDisplay->display(); + } + } + } + if($message['ads'] === "true"){ + echo '
'; + } + }else{ + echo '

ユーズがありません

'; + } + + $pdo = null; + + } + }else{ + echo '

取得に失敗しました。

'; + } + }else{ + echo '

取得に失敗しました。

'; + } +}else{ + echo '

取得に失敗しました。

'; +} +?> diff --git a/nextpage/ftlpage.php b/nextpage/ftlpage.php index 8ca2acc..d80e3d8 100644 --- a/nextpage/ftlpage.php +++ b/nextpage/ftlpage.php @@ -49,6 +49,9 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $itemsPerPage = 15; // 1ページあたりのユーズ数 $pageNumber = safetext(isset($_GET['page'])) ? safetext(intval($_GET['page'])) : 1; + if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){ + $pageNumber = 1; + } $offset = ($pageNumber - 1) * $itemsPerPage; $messages = array(); diff --git a/nextpage/nextpage.php b/nextpage/nextpage.php index b0d25ea..2784453 100644 --- a/nextpage/nextpage.php +++ b/nextpage/nextpage.php @@ -47,6 +47,9 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $itemsPerPage = 15; // 1ページあたりのユーズ数 $pageNumber = safetext(isset($_GET['page'])) ? safetext(intval($_GET['page'])) : 1; + if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){ + $pageNumber = 1; + } $offset = ($pageNumber - 1) * $itemsPerPage; $messages = array(); diff --git a/nextpage/notification.php b/nextpage/notification.php index 309fbf1..f654f9b 100644 --- a/nextpage/notification.php +++ b/nextpage/notification.php @@ -43,6 +43,9 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $itemsPerPage = 15; // 1ページあたりの投稿数 $pageNumber = safetext(isset($_GET['page'])) ? safetext(intval($_GET['page'])) : 1; + if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){ + $pageNumber = 1; + } $offset = ($pageNumber - 1) * $itemsPerPage; $messages = array(); diff --git a/nextpage/searchpage.php b/nextpage/searchpage.php index 5f150a6..6f2b254 100644 --- a/nextpage/searchpage.php +++ b/nextpage/searchpage.php @@ -42,6 +42,13 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $keyword = safetext(isset($_GET['keyword'])) ? safetext($_GET['keyword']) : ''; $userid = safetext($_GET['userid']); + $itemsPerPage = 15; // 1ページあたりのユーズ数 + $pageNumber = safetext(isset($_GET['page'])) ? safetext(intval($_GET['page'])) : 1; + if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){ + $pageNumber = 1; + } + $offset = ($pageNumber - 1) * $itemsPerPage; + $messages = array(); if (!empty($pdo)) { @@ -64,20 +71,26 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $username = $matches[1]; $searchKeyword = $matches[2]; - $messageQuery = $dbh->prepare("SELECT * FROM ueuse WHERE account = :username AND (ueuse LIKE :searchKeyword OR abi LIKE :searchKeyword) ORDER BY datetime DESC"); + $messageQuery = $dbh->prepare("SELECT * FROM ueuse WHERE account = :username AND (ueuse LIKE :searchKeyword OR abi LIKE :searchKeyword) ORDER BY datetime DESC LIMIT :offset, :itemsPerPage"); $messageQuery->bindValue(':username', $username, PDO::PARAM_STR); $messageQuery->bindValue(':searchKeyword', '%' . $searchKeyword . '%', PDO::PARAM_STR); + $messageQuery->bindValue(':offset', $offset, PDO::PARAM_INT); + $messageQuery->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT); $messageQuery->execute(); $message_array = $messageQuery->fetchAll(); } else { - $messageQuery = $dbh->prepare("SELECT * FROM ueuse WHERE ueuse LIKE :keyword OR abi LIKE :keyword ORDER BY datetime DESC"); + $messageQuery = $dbh->prepare("SELECT * FROM ueuse WHERE ueuse LIKE :keyword OR abi LIKE :keyword ORDER BY datetime DESC LIMIT :offset, :itemsPerPage"); $messageQuery->bindValue(':keyword', '%' . $keyword . '%', PDO::PARAM_STR); + $messageQuery->bindValue(':offset', $offset, PDO::PARAM_INT); + $messageQuery->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT); $messageQuery->execute(); $message_array = $messageQuery->fetchAll(); } $user_keyword = str_replace('@', '', $keyword); - $usersQuery = $dbh->prepare("SELECT * FROM account WHERE username LIKE :keyword OR userid LIKE :keyword OR profile LIKE :keyword ORDER BY datetime DESC"); + $usersQuery = $dbh->prepare("SELECT * FROM account WHERE username LIKE :keyword OR userid LIKE :keyword OR profile LIKE :keyword ORDER BY datetime DESC LIMIT :offset, :itemsPerPage"); + $usersQuery->bindValue(':offset', $offset, PDO::PARAM_INT); + $usersQuery->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT); $usersQuery->bindValue(':keyword', '%' . $user_keyword . '%', PDO::PARAM_STR); $usersQuery->execute(); $users_array = $usersQuery->fetchAll(); diff --git a/nextpage/ueusepage.php b/nextpage/ueusepage.php index 6e8fee6..3e4ba9b 100644 --- a/nextpage/ueusepage.php +++ b/nextpage/ueusepage.php @@ -49,6 +49,9 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $itemsPerPage = 15; // 1ページあたりの投稿数 $pageNumber = safetext(isset($_GET['page'])) ? safetext(intval($_GET['page'])) : 1; + if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){ + $pageNumber = 1; + } $offset = ($pageNumber - 1) * $itemsPerPage; $messages = array(); diff --git a/nextpage/userlikepage.php b/nextpage/userlikepage.php index 68ed592..78a1cb4 100644 --- a/nextpage/userlikepage.php +++ b/nextpage/userlikepage.php @@ -49,6 +49,9 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $itemsPerPage = 15; // 1ページあたりのユーズ数 $pageNumber = safetext(isset($_GET['page'])) ? safetext(intval($_GET['page'])) : 1; + if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){ + $pageNumber = 1; + } $offset = ($pageNumber - 1) * $itemsPerPage; $messages = array(); diff --git a/nextpage/usermediapage.php b/nextpage/usermediapage.php index 3aa136f..e9f6142 100644 --- a/nextpage/usermediapage.php +++ b/nextpage/usermediapage.php @@ -48,6 +48,9 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $itemsPerPage = 15; // 1ページあたりのユーズ数 $pageNumber = safetext(isset($_GET['page'])) ? safetext(intval($_GET['page'])) : 1; + if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){ + $pageNumber = 1; + } $offset = ($pageNumber - 1) * $itemsPerPage; $messages = array(); diff --git a/nextpage/userpage.php b/nextpage/userpage.php index a7038a3..c52b686 100644 --- a/nextpage/userpage.php +++ b/nextpage/userpage.php @@ -49,6 +49,9 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $itemsPerPage = 15; // 1ページあたりのユーズ数 $pageNumber = safetext(isset($_GET['page'])) ? safetext(intval($_GET['page'])) : 1; + if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){ + $pageNumber = 1; + } $offset = ($pageNumber - 1) * $itemsPerPage; $messages = array(); diff --git a/nodeinfo/2.1/index.php b/nodeinfo/2.1/index.php index 1f89417..1e9ed70 100644 --- a/nodeinfo/2.1/index.php +++ b/nodeinfo/2.1/index.php @@ -2,13 +2,7 @@ require("../../function/function.php"); $serversettings_file = "../../server/serversettings.ini"; $serversettings = parse_ini_file($serversettings_file, true); -function decode_yajirushi($postText){ - $postText = str_replace('←', '←', $postText); - $postText = str_replace('↓', '↓', $postText); - $postText = str_replace('↑', '↑', $postText); - $postText = str_replace('→', '→', $postText); - return $postText; -} + if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ header("Content-Type: application/activity+json"); header("charset=utf-8"); @@ -77,7 +71,7 @@ if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ "software" => array( "name" => "uwuzu", "version" => "".str_replace("\r", '', $uwuzuinfo[1])."", - "homepage" => "https://www.uwuzu.com/", + "homepage" => "https://docs.uwuzu.xyz/", "repository" => "https://github.com/Daichimarukana/uwuzu", ), "protocols" => [ diff --git a/notice/addnotice.php b/notice/addnotice.php index ece76da..161c678 100644 --- a/notice/addnotice.php +++ b/notice/addnotice.php @@ -67,28 +67,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, @@ -123,28 +123,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, diff --git a/notice/index.php b/notice/index.php index b05fb2d..1ef27a6 100644 --- a/notice/index.php +++ b/notice/index.php @@ -69,28 +69,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, @@ -125,28 +125,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, diff --git a/notification/index.php b/notification/index.php index 44f23f6..04b321a 100644 --- a/notification/index.php +++ b/notification/index.php @@ -66,28 +66,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, @@ -122,28 +122,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, diff --git a/others/account_migration.php b/others/account_migration.php index 28a4d4a..526b5d7 100644 --- a/others/account_migration.php +++ b/others/account_migration.php @@ -78,28 +78,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, @@ -134,28 +134,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, @@ -371,6 +371,7 @@ require('../logout/logout.php'); - アイコン
- ヘッダー
- メールアドレス

+

アカウントの移行後このサーバーのアカウントは自動凍結されます。

diff --git a/others/account_migration_done.php b/others/account_migration_done.php index c61abd8..0515288 100644 --- a/others/account_migration_done.php +++ b/others/account_migration_done.php @@ -66,28 +66,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, @@ -122,28 +122,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, diff --git a/others/index.php b/others/index.php index 8ee3b93..c3d19ab 100644 --- a/others/index.php +++ b/others/index.php @@ -72,28 +72,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, @@ -128,28 +128,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, @@ -561,7 +561,7 @@ require('../logout/logout.php');

API

-

APIの使用方法はuwuzu.comよりAPIドキュメントをご確認ください。

+

APIの使用方法はdocs.uwuzu.xyzよりAPIドキュメントをご確認ください。

time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, @@ -126,28 +126,28 @@ if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, diff --git a/passrecovery/startrecovery.php b/passrecovery/startrecovery.php index 5d1928f..9ce0962 100644 --- a/passrecovery/startrecovery.php +++ b/passrecovery/startrecovery.php @@ -112,45 +112,50 @@ if(!($userid == null)){ } if( empty($error_message) ) { - // トランザクション開始 - $pdo->beginTransaction(); + $other_settings_me = is_OtherSettings($pdo, $userid); + if($other_settings_me === true){ + // トランザクション開始 + $pdo->beginTransaction(); + + $hashpassword = uwuzu_password_hash($password); - $hashpassword = uwuzu_password_hash($password); - - try { - // SQL作成 - $stmt = $pdo->prepare("UPDATE account SET password = :password WHERE userid = :userid;"); - - // 他の値をセット - $stmt->bindParam(':password', $hashpassword, PDO::PARAM_STR); - - // 条件を指定 - // 以下の部分を適切な条件に置き換えてください - $stmt->bindValue(':userid', $userid, PDO::PARAM_STR); - - // SQLクエリの実行 - $res = $stmt->execute(); - - // コミット - $res = $pdo->commit(); - - } catch (Exception $e) { - - // エラーが発生した時はロールバック - $pdo->rollBack(); - } - - if ($res) { - $msg = "お使いのアカウントのパスワードがパスワードの復元により変更されました。\n変更した覚えがない場合はパスワードを変更し、セッショントークンを再生成してください。"; - send_notification($userid,"uwuzu-fromsys","🔴アカウントのパスワードが復元により変更されました。🔴",$msg,"/others", "system"); - - $_SESSION['userid'] = ""; - $url = 'donerecovery.php'; - header('Location: ' . $url, true, 303); - - // すべての出力を終了 - exit; - } else { + try { + // SQL作成 + $stmt = $pdo->prepare("UPDATE account SET password = :password WHERE userid = :userid;"); + + // 他の値をセット + $stmt->bindParam(':password', $hashpassword, PDO::PARAM_STR); + + // 条件を指定 + // 以下の部分を適切な条件に置き換えてください + $stmt->bindValue(':userid', $userid, PDO::PARAM_STR); + + // SQLクエリの実行 + $res = $stmt->execute(); + + // コミット + $res = $pdo->commit(); + + } catch (Exception $e) { + + // エラーが発生した時はロールバック + $pdo->rollBack(); + } + + if ($res) { + $msg = "お使いのアカウントのパスワードがパスワードの復元により変更されました。\n変更した覚えがない場合はパスワードを変更し、セッショントークンを再生成してください。"; + send_notification($userid,"uwuzu-fromsys","🔴アカウントのパスワードが復元により変更されました。🔴",$msg,"/others", "system"); + + $_SESSION['userid'] = ""; + $url = 'donerecovery.php'; + header('Location: ' . $url, true, 303); + + // すべての出力を終了 + exit; + } else { + $error_message[] = 'パスワードの更新に失敗しました。(REGISTERED_DAME)'; + } + }else{ $error_message[] = 'パスワードの更新に失敗しました。(REGISTERED_DAME)'; } } diff --git a/require/noscript_modal.php b/require/noscript_modal.php index 7fafe44..cae88d3 100644 --- a/require/noscript_modal.php +++ b/require/noscript_modal.php @@ -9,7 +9,7 @@

JavaScriptを無効にしている状態での使用はできません。

詳細は下記のリンクよりご確認ください。

- 詳細 + 詳細
JS_BLOCKED_ERROR
diff --git a/require/tutorial.php b/require/tutorial.php index 45a3c25..2a6ea13 100644 --- a/require/tutorial.php +++ b/require/tutorial.php @@ -68,6 +68,7 @@ そして、タイムライン上部のメニューから「フォロー」というタイムラインも見ることが可能です。
それぞれの機能はこんな感じ!

+ - おすすめ … おすすめタイムラインの略称で、人気のユーズや自分が多くいいねしているユーザーのユーズなどが表示されます!
- ローカル … ローカルタイムラインの略称で、同じサーバーにいる全員のユーズが表示されます。(uwuzu v1.3.5以前はLTL)
- フォロー … フォロータイムラインの略称で、自分のフォローしているユーザーのユーズが表示されます。(uwuzu v1.3.5以前はFTL)

@@ -114,7 +115,7 @@ - 詳細 + 詳細

エラー内容

diff --git a/update.json b/update.json index 808ade4..40e96af 100644 --- a/update.json +++ b/update.json @@ -1,14 +1,88 @@ { "software": "uwuzu", - "version": "1.4.8", - "release_date": "2024-11-14", - "release_notes": "このアップデートでは設定画面で発生する重大なバグが修正されています。\n早急なアップデートを推奨します。", - "notices": "アップデートの前にデータのバックアップを行うことをおすすめします!", + "version": "1.4.9", + "release_date": "2024/12/27", + "release_notes": "このアップデートではおすすめタイムラインの追加やフォローできない問題の修正などが含まれます!", + "notices": "アップデートの前にSQLの構造の更新を行ってください!\nデータのバックアップを行うことをおすすめします!", "files": { "overwrite": [ - "/settings/index.php", - "/settings_admin/update_admin.php", + "/actor/index.php", + "/admin/addadmin.php", + "/admin/index.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", + "/api/v1/instance.php", + "/api/migration-api.php", + "/bookmark/index.php", + "/css/home.css", + "/emoji/index.php", + "/favorite/favorite.php", "/function/function.php", + "/home/index.php", + "/js/console_notice.js", + "/migration/index.php", + "/nextpage/bookmark.php", + "/nextpage/emojiview.php", + "/nextpage/foryoupage.php", + "/nextpage/ftlpage.php", + "/nextpage/nextpage.php", + "/nextpage/notification.php", + "/nextpage/searchpage.php", + "/nextpage/ueusepage.php", + "/nextpage/userlikepage.php", + "/nextpage/usermediapage.php", + "/nextpage/userpage.php", + "/nodeinfo/2.1/index.php", + "/notice/addnotice.php", + "/notice/index.php", + "/notification/index.php", + "/others/account_migration.php", + "/others/account_migration_done.php", + "/others/index.php", + "/others/token.php", + "/passrecovery/startrecovery.php", + "/require/noscript_modal.php", + "/require/tutorial.php", + "/search/index.php", + "/settings/addauthcode.php", + "/settings/index.php", + "/settings/success.php", + "/settings_admin/api/update_query.php", + "/settings_admin/actionlog_admin.php", + "/settings_admin/ad_admin.php", + "/settings_admin/addemoji_admin.php", + "/settings_admin/codeadmin.php", + "/settings_admin/customize_admin.php", + "/settings_admin/maintenance_admin.php", + "/settings_admin/moderation_admin.php", + "/settings_admin/overview_admin.php", + "/settings_admin/plugin_admin.php", + "/settings_admin/role_admin.php", + "/settings_admin/serveradmin.php", + "/settings_admin/settings_left_menu.php", + "/settings_admin/update_admin.php", + "/settings_admin/useradmin.php", + "/settings_admin/userinfo.php", + "/ueuse/index.php", + "/user/index.php", + "/user/report.php", + "/user/success.php", + "/authlogin.php", + "/check.php", + "/new.php", + "/unsupported.php", + "/uwuzu_error_code.txt", "/server/uwuzuabout.txt", "/server/uwuzuinfo.txt", "/server/uwuzurelease.txt" diff --git a/user/index.php b/user/index.php index 6dd93a6..c2da4cd 100644 --- a/user/index.php +++ b/user/index.php @@ -70,28 +70,28 @@ if (isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username, [ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"], [ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true, [ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, @@ -124,28 +124,28 @@ if (isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { $_SESSION['username'] = $username; $_SESSION['loginid'] = $res["loginid"]; setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('username', $username, [ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('loginid', $res["loginid"], [ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); setcookie('admin_login', true, [ - 'expires' => time() + 60 * 60 * 24 * 14, + 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, @@ -205,7 +205,7 @@ if (!empty($pdo)) { // SQL実行 $rerole->execute(); - $userdata = $rerole->fetch(); // ここでデータベースから取得した値を $role に代入する + $userdata = $rerole->fetch(); $roleDataArray = array(); @@ -300,183 +300,43 @@ if (!empty($pdo)) { } if (!empty($_POST['follow'])) { - // トランザクションを開始 - $pdo->beginTransaction(); - try { - // フォローボタンが押された場合の処理 - $followerList = explode(',', $userdata['follower']); - if (!(in_array($userid, $followerList))) { - // 自分が相手をフォローしていない場合、相手のfollowerカラムと自分のfollowカラムを更新 - $followerList[] = $userid; - $newFollowerList = implode(',', $followerList); - - // UPDATE文を実行してフォロー情報を更新 - $updateQuery = $pdo->prepare("UPDATE account SET follower = :follower WHERE userid = :userid"); - $updateQuery->bindValue(':follower', $newFollowerList, PDO::PARAM_STR); - $updateQuery->bindValue(':userid', $userData['userid'], PDO::PARAM_STR); - $res = $updateQuery->execute(); - - // 自分のfollowカラムを更新 - $myflwlist = explode(',', $myfollowlist); - $myflwlist[] = $userData['userid']; - $newFollowList = implode(',', array_unique($myflwlist)); - - $updateQuery = $pdo->prepare("UPDATE account SET follow = :follow WHERE userid = :userid"); - $updateQuery->bindValue(':follow', $newFollowList, PDO::PARAM_STR); - $updateQuery->bindValue(':userid', $userid, PDO::PARAM_STR); - $res_follow = $updateQuery->execute(); - - send_notification($userData["userid"], $userid, "🎉" . $userid . "さんにフォローされました!🎉", "" . $userid . "さんにフォローされました。", "/@" . $userid . "", "follow"); - - if ($res && $res_follow) { - $pdo->commit(); - $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; - header("Location:" . $url); - exit; - } else { - $pdo->rollBack(); - $error_message[] = '更新に失敗しました。(REGISTERED_DAME)'; - } - } - } catch (Exception $e) { - // ロールバック - $pdo->rollBack(); + $res_follow = follow_user($pdo, $userData['userid'], $userid); + if($res_follow === false){ $error_message[] = '更新に失敗しました。(REGISTERED_DAME)'; + }else{ + $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + header("Location:" . $url); + exit; } } elseif (!empty($_POST['unfollow'])) { - // トランザクションを開始 - $pdo->beginTransaction(); - try { - // フォロー解除ボタンが押された場合の処理 - $followerList = explode(',', $userdata['follower']); - if (in_array($userid, $followerList)) { - // 自分が相手をフォローしている場合、相手のfollowerカラムと自分のfollowカラムを更新 - $followerList = array_diff($followerList, array($userid)); - $newFollowerList = implode(',', $followerList); - - // UPDATE文を実行してフォロー情報を更新 - $updateQuery = $pdo->prepare("UPDATE account SET follower = :follower WHERE userid = :userid"); - $updateQuery->bindValue(':follower', $newFollowerList, PDO::PARAM_STR); - $updateQuery->bindValue(':userid', $userData['userid'], PDO::PARAM_STR); - $res = $updateQuery->execute(); - - $myflwlist = explode(',', $myfollowlist); - $delfollowList = array_diff($myflwlist, array($userData['userid'])); - $deluserid = implode(',', $delfollowList); - - // 自分のfollowカラムから相手のユーザーIDを削除 - $updateQuery = $pdo->prepare("UPDATE account SET follow = :follow WHERE userid = :userid"); - $updateQuery->bindValue(':follow', $deluserid, PDO::PARAM_STR); - $updateQuery->bindValue(':userid', $userid, PDO::PARAM_STR); - $res_follow = $updateQuery->execute(); - - if ($res && $res_follow) { - // コミット - $pdo->commit(); - - // リダイレクト - $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; - header("Location:" . $url); - exit; - } else { - // ロールバック - $pdo->rollBack(); - $error_message[] = '更新に失敗しました。(REGISTERED_DAME)'; - } - - $stmt = null; - } - } catch (Exception $e) { - // ロールバック - $pdo->rollBack(); + $res_unfollow = unfollow_user($pdo, $userData['userid'], $userid); + if($res_unfollow === false){ $error_message[] = '更新に失敗しました。(REGISTERED_DAME)'; + }else{ + $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + header("Location:" . $url); + exit; } } if (!empty($_POST['send_block_submit'])) { - - $pdo->beginTransaction(); - try { - $updateQuery = $pdo->prepare("UPDATE account SET blocklist = CONCAT_WS(',', blocklist, :blocklist) WHERE userid = :userid"); - $updateQuery->bindValue(':blocklist', $userData["userid"], PDO::PARAM_STR); - $updateQuery->bindValue(':userid', $userid, PDO::PARAM_STR); - $res_block = $updateQuery->execute(); - - // フォロー解除ボタンが押された場合の処理 - $followerList = explode(',', $userdata['follower']); - if (in_array($userid, $followerList)) { - // 自分が相手をフォローしている場合、相手のfollowerカラムと自分のfollowカラムを更新 - $followerList = array_diff($followerList, array($userid)); - $newFollowerList = implode(',', $followerList); - - // UPDATE文を実行してフォロー情報を更新 - $updateQuery = $pdo->prepare("UPDATE account SET follower = :follower WHERE userid = :userid"); - $updateQuery->bindValue(':follower', $newFollowerList, PDO::PARAM_STR); - $updateQuery->bindValue(':userid', $userData['userid'], PDO::PARAM_STR); - $res = $updateQuery->execute(); - - $myflwlist = explode(',', $myfollowlist); - $delfollowList = array_diff($myflwlist, array($userData['userid'])); - $deluserid = implode(',', $delfollowList); - // 自分のfollowカラムから相手のユーザーIDを削除 - $updateQuery = $pdo->prepare("UPDATE account SET follow = :follow WHERE userid = :userid"); - $updateQuery->bindValue(':follow', $deluserid, PDO::PARAM_STR); - $updateQuery->bindValue(':userid', $userid, PDO::PARAM_STR); - $res_follow = $updateQuery->execute(); - - if ($res && $res_follow) { - $pdo->commit(); - $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; - header("Location:" . $url); - exit; - } else { - $pdo->rollBack(); - $error_message[] = '更新に失敗しました。(REGISTERED_DAME)'; - } - - $stmt = null; - } - - if ($res_block) { - $pdo->commit(); - $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; - header("Location:" . $url); - exit; - } else { - $pdo->rollBack(); - $error_message[] = '更新に失敗しました。(REGISTERED_DAME)'; - } - } catch (Exception $e) { - // ロールバック - $pdo->rollBack(); + $res_block = block_user($pdo, $userData['userid'], $userid); + if($res_block === false){ $error_message[] = '更新に失敗しました。(REGISTERED_DAME)'; + }else{ + $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + header("Location:" . $url); + exit; } } elseif (!empty($_POST['send_un_block_submit'])) { - $pdo->beginTransaction(); - try { - $myblklist = explode(',', $myblocklist); - $delblkList = array_diff($myblklist, array($userData['userid'])); - $deluserid = implode(',', $delblkList); - // 自分のfollowカラムから相手のユーザーIDを削除 - $updateQuery = $pdo->prepare("UPDATE account SET blocklist = :blocklist WHERE userid = :userid"); - $updateQuery->bindValue(':blocklist', $deluserid, PDO::PARAM_STR); - $updateQuery->bindValue(':userid', $userid, PDO::PARAM_STR); - $res_block = $updateQuery->execute(); - - if ($res_block) { - $pdo->commit(); - $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; - header("Location:" . $url); - exit; - } else { - $pdo->rollBack(); - $error_message[] = '更新に失敗しました。(REGISTERED_DAME)'; - } - } catch (Exception $e) { - // ロールバック - $pdo->rollBack(); + $res_unblock = unblock_user($pdo, $userData['userid'], $userid); + if($res_unblock === false){ $error_message[] = '更新に失敗しました。(REGISTERED_DAME)'; + }else{ + $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + header("Location:" . $url); + exit; } } @@ -799,6 +659,7 @@ $pdo = null;