0,
'path' => '/',
'domain' => '',
'secure' => true,
'httponly' => true,
'samesite' => 'Lax'
]);
session_start();
session_regenerate_id(true);
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) {
// 接続エラーのときエラー内容を取得する
$error_message[] = $e->getMessage();
}
//ログイン認証---------------------------------------------------
blockedIP($_SERVER['REMOTE_ADDR']);
$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "user");
if($is_login === false){
header("Location: ../index.php");
exit;
}else{
$userid = safetext($is_login['userid']);
$username = safetext($is_login['username']);
$loginid = safetext($is_login["loginid"]);
$role = safetext($is_login["role"]);
$sacinfo = safetext($is_login["sacinfo"]);
$myblocklist = safetext($is_login["blocklist"]);
$myfollowlist = safetext($is_login["follow"]);
$is_Admin = safetext($is_login["admin"]);
}
$notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'");
$notiQuery->bindValue(':userid', $userid);
$notiQuery->execute();
$notiData = $notiQuery->fetch(PDO::FETCH_ASSOC);
$notificationcount = $notiData['notification_count'];
if( !empty($pdo) ) {
// データベース接続の設定
$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,
));
$userQuery = $dbh->prepare("SELECT userid,token,role FROM account WHERE userid = :userid");
$userQuery->bindValue(':userid', $userid);
$userQuery->execute();
$userData = $userQuery->fetch();
}
if( !empty($_POST['btn_submit']) ) {
$chkuserid = safetext($_POST['chkuserid']);
if( empty($chkuserid) ) {
$error_message[] = '確認用ユーザーIDを入力してください。(USERID_CHECK_INPUT_PLEASE)';
} else {
if($chkuserid === $userData["userid"]){
$userId = $userData["userid"]; // 削除対象のユーザーID
$folderPath = "../ueuseimages/"; // フォルダのパス
// 指定したフォルダ内でユーザーIDを含むファイルを検索
$filesToDelete = glob($folderPath . "*-$userId.*"); // 「-ユーザーID.拡張子」というパターンを検索
// ファイルを順に削除
foreach ($filesToDelete as $file) {
if (is_file($file)) {
unlink($file); // ファイルを削除
}
}
$folderPath2 = "../ueusevideos/"; // フォルダのパス
// 指定したフォルダ内でユーザーIDを含むファイルを検索
$filesToDelete2 = glob($folderPath2 . "*-$userId.*"); // 「-ユーザーID.拡張子」というパターンを検索
// ファイルを順に削除
foreach ($filesToDelete2 as $file2) {
if (is_file($file2)) {
unlink($file2); // ファイルを削除
}
}
$folderPath3 = "../usericons/"; // フォルダのパス
// 指定したフォルダ内でユーザーIDを含むファイルを検索
$filesToDelete3 = glob($folderPath3 . "*-$userId.*"); // 「-ユーザーID.拡張子」というパターンを検索
// ファイルを順に削除
foreach ($filesToDelete3 as $file3) {
if (is_file($file3)) {
unlink($file3); // ファイルを削除
}
}
$folderPath4 = "../userheads/"; // フォルダのパス
// 指定したフォルダ内でユーザーIDを含むファイルを検索
$filesToDelete4 = glob($folderPath4 . "*-$userId.*"); // 「-ユーザーID.拡張子」というパターンを検索
// ファイルを順に削除
foreach ($filesToDelete4 as $file4) {
if (is_file($file4)) {
unlink($file4); // ファイルを削除
}
}
// フォロー・フォロワー情報を削除したい全てのアカウントを取得
$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 {
// 投稿削除クエリを実行
$deleteQuery = $pdo->prepare("DELETE FROM ueuse WHERE account = :userid");
$deleteQuery->bindValue(':userid', $userid, PDO::PARAM_STR);
$res = $deleteQuery->execute();
// 通知削除クエリを実行(自分宛ての通知)
$deleteQuery = $pdo->prepare("DELETE FROM notification WHERE touserid = :touserid");
$deleteQuery->bindValue(':touserid', $userid, PDO::PARAM_STR);
$res = $deleteQuery->execute();
// 通知削除クエリを実行(自分からの通知)
$deleteQuery = $pdo->prepare("DELETE FROM notification WHERE fromuserid = :fromuserid");
$deleteQuery->bindValue(':fromuserid', $userid, 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', "%,$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['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);
$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', $userid, PDO::PARAM_STR);
$res = $deleteQuery->execute();
$pdo->commit();
} catch (Exception $e) {
// エラーが発生した時はロールバック
$pdo->rollBack();
actionLog($userid, "error", "deleteAccount", null, $e, 4);
}
if ($res) {
if (isset($_SERVER['HTTP_COOKIE'])) {
$cookies = explode(';', $_SERVER['HTTP_COOKIE']);
foreach($cookies as $cookie) {
$parts = explode('=', $cookie);
$name = trim($parts[0]);
setcookie($name, '', time()-1000);
setcookie($name, '', time()-1000, '/');
}
}
header("Location:../index.php");
exit;
} else {
$error_message[] = 'アカウント削除に失敗しました。(ACCOUNT_DELETE_DAME)';
}
// プリペアドステートメントを削除
$stmt = null;
}else{
$error_message[] = '確認用ユーザーIDが違います。(USERID_CHIGAUYANKE)';
}
}
}
if( !empty($_POST['session_submit']) ) {
$LoginIdBytes = random_bytes(64);
$loginid = hash('sha3-512', $LoginIdBytes);
$pdo->beginTransaction();
try {
$stmt = $pdo->prepare("UPDATE account SET loginid = :loginid WHERE userid = :userid;");
$stmt->bindParam(':loginid', $loginid, PDO::PARAM_STR);
$stmt->bindValue(':userid', $userid, PDO::PARAM_STR);
// SQLクエリの実行
$res = $stmt->execute();
// コミット
$res = $pdo->commit();
} catch (Exception $e) {
// エラーが発生した時はロールバック
$pdo->rollBack();
}
if ($res) {
if (isset($_SERVER['HTTP_COOKIE'])) {
$cookies = explode(';', $_SERVER['HTTP_COOKIE']);
foreach($cookies as $cookie) {
$parts = explode('=', $cookie);
$name = trim($parts[0]);
setcookie($name, '', time()-1000);
setcookie($name, '', time()-1000, '/');
}
}
// リダイレクト先のURLへ転送する
$url = '../index.php';
header('Location: ' . $url, true, 303);
// すべての出力を終了
exit;
} else {
$error_message[] = 'セッショントークンの再生成に失敗しました。(END_OF_SESSION_DAME)';
}
}
if( !empty($_POST['logout_submit']) ) {
$url = '../logout/index.php';
header('Location: ' . $url);
exit;
}
if( !empty($_POST['token_submit']) ) {
$token = random_token();
$nones = "none";
$pdo->beginTransaction();
try {
$stmt = $pdo->prepare("UPDATE account SET token = :token, sacinfo = :new_sacinfo WHERE userid = :userid;");
$stmt->bindParam(':token', $token, PDO::PARAM_STR);
$stmt->bindParam(':new_sacinfo', $nones, PDO::PARAM_STR);
$stmt->bindValue(':userid', $userid, PDO::PARAM_STR);
// SQLクエリの実行
$res = $stmt->execute();
// コミット
$res = $pdo->commit();
} catch (Exception $e) {
// エラーが発生した時はロールバック
$pdo->rollBack();
}
if ($res) {
$_SESSION['token'] = $token;
// リダイレクト先のURLへ転送する
$url = 'token.php';
header('Location: ' . $url, true, 303);
exit;
} else {
$error_message[] = 'アクセストークンの発行に失敗しました。(CREATE_TOKEN_DAME)';
}
}
if( !empty($_POST['token_off_submit']) ) {
$token = '';
$new_sacinfo = 'none';
$pdo->beginTransaction();
try {
$stmt = $pdo->prepare("UPDATE account SET token = :token,sacinfo = :sacinfo WHERE userid = :userid;");
$stmt->bindParam(':token', $token, PDO::PARAM_STR);
$stmt->bindParam(':sacinfo', $new_sacinfo, PDO::PARAM_STR);
$stmt->bindValue(':userid', $userid, PDO::PARAM_STR);
// SQLクエリの実行
$res = $stmt->execute();
// コミット
$res = $pdo->commit();
} catch (Exception $e) {
// エラーが発生した時はロールバック
$pdo->rollBack();
}
if ($res) {
$url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
header("Location:".$url."");
exit;
} else {
$error_message[] = 'アクセストークンの削除に失敗しました。(TOKEN_DELETE_DAME)';
}
}
if( !empty($_POST['cache_submit']) ) {
header("Location: cache_clear.php");
exit;
}
require('../logout/logout.php');
?>
その他の項目 -
もしものときは
こんにちは、uwuzu開発者のだいちまるです。
ここを見ているということはなにかあったのでしょうか...
心配です。
もし炎上をしてしまったり、インターネットによる心身のつらさなどに襲われ生きづらかったり周りと触れづらい状態にあるならば信頼できる人への相談や失踪をして、インターネットの海から離れるのも良いかもしれません。
インターネットが全てではないですし、このサーバーからいなくなるだけでも気が楽になるかもしれません。
一度ゆっくり休んでから人生を再開してみてはいかがでしょうか、自分を第一に、自分を大事に。
そして、インターネットは情報の海であることを忘れないように。