From bc8b6cd800ab6735dc398f78c47a76f17018c769 Mon Sep 17 00:00:00 2001 From: Daichimarukana Date: Sun, 26 Jan 2025 16:06:37 +0900 Subject: [PATCH] uwuzu v1.4.14 Funium --- api/ueuse/create.php | 4 +- bookmark/bookmark.php | 4 +- delete/delete.php | 2 +- function/function.php | 295 ++++++++++++++++++++--------- home/index.php | 43 +++-- js/nsfw_event.js | 2 +- js/unsupported.js | 1 + nextpage/bookmark.php | 35 ++-- nextpage/foryoupage.php | 8 +- others/index.php | 92 ++++----- server/uwuzuinfo.txt | 4 +- server/uwuzurelease.txt | 17 ++ settings_admin/actionlog_admin.php | 2 +- settings_admin/ipblock_admin.php | 44 ++++- settings_admin/userinfo.php | 233 +++++++++++++++-------- ueuse/index.php | 43 +++-- update.json | 29 ++- uwuzu_database.sql | 5 +- 18 files changed, 588 insertions(+), 275 deletions(-) diff --git a/api/ueuse/create.php b/api/ueuse/create.php index 3017730..f387565 100644 --- a/api/ueuse/create.php +++ b/api/ueuse/create.php @@ -221,6 +221,7 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { $uniqid = safetext(createUniqId()); $abi = "none"; $nones = "none"; + $popularity = 0; // トランザクション開始 $pdo->beginTransaction(); @@ -228,7 +229,7 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { try { // SQL作成 - $stmt = $pdo->prepare("INSERT INTO ueuse (username, account, uniqid, rpuniqid, ueuse, photo1, photo2, photo3, photo4, video1, datetime, abi, nsfw) VALUES (:username, :account, :uniqid, :rpuniqid, :ueuse, :photo1, :photo2, :photo3, :photo4, :video1, :datetime, :abi, :nsfw)"); + $stmt = $pdo->prepare("INSERT INTO ueuse (username, account, uniqid, rpuniqid, ueuse, photo1, photo2, photo3, photo4, video1, datetime, abi, nsfw, popularity) VALUES (:username, :account, :uniqid, :rpuniqid, :ueuse, :photo1, :photo2, :photo3, :photo4, :video1, :datetime, :abi, :nsfw, :popularity)"); $stmt->bindParam(':username', $username, PDO::PARAM_STR); $stmt->bindParam(':account', $userid, PDO::PARAM_STR); @@ -246,6 +247,7 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) { $stmt->bindParam(':abi', $abi, PDO::PARAM_STR); $stmt->bindParam(':nsfw', $nsfw, PDO::PARAM_STR); + $stmt->bindParam(':popularity', $popularity, PDO::PARAM_INT); // SQLクエリの実行 $res = $stmt->execute(); diff --git a/bookmark/bookmark.php b/bookmark/bookmark.php index bee15a6..df9c410 100644 --- a/bookmark/bookmark.php +++ b/bookmark/bookmark.php @@ -66,7 +66,7 @@ if (safetext(isset($_POST['uniqid'])) && safetext(isset($_POST['userid'])) && sa echo json_encode(['success' => true, 'newbookmark' => 'success']); exit; } else { - echo json_encode(['success' => false, 'error' => 'いいねの更新に失敗しました。']); + echo json_encode(['success' => false, 'error' => 'ブックマークの更新に失敗しました。']); exit; } @@ -76,7 +76,7 @@ if (safetext(isset($_POST['uniqid'])) && safetext(isset($_POST['userid'])) && sa exit; } } catch(PDOException $e) { - echo json_encode(['success' => false, 'error' => 'データベースエラー:' . $e->getMessage()]); + echo json_encode(['success' => false, 'error' => 'データベースエラー']); exit; } } diff --git a/delete/delete.php b/delete/delete.php index 1e0e8a2..b3a592f 100644 --- a/delete/delete.php +++ b/delete/delete.php @@ -17,7 +17,7 @@ if (safetext(isset($_POST['uniqid'])) && safetext(isset($_POST['userid'])) && sa exit; } }else{ - echo json_encode(['success' => false, 'error' => '削除に失敗しました。(sess_err)']); + echo json_encode(['success' => false, 'error' => '削除に失敗しました。(ERROR)']); exit; } ?> diff --git a/function/function.php b/function/function.php index 879ac03..3be0bbc 100644 --- a/function/function.php +++ b/function/function.php @@ -1,25 +1,70 @@ $totalBits) { + actionLog(null, "error", "isIpInCIDR", null, "bad_prefix_length_".$prefixLength, 4); + return false; + } + + $mask = str_repeat("\xFF", (int)($prefixLength / 8)); + $remainingBits = $prefixLength % 8; + + if ($remainingBits > 0) { + $mask .= chr((0xFF << (8 - $remainingBits)) & 0xFF); + } + $mask = str_pad($mask, strlen($networkBinary), "\x00"); + + return ($ipBinary & $mask) === ($networkBinary & $mask); + }else{ + actionLog(null, "error", "isIpInCIDR", null, "bad_ip", 4); + return false; + } +} +function blockedIP($ip_addr) { // データベースに接続 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, + [ + 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) { - actionLog(null, "error", "blockedIP", null, $e, 4); + } catch (PDOException $e) { + error_log("Database connection failed: " . $e->getMessage()); return false; } - $search_query = $pdo->prepare('SELECT * FROM ipblock WHERE ipaddr = :ipaddr limit 1'); - $search_query->execute(array(':ipaddr' => $ip_addr)); - $result = $search_query->fetch(); + // IPブロックリストの取得 + $search_query = $pdo->prepare('SELECT ipaddr FROM ipblock'); + $search_query->execute(); + $blocked_ips = $search_query->fetchAll(PDO::FETCH_COLUMN); - if($result > 0){ - $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . "/unsupported.php?errcode=IP_BANNED"; - header("Location:".$url.""); - exit; + foreach ($blocked_ips as $blocked_ip) { + if (isIpInCIDR($ip_addr, $blocked_ip)) { + $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . "/unsupported.php?errcode=IP_BANNED"; + header("Location: " . $url); + exit; + } } } function uwuzuUserLogin($session, $cookie, $ip_addr, $operation_permission = "user") { @@ -854,58 +899,60 @@ function send_notification($to,$from,$title,$message,$url,$category){ } 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(); + $to_result = getUserData($pdo, $to); $category_list = ["system","favorite","reply","reuse","ueuse","follow","mention","other"]; if(in_array($category, $category_list)){ - if(in_array($category, explode(',', $result["notification_settings"])) || empty($result["notification_settings"]) || $category === "system" || $category === "other"){ - if(!(empty($pdo))){ - $pdo->beginTransaction(); - - try { - $fromuserid = safetext($from); - $touserid = safetext($to); - $datetime = date("Y-m-d H:i:s"); - $msg = safetext($message); - $title = safetext($title); - $url = safetext($url); - $userchk = 'none'; - $notification_category = safetext($category); - - // 通知用SQL作成 - $stmt = $pdo->prepare("INSERT INTO notification (fromuserid, touserid, msg, url, datetime, userchk, title, category) VALUES (:fromuserid, :touserid, :msg, :url, :datetime, :userchk, :title, :category)"); - - $stmt->bindParam(':fromuserid', $fromuserid, PDO::PARAM_STR); - $stmt->bindParam(':touserid', $touserid, PDO::PARAM_STR); - $stmt->bindParam(':msg', $msg, PDO::PARAM_STR); - $stmt->bindParam(':url', $url, PDO::PARAM_STR); - $stmt->bindParam(':userchk', $userchk, PDO::PARAM_STR); - $stmt->bindParam(':title', $title, PDO::PARAM_STR); - $stmt->bindParam(':category', $notification_category, PDO::PARAM_STR); - - $stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR); - - $res = $stmt->execute(); - - $res = $pdo->commit(); - - if($res){ - return true; - }else{ + if(in_array($category, explode(',', $to_result["notification_settings"])) || empty($to_result["notification_settings"]) || $category === "system" || $category === "other"){ + //ブロックされてたら送らない + if(!(in_array($from, explode(',', $to_result["blocklist"])))){ + if(!(empty($pdo))){ + $pdo->beginTransaction(); + try { + $fromuserid = safetext($from); + $touserid = safetext($to); + $datetime = date("Y-m-d H:i:s"); + $msg = safetext($message); + $title = safetext($title); + $url = safetext($url); + $userchk = 'none'; + $notification_category = safetext($category); + + // 通知用SQL作成 + $stmt = $pdo->prepare("INSERT INTO notification (fromuserid, touserid, msg, url, datetime, userchk, title, category) VALUES (:fromuserid, :touserid, :msg, :url, :datetime, :userchk, :title, :category)"); + + $stmt->bindParam(':fromuserid', $fromuserid, PDO::PARAM_STR); + $stmt->bindParam(':touserid', $touserid, PDO::PARAM_STR); + $stmt->bindParam(':msg', $msg, PDO::PARAM_STR); + $stmt->bindParam(':url', $url, PDO::PARAM_STR); + $stmt->bindParam(':userchk', $userchk, PDO::PARAM_STR); + $stmt->bindParam(':title', $title, PDO::PARAM_STR); + $stmt->bindParam(':category', $notification_category, PDO::PARAM_STR); + + $stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR); + + $res = $stmt->execute(); + + $res = $pdo->commit(); + + if($res){ + return true; + }else{ + $pdo->rollBack(); + actionLog($from, "error", "send_notification", $to, "通知の送信に失敗しました(rollBack)", 3); + return false; + } + + } catch(Exception $e) { $pdo->rollBack(); - actionLog($from, "error", "send_notification", $to, "通知の送信に失敗しました(rollBack)", 3); + actionLog($from, "error", "send_notification", $to, $e, 4); return false; } - - } catch(Exception $e) { - $pdo->rollBack(); - actionLog($from, "error", "send_notification", $to, $e, 4); + }else{ return false; } }else{ - return false; + return true; } }else{ // 受信しない設定なのでtrue @@ -1221,15 +1268,17 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ $datetime = date("Y-m-d H:i:s"); $uniqid = createUniqId(); $abi = "none"; + $popularity = 0; if(empty($rpUniqid) && empty($ruUniqid)){ + //-----------通常ユーズ----------- // トランザクション開始 $pdo->beginTransaction(); try { // SQL作成 - $stmt = $pdo->prepare("INSERT INTO ueuse (username, account, uniqid, ueuse, photo1, photo2, photo3, photo4, video1, datetime, abi, nsfw) VALUES (:username, :account, :uniqid, :ueuse, :photo1, :photo2, :photo3, :photo4, :video1, :datetime, :abi, :nsfw)"); + $stmt = $pdo->prepare("INSERT INTO ueuse (username, account, uniqid, ueuse, photo1, photo2, photo3, photo4, video1, datetime, abi, nsfw, popularity) VALUES (:username, :account, :uniqid, :ueuse, :photo1, :photo2, :photo3, :photo4, :video1, :datetime, :abi, :nsfw, :popularity)"); $stmt->bindParam(':username', $username, PDO::PARAM_STR); $stmt->bindParam(':account', $userid, PDO::PARAM_STR); @@ -1244,6 +1293,7 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ $stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR); $stmt->bindParam(':nsfw', $save_nsfw, PDO::PARAM_STR); + $stmt->bindParam(':popularity', $popularity, PDO::PARAM_INT); $stmt->bindParam(':abi', $abi, PDO::PARAM_STR); @@ -1265,6 +1315,7 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ 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"); $toUserIdQuery->bindValue(':ueuseid', $rpUniqid, PDO::PARAM_STR); $toUserIdQuery->execute(); @@ -1276,12 +1327,13 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ $touserid = null; } + changePopularity($pdo, $rpUniqid, $userid, 3); // トランザクション開始 $pdo->beginTransaction(); try { // SQL作成 - $stmt = $pdo->prepare("INSERT INTO ueuse (username, account, uniqid, rpuniqid, ueuse, photo1, photo2, photo3, photo4, video1, datetime, abi, nsfw) VALUES (:username, :account, :uniqid, :rpuniqid, :ueuse, :photo1, :photo2, :photo3, :photo4, :video1, :datetime, :abi, :nsfw)"); + $stmt = $pdo->prepare("INSERT INTO ueuse (username, account, uniqid, rpuniqid, ueuse, photo1, photo2, photo3, photo4, video1, datetime, abi, nsfw, popularity) VALUES (:username, :account, :uniqid, :rpuniqid, :ueuse, :photo1, :photo2, :photo3, :photo4, :video1, :datetime, :abi, :nsfw, :popularity)"); $stmt->bindParam(':username', $username, PDO::PARAM_STR); $stmt->bindParam(':account', $userid, PDO::PARAM_STR); @@ -1299,6 +1351,7 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ $stmt->bindParam(':nsfw', $save_nsfw, PDO::PARAM_STR); $stmt->bindParam(':abi', $abi, PDO::PARAM_STR); + $stmt->bindParam(':popularity', $popularity, PDO::PARAM_INT); // SQLクエリの実行 $res = $stmt->execute(); @@ -1319,6 +1372,7 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ 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"); $toUserIdQuery->bindValue(':ueuseid', $ruUniqid, PDO::PARAM_STR); $toUserIdQuery->execute(); @@ -1329,12 +1383,15 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ }else{ $touserid = null; } + + changePopularity($pdo, $ruUniqid, $userid, 2); + // トランザクション開始 $pdo->beginTransaction(); try { // SQL作成 - $stmt = $pdo->prepare("INSERT INTO ueuse (username, account, uniqid, ruuniqid, ueuse, photo1, photo2, photo3, photo4, video1, datetime, abi, nsfw) VALUES (:username, :account, :uniqid, :ruuniqid, :ueuse, :photo1, :photo2, :photo3, :photo4, :video1, :datetime, :abi, :nsfw)"); + $stmt = $pdo->prepare("INSERT INTO ueuse (username, account, uniqid, ruuniqid, ueuse, photo1, photo2, photo3, photo4, video1, datetime, abi, nsfw, popularity) VALUES (:username, :account, :uniqid, :ruuniqid, :ueuse, :photo1, :photo2, :photo3, :photo4, :video1, :datetime, :abi, :nsfw, :popularity)"); $stmt->bindParam(':username', $username, PDO::PARAM_STR); $stmt->bindParam(':account', $userid, PDO::PARAM_STR); @@ -1352,6 +1409,7 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ $stmt->bindParam(':nsfw', $save_nsfw, PDO::PARAM_STR); $stmt->bindParam(':abi', $abi, PDO::PARAM_STR); + $stmt->bindParam(':popularity', $popularity, PDO::PARAM_INT); // SQLクエリの実行 @@ -1502,6 +1560,20 @@ function delete_ueuse($uniqid, $userid, $account_id){ } } + $ru_tree_Chkquery = $pdo->prepare('SELECT * FROM ueuse WHERE uniqid = :ruuniqid limit 1'); + $ru_tree_Chkquery->execute(array(':ruuniqid' => $result["ruuniqid"])); + $result4 = $ru_tree_Chkquery->fetch(); + if($result4 > 0){ + changePopularity($pdo, $result["ruuniqid"], $userid, -2); + } + + $rp_tree_Chkquery = $pdo->prepare('SELECT * FROM ueuse WHERE uniqid = :rpuniqid limit 1'); + $rp_tree_Chkquery->execute(array(':rpuniqid' => $result["rpuniqid"])); + $result5 = $rp_tree_Chkquery->fetch(); + if($result5 > 0){ + changePopularity($pdo, $result["rpuniqid"], $userid, -3); + } + try { // 削除クエリを実行 $deleteQuery = $pdo->prepare("DELETE FROM ueuse WHERE uniqid = :uniqid AND account = :userid"); @@ -1581,6 +1653,7 @@ function follow_user($pdo, $to_userid, $userid){ return false; } }else{ + $pdo->rollBack(); return true; } } catch (Exception $e) { @@ -1644,6 +1717,7 @@ function unfollow_user($pdo, $to_userid, $userid){ return false; } }else{ + $pdo->rollBack(); return true; } } catch (Exception $e) { @@ -1703,6 +1777,7 @@ function block_user($pdo, $to_userid, $userid){ return false; } }else{ + $pdo->rollBack(); return true; } } catch (Exception $e) { @@ -1756,6 +1831,7 @@ function unblock_user($pdo, $to_userid, $userid){ return false; } }else{ + $pdo->rollBack(); return true; } } catch (Exception $e) { @@ -1771,31 +1847,80 @@ function unblock_user($pdo, $to_userid, $userid){ return false; } } +function changePopularity($pdo, $uniqid, $userid, $change_range){ + if (!(empty($pdo)) && !(empty($uniqid))){ + if(is_numeric($change_range)){ + $pdo->beginTransaction(); + try { + // 投稿のいいね情報を取得 + $stmt = $pdo->prepare("SELECT popularity FROM ueuse WHERE uniqid = :uniqid"); + $stmt->bindValue(':uniqid', $uniqid, PDO::PARAM_STR); + $stmt->execute(); + $post = $stmt->fetch(PDO::FETCH_ASSOC); + + if (!(empty($post))) { + $new_popularity = (int)$post['popularity'] + (int)$change_range; + if($new_popularity >= 2147483647){ + $new_popularity = 2147483647; + } + + $updateQuery = $pdo->prepare("UPDATE ueuse SET popularity = :popularity WHERE uniqid = :uniqid"); + $updateQuery->bindValue(':popularity', $new_popularity, PDO::PARAM_INT); + $updateQuery->bindValue(':uniqid', $uniqid, PDO::PARAM_STR); + $res = $updateQuery->execute(); + + if ($res) { + $pdo->commit(); + return true; + } else { + $pdo->rollBack(); + actionLog($userid, "error", "changePopularity", $uniqid, "いいねに失敗しました", 3); + return false; + } + } else { + $pdo->rollBack(); + return false; + } + } catch(PDOException $e) { + actionLog($userid, "error", "changePopularity", $uniqid, $e, 4); + return false; + } + }else{ + actionLog($userid, "error", "changePopularity", $uniqid, "不正な変更値です", 4); + 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); + // 投稿のいいね情報を取得 + $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 (!(empty($post))) { + $favoriteList = explode(',', $post['favorite']); + $index = array_search($userid, $favoriteList); - if ($index === false) { - // ユーザーIDを追加 - $favoriteList[] = $userid; + 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); - } + send_notification(safetext($post['account']),$userid,"".$userid."さんがいいねしました!",safetext($post['ueuse']),"/!".$uniqid."","favorite"); + + //1いいねでスコアが1増加 + changePopularity($pdo, $uniqid, $userid, 1); + } else { + // ユーザーIDを削除 + array_splice($favoriteList, $index, 1); + + //1いいね解除でスコアが1減る + changePopularity($pdo, $uniqid, $userid, -1); + } + $pdo->beginTransaction(); + try { // 新しいいいね情報を更新 $newFavorite = implode(',', $favoriteList); $updateQuery = $pdo->prepare("UPDATE ueuse SET favorite = :favorite WHERE uniqid = :uniqid"); @@ -1811,13 +1936,13 @@ function addFavorite($pdo, $uniqid, $userid){ 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]; } - } catch(PDOException $e) { - actionLog($userid, "error", "addFavorite", $uniqid, $e, 4); - return [false, "データベースエラー", null]; + } else { + $pdo->rollBack(); + return [false, "投稿が見つかりませんでした", null]; } } } diff --git a/home/index.php b/home/index.php index 8dc01fc..59142e8 100644 --- a/home/index.php +++ b/home/index.php @@ -1091,24 +1091,45 @@ $(document).ready(function() { if($("#error").length){ $("#error").hide(); } - - EmojiClickEvent(); }, error: function (xhr, textStatus, errorThrown) { // エラーと判定された場合 isEmojiLoading = false; $("#error").show(); - EmojiClickEvent(); }, }); } - function EmojiClickEvent() { - $(".one_emoji").click(function (event) { - event.preventDefault(); - var children = $(this).children("img"); - var custom_emojiname = children.attr("title"); - $("#ueuse").val($("#ueuse").val() + custom_emojiname); - }); - } + + var last_cursor_at = 0; + $('body').on('click', '.one_emoji', function(event) { + event.preventDefault(); + + var children = $(this).children("img"); + var custom_emojiname = children.attr("title"); + + var input = $("#ueuse").get(0); + var now_ueuse = $("#ueuse").val(); + + var cursor_at = (input && input.selectionStart !== undefined) ? input.selectionStart : last_cursor_at; + + var front = now_ueuse.slice(0, cursor_at); + var back = now_ueuse.slice(cursor_at); + $("#ueuse").val(front + custom_emojiname + back); + + last_cursor_at = cursor_at + custom_emojiname.length; + + // 挿入後にフォーカスとカーソルを維持 + $("#ueuse").focus(); + if (input) { + input.setSelectionRange(last_cursor_at, last_cursor_at); + } + }); + + $("#ueuse").on("click keyup", function() { + var input = $(this).get(0); + if (input && input.selectionStart !== undefined) { + last_cursor_at = input.selectionStart; + } + }); }); \ No newline at end of file diff --git a/js/nsfw_event.js b/js/nsfw_event.js index 97f895d..022f438 100644 --- a/js/nsfw_event.js +++ b/js/nsfw_event.js @@ -78,7 +78,7 @@ function isHarmfulContent(text, examples, keywords, similarityThreshold = 0.7) { nonHarmfulCharCount -= harmfulText.length; } - if (harmfulCharCount > nonHarmfulCharCount) { + if (harmfulCharCount > nonHarmfulCharCount || harmfulCharCount > 6) { return true; } else { return false; diff --git a/js/unsupported.js b/js/unsupported.js index 9e9e2da..361c243 100644 --- a/js/unsupported.js +++ b/js/unsupported.js @@ -81,6 +81,7 @@ if (navigator.cookieEnabled) { } /*Main Access check*/ + if (user_agent_browser == 'Microsoft_Internet_Explorer' || user_agent_browser == 'NintendoBrowser') { user_agent_access = 'bad'; errcode = 'UNSUPPORTED_BROWSER'; diff --git a/nextpage/bookmark.php b/nextpage/bookmark.php index adac82f..849c7e7 100644 --- a/nextpage/bookmark.php +++ b/nextpage/bookmark.php @@ -57,30 +57,33 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $bookmarkQuery->execute(); $bookmarkData = $bookmarkQuery->fetch(); $bookmark = $bookmarkData['bookmark']; - $bookmarkList = explode(',', $bookmark); + $bookmarkList = array_chunk(array_reverse(explode(',', $bookmark)),$itemsPerPage); // フォローしているユーザーの投稿を取得し、日時順に並び替える $messages = array(); // 初期化 - foreach ($bookmarkList as $bookmarkUniqId) { - $sql = "SELECT ueuse.* - FROM ueuse - LEFT JOIN account ON ueuse.account = account.userid - WHERE uniqid = :bookmarkUniqId AND account.role != 'ice' - ORDER BY ueuse.datetime DESC - LIMIT :offset, :itemsPerPage"; + $list_Page = (int)$pageNumber - 1; - $stmt = $pdo->prepare($sql); - $stmt->bindValue(':bookmarkUniqId', $bookmarkUniqId, PDO::PARAM_STR); - $stmt->bindValue(':offset', $offset, PDO::PARAM_INT); - $stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT); - $stmt->execute(); + if(!(empty($bookmarkList[$list_Page]))){ + foreach ($bookmarkList[$list_Page] as $bookmarkUniqId) { + $sql = "SELECT ueuse.* + FROM ueuse + LEFT JOIN account ON ueuse.account = account.userid + WHERE uniqid = :bookmarkUniqId AND account.role != 'ice' + ORDER BY ueuse.datetime DESC"; - while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { - $messages[] = $row; + $stmt = $pdo->prepare($sql); + $stmt->bindValue(':bookmarkUniqId', $bookmarkUniqId, PDO::PARAM_STR); + $stmt->execute(); + + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { + $messages[] = $row; + } } + }else{ + $messages = []; } - $messages = array_reverse($messages); + // ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える foreach ($messages as &$message) { $userQuery = $pdo->prepare("SELECT username, userid, profile, role, iconname, headname, sacinfo FROM account WHERE userid = :userid"); diff --git a/nextpage/foryoupage.php b/nextpage/foryoupage.php index f78d2fb..3d8a420 100644 --- a/nextpage/foryoupage.php +++ b/nextpage/foryoupage.php @@ -94,11 +94,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $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 + ueuse.* FROM ueuse LEFT JOIN account ON ueuse.account = account.userid @@ -109,7 +105,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { AND account.role != 'ice' ORDER BY - total_score DESC + ueuse.popularity DESC LIMIT :offset, :itemsPerPage; "; diff --git a/others/index.php b/others/index.php index 95c8eaf..931adff 100644 --- a/others/index.php +++ b/others/index.php @@ -145,19 +145,50 @@ if( !empty($_POST['btn_submit']) ) { } } + // フォロー・フォロワー情報を削除したい全てのアカウントを取得 + $flw_query = $pdo->prepare("SELECT * + FROM account + WHERE follow LIKE :pattern1 + OR follow LIKE :pattern2 + OR follow LIKE :pattern3 + OR follower LIKE :pattern1 + OR follower LIKE :pattern2 + OR follower LIKE :pattern3 + "); + $flw_query->bindValue(':pattern1', "%,$userid,%", PDO::PARAM_STR); // 中間に位置する場合 + $flw_query->bindValue(':pattern2', "%,$userid", PDO::PARAM_STR); // 末尾に位置する場合 + $flw_query->bindValue(':pattern3', "$userid,%", PDO::PARAM_STR); // 先頭に位置する場合 + $flw_query->execute(); + $flw_accounts = $flw_query->fetchAll(); + foreach ($flw_accounts as $account) { + unfollow_user($pdo, $account['userid'], $userid); + unfollow_user($pdo, $userid, $account['userid']); + } + + // ユーザーIDを削除したい全てのアカウントを取得 + $blk_query = $pdo->prepare("SELECT * + FROM account + WHERE blocklist LIKE :pattern1 + OR blocklist LIKE :pattern2 + OR blocklist LIKE :pattern3 + "); + $blk_query->bindValue(':pattern1', "%,$userid,%", PDO::PARAM_STR); // 中間に位置する場合 + $blk_query->bindValue(':pattern2', "%,$userid", PDO::PARAM_STR); // 末尾に位置する場合 + $blk_query->bindValue(':pattern3', "$userid,%", PDO::PARAM_STR); // 先頭に位置する場合 + $blk_query->execute(); + $blk_accounts = $blk_query->fetchAll(); + + foreach ($blk_accounts as $account) { + unblock_user($pdo, $userid, $account['userid']); + } + + $pdo->beginTransaction(); try { - $pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS); - // 投稿削除クエリを実行 $deleteQuery = $pdo->prepare("DELETE FROM ueuse WHERE account = :userid"); $deleteQuery->bindValue(':userid', $userid, PDO::PARAM_STR); $res = $deleteQuery->execute(); - - // アカウント削除クエリを実行 - $deleteQuery = $pdo->prepare("DELETE FROM account WHERE userid = :userid"); - $deleteQuery->bindValue(':userid', $userid, PDO::PARAM_STR); - $res = $deleteQuery->execute(); // 通知削除クエリを実行(自分宛ての通知) $deleteQuery = $pdo->prepare("DELETE FROM notification WHERE touserid = :touserid"); @@ -169,40 +200,7 @@ if( !empty($_POST['btn_submit']) ) { $deleteQuery->bindValue(':fromuserid', $userid, PDO::PARAM_STR); $res = $deleteQuery->execute(); - // ユーザーIDを削除したい全てのアカウントを取得 - $query = $pdo->prepare("SELECT * FROM account WHERE follow LIKE :pattern1 OR follow LIKE :pattern2 OR follow LIKE :pattern3 OR follower LIKE :pattern1 OR follower LIKE :pattern2 OR follower LIKE :pattern3"); - $query->bindValue(':pattern1', "%,$userid,%", PDO::PARAM_STR); - $query->bindValue(':pattern2', "%,$userid", PDO::PARAM_STR); - $query->bindValue(':pattern3', "$userid,%", PDO::PARAM_STR); - $query->execute(); - $accounts = $query->fetchAll(); - - foreach ($accounts as $account) { - // フォローの更新 - if (strpos($account['follow'], ",$userid,") !== false || strpos($account['follow'], ",$userid") !== false || strpos($account['follow'], "$userid,") !== false) { - $followList = explode(',', $account['follow']); - $followList = array_diff($followList, array($userid)); - $newFollowList = implode(',', $followList); - - $updateFollowQuery = $pdo->prepare("UPDATE account SET follow = :follow WHERE userid = :userid"); - $updateFollowQuery->bindValue(':follow', $newFollowList, PDO::PARAM_STR); - $updateFollowQuery->bindValue(':userid', $account['userid'], PDO::PARAM_STR); - $updateFollowQuery->execute(); - } - - // フォロワーの更新 - if (strpos($account['follower'], ",$userid,") !== false || strpos($account['follower'], ",$userid") !== false || strpos($account['follower'], "$userid,") !== false) { - $followerList = explode(',', $account['follower']); - $followerList = array_diff($followerList, array($userid)); - $newFollowerList = implode(',', $followerList); - - $updateFollowerQuery = $pdo->prepare("UPDATE account SET follower = :follower WHERE userid = :userid"); - $updateFollowerQuery->bindValue(':follower', $newFollowerList, PDO::PARAM_STR); - $updateFollowerQuery->bindValue(':userid', $account['userid'], PDO::PARAM_STR); - $updateFollowerQuery->execute(); - } - } - + // いいねの削除 $query = $pdo->prepare("SELECT * FROM ueuse WHERE favorite LIKE :pattern1 OR favorite LIKE :pattern2 OR favorite LIKE :pattern3"); $query->bindValue(':pattern1', "%,$userid,%", PDO::PARAM_STR); $query->bindValue(':pattern2', "%,$userid", PDO::PARAM_STR); @@ -224,11 +222,15 @@ if( !empty($_POST['btn_submit']) ) { } } - + $deleteQuery = $pdo->prepare("DELETE FROM account WHERE userid = :userid"); + $deleteQuery->bindValue(':userid', $userid, PDO::PARAM_STR); + $res = $deleteQuery->execute(); + + $pdo->commit(); } catch (Exception $e) { - // エラーが発生した時はロールバック $pdo->rollBack(); + actionLog($userid, "error", "deleteAccount", null, $e, 4); } if ($res) { @@ -242,7 +244,7 @@ if( !empty($_POST['btn_submit']) ) { } } header("Location:../index.php"); - exit; + exit; } else { $error_message[] = 'アカウント削除に失敗しました。(ACCOUNT_DELETE_DAME)'; } @@ -451,7 +453,7 @@ require('../logout/logout.php');

アカウント削除

アカウント誤削除を防ぐため下の入力ボックスにご自身のユーザーIDを入力する必要があります。

- +

あなたはこのサーバーの管理者のようです。
管理者アカウントの移行は済んでいますか?
アカウントを削除しても大丈夫なのですか...?

diff --git a/server/uwuzuinfo.txt b/server/uwuzuinfo.txt index 2e41b94..abb529d 100644 --- a/server/uwuzuinfo.txt +++ b/server/uwuzuinfo.txt @@ -1,4 +1,4 @@ uwuzu -1.4.13 -2025/01/14 +1.4.14 +2025/01/26 daichimarukana,putonfps \ No newline at end of file diff --git a/server/uwuzurelease.txt b/server/uwuzurelease.txt index 7cd0795..f083c0d 100644 --- a/server/uwuzurelease.txt +++ b/server/uwuzurelease.txt @@ -1,6 +1,23 @@ ## リリースノートだぜぇぇぇぇぇぇい!!!!!!! ここにはuwuzuの更新情報を載せてくぜぇ~!(いやまてテンションおかしいだろ...) +## Version 1.4.14 (Funium) +2025/01/26 +fix: その他ページでのバグを修正しました。 +fix: 通知のバグを修正しました。 +fix: 絵文字ピッカーでワンクリックで複数個絵文字が入力されてしまう問題を修正しました。 +fix: フォロー・フォロー解除の操作が完全に終了していないにもかかわらず、正常に終了したと返してしまう問題を修正しました。 +fix: アカウント削除・BANに関するバグを修正しました! +chg: ブロックしているユーザーから通知が送信されないようにしました! +chg: IPブロック機能でCIDR表記に対応しました! +chg: 絵文字ピッカーでカーソル位置に絵文字を入力させるようにしました! +chg: おすすめタイムラインの動作を大幅に高速化しました! + このアップデートによりDBの更新が必要です。 + データベースのueuseテーブルにpopularity(int(11))というカラムを追加してください。 +chg: ユーザーを傷つけてしまうおそれのある投稿を未然に防ぐ機能を強化しました! +new: 管理者が個別でユーザーに通知を送信できる機能を実装しました! +uwuzu_database.sqlは更新済みです。 + ## Version 1.4.13 (Funium) 2025/01/14 fix: 正しい認証情報があるのにもかかわらずログアウトされてしまう問題を修正しました。 diff --git a/settings_admin/actionlog_admin.php b/settings_admin/actionlog_admin.php index 3f1fd3c..0aa672a 100644 --- a/settings_admin/actionlog_admin.php +++ b/settings_admin/actionlog_admin.php @@ -150,7 +150,7 @@ if (!empty($pdo)) {

ターゲット:


内容

-

+


diff --git a/settings_admin/ipblock_admin.php b/settings_admin/ipblock_admin.php index 9512c1b..b320f45 100644 --- a/settings_admin/ipblock_admin.php +++ b/settings_admin/ipblock_admin.php @@ -108,12 +108,25 @@ if (!empty($pdo)) { if( !empty($_POST['ip_btn_submit']) ) { $ipaddr = safetext($_POST['ipaddr']); + if (strpos($ipaddr, '/')) { + [$network, $prefixLength] = explode('/', $ipaddr); + }else{ + $network = $ipaddr; + $prefixLength = null; + } + $note = safetext($_POST['note']); - if(filter_var($ipaddr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) || filter_var($ipaddr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){ + if(filter_var($network, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) || filter_var($network, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){ $search_query = $pdo->prepare('SELECT * FROM ipblock WHERE ipaddr = :ipaddr limit 1'); - $search_query->execute(array(':ipaddr' => $ipaddr)); + if(!(empty($prefixLength))){ + $pre_ip = $network."/".$prefixLength; + $search_query->execute(array(':ipaddr' => $pre_ip)); + }else{ + $search_query->execute(array(':ipaddr' => $network)); + } + $result = $search_query->fetch(); if($result > 0){ @@ -157,10 +170,22 @@ if( !empty($_POST['ip_btn_submit']) ) { if( !empty($_POST['ip_del_submit']) ) { $ipaddr = safetext($_POST['del_ipaddr']); - - if(filter_var($ipaddr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) || filter_var($ipaddr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){ + + if (strpos($ipaddr, '/')) { + [$network, $prefixLength] = explode('/', $ipaddr); + }else{ + $network = $ipaddr; + $prefixLength = null; + } + + if(filter_var($network, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) || filter_var($network, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){ $search_query = $pdo->prepare('SELECT * FROM ipblock WHERE ipaddr = :ipaddr limit 1'); - $search_query->execute(array(':ipaddr' => $ipaddr)); + if(!(empty($prefixLength))){ + $pre_ip = $network."/".$prefixLength; + $search_query->execute(array(':ipaddr' => $pre_ip)); + }else{ + $search_query->execute(array(':ipaddr' => $network)); + } $result = $search_query->fetch(); if($result > 0){ @@ -168,6 +193,12 @@ if( !empty($_POST['ip_del_submit']) ) { try{ $deleteQuery = $pdo->prepare("DELETE FROM ipblock WHERE ipaddr = :ipaddr"); $deleteQuery->bindValue(':ipaddr', $ipaddr, PDO::PARAM_STR); + if(!(empty($prefixLength))){ + $pre_ip = $network."/".$prefixLength; + $deleteQuery->bindValue(':ipaddr', $pre_ip, PDO::PARAM_STR); + }else{ + $deleteQuery->bindValue(':ipaddr', $network, PDO::PARAM_STR); + } $res = $deleteQuery->execute(); $res = $pdo->commit(); } catch (Exception $e) { @@ -229,7 +260,8 @@ require('../logout/logout.php');

IPアドレスのブロック機能です。

IPアドレス

-
IPv4とIPv6に対応しています。
+
IPv4とIPv6に対応しています。
+ CIDR表記にも対応しています。
diff --git a/settings_admin/userinfo.php b/settings_admin/userinfo.php index 82ae1de..5376616 100644 --- a/settings_admin/userinfo.php +++ b/settings_admin/userinfo.php @@ -119,6 +119,35 @@ if (!empty($pdo)) { $upload_cnt1 = $result->rowCount(); } + +if( !empty($_POST['send_notification_submit']) ) { + $notice_title = safetext($_POST['notice_title']); + $notice_msg = safetext($_POST['notice_msg']); + if(empty($notice_title)){ + $error_message[] = "通知のタイトルを空欄にすることはできません。(INPUT_PLEASE)"; + }elseif(mb_strlen($notice_title) > 128){ + $error_message[] = "通知のタイトルを512文字以上にすることはできません。(INPUT_OVER_MAX_COUNT)"; + } + if(empty($notice_msg)){ + $error_message[] = "通知の本文を空欄にすることはできません。(INPUT_PLEASE)"; + }elseif(mb_strlen($notice_msg) > 128){ + $error_message[] = "通知の本文を16777216文字以上にすることはできません。(INPUT_OVER_MAX_COUNT)"; + } + if(empty($error_message)){ + $url = safetext("/rule/serverabout"); + $response = send_notification($userdata['userid'], "uwuzu-fromsys", $notice_title, $notice_msg, $url, "system"); + if($response == true){ + actionLog($userid, "info", "send_notification_submit", $userdata['userid'], $userdata['userid']."さんに".$userid."さんが通知を送信しました。\n".$notice_msg, 0); + header("Location:useradmin"); + exit; + }else{ + actionLog($userid, "error", "send_notification_submit", $userdata['userid'], $userdata['userid']."さんに".$userid."さんが通知を送信できませんでした。\n".$notice_msg, 4); + header("Location:useradmin"); + exit; + } + } +} + if( !empty($_POST['send_ice_submit']) ) { $notice_msg = $_POST['notice_msg']; @@ -366,81 +395,92 @@ if( !empty($_POST['send_ban_submit']) ) { try { - $pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS); + // フォロー・フォロワー情報を削除したい全てのアカウントを取得 + $flw_query = $pdo->prepare("SELECT * + FROM account + WHERE follow LIKE :pattern1 + OR follow LIKE :pattern2 + OR follow LIKE :pattern3 + OR follower LIKE :pattern1 + OR follower LIKE :pattern2 + OR follower LIKE :pattern3 + "); + $flw_query->bindValue(':pattern1', "%,$userId2,%", PDO::PARAM_STR); // 中間に位置する場合 + $flw_query->bindValue(':pattern2', "%,$userId2", PDO::PARAM_STR); // 末尾に位置する場合 + $flw_query->bindValue(':pattern3', "$userId2,%", PDO::PARAM_STR); // 先頭に位置する場合 + $flw_query->execute(); + $flw_accounts = $flw_query->fetchAll(); - // 投稿削除クエリを実行 - $deleteQuery = $pdo->prepare("DELETE FROM ueuse WHERE account = :userid"); - $deleteQuery->bindValue(':userid', $userId2, PDO::PARAM_STR); - $res = $deleteQuery->execute(); - - // アカウント削除クエリを実行 - $deleteQuery = $pdo->prepare("DELETE FROM account WHERE userid = :userid"); - $deleteQuery->bindValue(':userid', $userId2, PDO::PARAM_STR); - $res = $deleteQuery->execute(); - - // 通知削除クエリを実行 - $deleteQuery = $pdo->prepare("DELETE FROM notification WHERE touserid = :touserid"); - $deleteQuery->bindValue(':touserid', $userId2, PDO::PARAM_STR); - $res = $deleteQuery->execute(); - - // 通知削除クエリを実行(自分からの通知) - $deleteQuery = $pdo->prepare("DELETE FROM notification WHERE fromuserid = :fromuserid"); - $deleteQuery->bindValue(':fromuserid', $userId2, PDO::PARAM_STR); - $res = $deleteQuery->execute(); - - // ユーザーIDを削除したい全てのアカウントを取得 - $query = $pdo->prepare("SELECT * FROM account WHERE follow LIKE :pattern1 OR follow LIKE :pattern2 OR follow LIKE :pattern3 OR follower LIKE :pattern1 OR follower LIKE :pattern2 OR follower LIKE :pattern3"); - $query->bindValue(':pattern1', "%,$userid,%", PDO::PARAM_STR); - $query->bindValue(':pattern2', "%,$userid", PDO::PARAM_STR); - $query->bindValue(':pattern3', "$userid,%", PDO::PARAM_STR); - $query->execute(); - $accounts = $query->fetchAll(); - - foreach ($accounts as $account) { - // フォローの更新 - if (strpos($account['follow'], ",$userid,") !== false || strpos($account['follow'], ",$userid") !== false || strpos($account['follow'], "$userid,") !== false) { - $followList = explode(',', $account['follow']); - $followList = array_diff($followList, array($userid)); - $newFollowList = implode(',', $followList); - - $updateFollowQuery = $pdo->prepare("UPDATE account SET follow = :follow WHERE userid = :userid"); - $updateFollowQuery->bindValue(':follow', $newFollowList, PDO::PARAM_STR); - $updateFollowQuery->bindValue(':userid', $account['userid'], PDO::PARAM_STR); - $updateFollowQuery->execute(); - } - - // フォロワーの更新 - if (strpos($account['follower'], ",$userid,") !== false || strpos($account['follower'], ",$userid") !== false || strpos($account['follower'], "$userid,") !== false) { - $followerList = explode(',', $account['follower']); - $followerList = array_diff($followerList, array($userid)); - $newFollowerList = implode(',', $followerList); - - $updateFollowerQuery = $pdo->prepare("UPDATE account SET follower = :follower WHERE userid = :userid"); - $updateFollowerQuery->bindValue(':follower', $newFollowerList, PDO::PARAM_STR); - $updateFollowerQuery->bindValue(':userid', $account['userid'], PDO::PARAM_STR); - $updateFollowerQuery->execute(); - } + foreach ($flw_accounts as $account) { + unfollow_user($pdo, $account['userid'], $userId2); + unfollow_user($pdo, $userId2, $account['userid']); } - $query = $pdo->prepare("SELECT * FROM ueuse WHERE favorite LIKE :pattern1 OR favorite LIKE :pattern2 OR favorite LIKE :pattern3"); - $query->bindValue(':pattern1', "%,$userid,%", PDO::PARAM_STR); - $query->bindValue(':pattern2', "%,$userid", PDO::PARAM_STR); - $query->bindValue(':pattern3', "$userid,%", PDO::PARAM_STR); - $query->execute(); - $accounts = $query->fetchAll(); + // ユーザーIDを削除したい全てのアカウントを取得 + $blk_query = $pdo->prepare("SELECT * + FROM account + WHERE blocklist LIKE :pattern1 + OR blocklist LIKE :pattern2 + OR blocklist LIKE :pattern3 + "); + $blk_query->bindValue(':pattern1', "%,$userId2,%", PDO::PARAM_STR); // 中間に位置する場合 + $blk_query->bindValue(':pattern2', "%,$userId2", PDO::PARAM_STR); // 末尾に位置する場合 + $blk_query->bindValue(':pattern3', "$userId2,%", PDO::PARAM_STR); // 先頭に位置する場合 + $blk_query->execute(); + $blk_accounts = $blk_query->fetchAll(); - foreach ($accounts as $account) { - // いいねの更新 - if (strpos($account['favorite'], ",$userid,") !== false || strpos($account['favorite'], ",$userid") !== false || strpos($account['favorite'], "$userid,") !== false) { - $favoriteList = explode(',', $account['favorite']); - $favoriteList = array_diff($favoriteList, array($userid)); - $newFavoriteList = implode(',', $favoriteList); + foreach ($blk_accounts as $account) { + unblock_user($pdo, $userId2, $account['userid']); + } - $updateFavoriteQuery = $pdo->prepare("UPDATE ueuse SET favorite = :favorite WHERE uniqid = :uniqid"); - $updateFavoriteQuery->bindValue(':favorite', $newFavoriteList, PDO::PARAM_STR); - $updateFavoriteQuery->bindValue(':uniqid', $account['uniqid'], PDO::PARAM_STR); - $updateFavoriteQuery->execute(); + $pdo->beginTransaction(); + try { + // 投稿削除クエリを実行 + $deleteQuery = $pdo->prepare("DELETE FROM ueuse WHERE account = :userid"); + $deleteQuery->bindValue(':userid', $userId2, PDO::PARAM_STR); + $res = $deleteQuery->execute(); + + // 通知削除クエリを実行(自分宛ての通知) + $deleteQuery = $pdo->prepare("DELETE FROM notification WHERE touserid = :touserid"); + $deleteQuery->bindValue(':touserid', $userId2, PDO::PARAM_STR); + $res = $deleteQuery->execute(); + + // 通知削除クエリを実行(自分からの通知) + $deleteQuery = $pdo->prepare("DELETE FROM notification WHERE fromuserid = :fromuserid"); + $deleteQuery->bindValue(':fromuserid', $userId2, PDO::PARAM_STR); + $res = $deleteQuery->execute(); + + // いいねの削除 + $query = $pdo->prepare("SELECT * FROM ueuse WHERE favorite LIKE :pattern1 OR favorite LIKE :pattern2 OR favorite LIKE :pattern3"); + $query->bindValue(':pattern1', "%,$userId2,%", PDO::PARAM_STR); + $query->bindValue(':pattern2', "%,$userId2", PDO::PARAM_STR); + $query->bindValue(':pattern3', "$userId2,%", PDO::PARAM_STR); + $query->execute(); + $accounts = $query->fetchAll(); + + foreach ($accounts as $account) { + // いいねの更新 + if (strpos($account['favorite'], ",$userId2,") !== false || strpos($account['favorite'], ",$userId2") !== false || strpos($account['favorite'], "$userId2,") !== false) { + $favoriteList = explode(',', $account['favorite']); + $favoriteList = array_diff($favoriteList, array($userId2)); + $newFavoriteList = implode(',', $favoriteList); + + $updateFavoriteQuery = $pdo->prepare("UPDATE ueuse SET favorite = :favorite WHERE uniqid = :uniqid"); + $updateFavoriteQuery->bindValue(':favorite', $newFavoriteList, PDO::PARAM_STR); + $updateFavoriteQuery->bindValue(':uniqid', $account['uniqid'], PDO::PARAM_STR); + $updateFavoriteQuery->execute(); + } } + + $deleteQuery = $pdo->prepare("DELETE FROM account WHERE userid = :userid"); + $deleteQuery->bindValue(':userid', $userId2, PDO::PARAM_STR); + $res = $deleteQuery->execute(); + + $pdo->commit(); + } catch (Exception $e) { + // エラーが発生した時はロールバック + $pdo->rollBack(); + actionLog($userId2, "error", "deleteAccount", null, $e, 4); } //BAN通知メール @@ -576,18 +616,35 @@ require('../logout/logout.php');
アカウント操作
+ - + - + - +
+ +