diff --git a/abi/addabi.php b/abi/addabi.php
index 85e4d80..cee4b52 100644
--- a/abi/addabi.php
+++ b/abi/addabi.php
@@ -57,7 +57,7 @@ if (safetext(isset($_POST['uniqid'])) && safetext(isset($_POST['abitext'])) && s
if($result2["loginid"] === $loginid){
if($result["abi"] == "none" && (!($result2["role"] == "ice"))){
// 文字数を確認
- if( (int)safetext(file_get_contents($mojisizefile)) < mb_strlen($abitext, 'UTF-8') ) {
+ if( (int)safetext(file_get_contents($mojisizefile)) < mb_strlen(str_replace("\r\n", "\n", $abitext), 'UTF-8') ) {
$err = "content_to_".safetext(file_get_contents($mojisizefile))."_characters";
$response = array(
'error_code' => $err,
diff --git a/addauthcode.php b/addauthcode.php
index 3839e68..73a0da1 100644
--- a/addauthcode.php
+++ b/addauthcode.php
@@ -32,15 +32,6 @@ $stmt = null;
$res = null;
$option = null;
-
-if( !empty($_SESSION['userid']) ) {
- $userid = $_SESSION['userid'];
-}else{
- header("Location: login.php");
- exit;
-}
-
-
try {
$option = array(
@@ -55,134 +46,140 @@ try {
$error_message[] = $e->getMessage();
}
-//ログイン認証---------------------------------------------------
-blockedIP($_SERVER['REMOTE_ADDR']);
-$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "user");
-if(!($is_login === false)){
- header("Location: /home/");
- exit;
-}
-//-------------------------------------------------------------
-
-require_once 'authcode/GoogleAuthenticator.php';
-
-if(empty($_SESSION['secretcode'])){
- $authcode = new PHPGangsta_GoogleAuthenticator();
- $secret = $authcode->createSecret();
- $_SESSION['secretcode'] = $secret;
-}else{
- $authcode = new PHPGangsta_GoogleAuthenticator();
- $secret = $_SESSION['secretcode'];
-}
-
-if(!(empty($pdo))){
- // ユーザーデータ取得
- $userQuery = $pdo->prepare("SELECT * FROM account WHERE userid = :userid");
- $userQuery->bindValue(':userid', $userid);
- $userQuery->execute();
- $userData = $userQuery->fetch();
-}
-
-if( !empty($_POST['btn_submit']) ) {
- $chkauthcode = new PHPGangsta_GoogleAuthenticator();
- //二段階認証の確認
- $userauthcode = $_POST['usercode'];
-
- $discrepancy = 2;
-
- $checkResult = $chkauthcode->verifyCode($secret, $userauthcode, $discrepancy);
- if ($checkResult) {
- if( empty($error_message) ) {
- $backupcode = random();
- $hashbackupcode = uwuzu_password_hash($backupcode);
- $secret = $_SESSION['secretcode'];
-
- if(!(empty($userData["encryption_ivkey"]))){
- $userEnckey = GenUserEnckey($userData["datetime"]);
- $enc_seacret = EncryptionUseEncrKey($secret, $userEnckey, $userData["encryption_ivkey"]);
- }else{
- $ivLength = openssl_cipher_iv_length('aes-256-cbc');
- $randomBytes = random_bytes($ivLength);
- $randomhash = hash('sha3-512', $randomBytes);
- $iv = substr($randomhash, 0, $ivLength);
- // トランザクション開始
- $pdo->beginTransaction();
- try {
- // SQL作成
- $stmt = $pdo->prepare("UPDATE account SET encryption_ivkey = :encryption_ivkey WHERE userid = :userid;");
- $stmt->bindParam(':encryption_ivkey', $iv, PDO::PARAM_STR);
- $stmt->bindValue(':userid', $userid, PDO::PARAM_STR);
- $res = $stmt->execute();
- $res = $pdo->commit();
- } catch (Exception $e) {
- $pdo->rollBack();
- }
- if (!($res)) {
- $error_message[] = "アカウント操作に失敗しました(ERROR)";
- }
- $stmt = null;
-
- $userEnckey = GenUserEnckey($userData["datetime"]);
- $enc_seacret = EncryptionUseEncrKey($secret, $userEnckey, $iv);
- }
-
- // トランザクション開始
- $pdo->beginTransaction();
-
- try {
-
- // SQL作成
- $stmt = $pdo->prepare("UPDATE account SET authcode = :authcode,backupcode = :backupcode WHERE userid = :userid");
-
- $stmt->bindValue(':authcode', $enc_seacret, PDO::PARAM_STR);
- $stmt->bindValue(':backupcode', $hashbackupcode, PDO::PARAM_STR);
-
- // ユーザーIDのバインド(WHERE句に必要)
- $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, '/');
- }
- }
- $userid = "";
- $_SESSION['backupcode'] = $backupcode;
- // リダイレクト先のURLへ転送する
- $url = 'success.php';
- header('Location: ' . $url, true, 303);
- exit;
- } else {
- $error_message[] = '更新に失敗しました。(REGISTERED_DAME)';
- }
-
- // プリペアドステートメントを削除
- $stmt = null;
+if( !empty($pdo) ) {
+ $userData = getUserData($pdo, $_SESSION['userid']);
+ if(!(empty($userData))){
+ if($_SESSION['is_register_account'] === true){
+ $userid = $userData["userid"];
+ }else{
+ header("Location: login.php");
+ exit;
+ }
+ }else{
+ $_SESSION = array();
+ header("Location: index.php");
+ exit;
+ }
+
+ //ログイン認証---------------------------------------------------
+ blockedIP($_SERVER['REMOTE_ADDR']);
+ $is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "user");
+ if(!($is_login === false)){
+ header("Location: /home/");
+ exit;
+ }
+ //-------------------------------------------------------------
+
+ require_once 'authcode/GoogleAuthenticator.php';
+
+ if(empty($_SESSION['secretcode'])){
+ $authcode = new PHPGangsta_GoogleAuthenticator();
+ $secret = $authcode->createSecret();
+ $_SESSION['secretcode'] = $secret;
+ }else{
+ $authcode = new PHPGangsta_GoogleAuthenticator();
+ $secret = $_SESSION['secretcode'];
+ }
+
+ if(!(empty($pdo))){
+ // ユーザーデータ取得
+ $userQuery = $pdo->prepare("SELECT * FROM account WHERE userid = :userid");
+ $userQuery->bindValue(':userid', $userid);
+ $userQuery->execute();
+ $userData = $userQuery->fetch();
+ }
+
+ if( !empty($_POST['btn_submit']) ) {
+ $chkauthcode = new PHPGangsta_GoogleAuthenticator();
+ //二段階認証の確認
+ $userauthcode = $_POST['usercode'];
+
+ $discrepancy = 2;
+
+ $checkResult = $chkauthcode->verifyCode($secret, $userauthcode, $discrepancy);
+ if ($checkResult) {
+ if( empty($error_message) ) {
+ $backupcode = random();
+ $hashbackupcode = uwuzu_password_hash($backupcode);
+ $secret = $_SESSION['secretcode'];
+
+ if(!(empty($userData["encryption_ivkey"]))){
+ $userEnckey = GenUserEnckey($userData["datetime"]);
+ $enc_seacret = EncryptionUseEncrKey($secret, $userEnckey, $userData["encryption_ivkey"]);
+ }else{
+ $ivLength = openssl_cipher_iv_length('aes-256-cbc');
+ $randomBytes = random_bytes($ivLength);
+ $randomhash = hash('sha3-512', $randomBytes);
+ $iv = substr($randomhash, 0, $ivLength);
+ // トランザクション開始
+ $pdo->beginTransaction();
+ try {
+ // SQL作成
+ $stmt = $pdo->prepare("UPDATE account SET encryption_ivkey = :encryption_ivkey WHERE userid = :userid;");
+ $stmt->bindParam(':encryption_ivkey', $iv, PDO::PARAM_STR);
+ $stmt->bindValue(':userid', $userid, PDO::PARAM_STR);
+ $res = $stmt->execute();
+ $res = $pdo->commit();
+ } catch (Exception $e) {
+ $pdo->rollBack();
+ }
+ if (!($res)) {
+ $error_message[] = "アカウント操作に失敗しました(ERROR)";
+ }
+ $stmt = null;
+
+ $userEnckey = GenUserEnckey($userData["datetime"]);
+ $enc_seacret = EncryptionUseEncrKey($secret, $userEnckey, $iv);
+ }
+
+ // トランザクション開始
+ $pdo->beginTransaction();
+
+ try {
+
+ // SQL作成
+ $stmt = $pdo->prepare("UPDATE account SET authcode = :authcode,backupcode = :backupcode WHERE userid = :userid");
+
+ $stmt->bindValue(':authcode', $enc_seacret, PDO::PARAM_STR);
+ $stmt->bindValue(':backupcode', $hashbackupcode, PDO::PARAM_STR);
+
+ // ユーザーIDのバインド(WHERE句に必要)
+ $stmt->bindValue(':userid', $userid, PDO::PARAM_STR);
+
+ // SQLクエリの実行
+ $res = $stmt->execute();
+
+ // コミット
+ $res = $pdo->commit();
+
+
+ } catch (Exception $e) {
+
+ // エラーが発生した時はロールバック
+ $pdo->rollBack();
+ }
+
+ if ($res) {
+ $_SESSION["userid"] = $userid;
+ $_SESSION['backupcode'] = $backupcode;
+ $_SESSION['is_register_account'] = true;
+ // リダイレクト先のURLへ転送する
+ $url = 'success.php';
+ header('Location: ' . $url, true, 303);
+ exit;
+ } else {
+ $error_message[] = '更新に失敗しました。(REGISTERED_DAME)';
+ }
+
+ // プリペアドステートメントを削除
+ $stmt = null;
+ }
+ } else {
+ $error_message[] = "二段階認証が出来ませんでした。再度お試しください。(AUTHCODE_CHECK_DAME)";
}
- } else {
- $error_message[] = "二段階認証が出来ませんでした。再度お試しください。(AUTHCODE_CHECK_DAME)";
}
}
-
-
// データベースの接続を閉じる
$pdo = null;
@@ -216,7 +213,7 @@ $pdo = null;
diff --git a/admin/index.php b/admin/index.php
index e01627c..ee034a3 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -98,37 +98,24 @@ if(!(empty(DB_NAME) && empty(DB_HOST) && empty(DB_USER) && empty(DB_PASS))){
$db_php = false;
}
-if (in_array("gd", get_loaded_extensions())) {
- $check_gd = true;
-} else {
- $check_gd = false;
+$extensions_to_check = [
+ "gd" => "GD",
+ "fileinfo" => "Fileinfo",
+ "mbstring" => "mbstring",
+ "pdo_mysql" => "pdo_mysql",
+ "mysqli" => "mysqli",
+ "zip" => "ZipArchive",
+ "curl" => "cURL"
+];
+
+$loaded_extensions = get_loaded_extensions();
+$extension_status = [];
+
+foreach ($extensions_to_check as $extension_id => $display_name){
+ $is_loaded = in_array($extension_id, $loaded_extensions);
+ $extension_status[$display_name] = $is_loaded;
}
-if (in_array("fileinfo", get_loaded_extensions())) {
- $check_fileinfo = true;
-} else {
- $check_fileinfo = false;
-}
-if (in_array("mbstring", get_loaded_extensions())) {
- $check_mbstring = true;
-} else {
- $check_mbstring = false;
-}
-if (in_array("pdo_mysql", get_loaded_extensions())) {
- $check_pdo_mysql = true;
-} else {
- $check_pdo_mysql = false;
-}
-if (in_array("mysqli", get_loaded_extensions())) {
- $check_mysqli = true;
-} else {
- $check_mysqli = false;
-}
-if (in_array("zip", get_loaded_extensions())) {
- $check_zip = true;
-} else {
- $check_zip = false;
-}
-// データベースの接続を閉じる
+
$pdo = null;
?>
@@ -186,17 +173,20 @@ $pdo = null;
これらのデータをあなたが知っているのであれば早速セットアップを開始しましょう!
- セットアップ中にエラーに遭遇した場合はdocs.uwuzu.xyzを確認し、解消に向けて取り組みましょう!
+ セットアップ中にエラーに遭遇した場合はdocs.uwuzu.comを確認し、解消に向けて取り組みましょう!
-
-
Already setが設定済みでNot setが未設定です。
-
GD :
-
Fileinfo :
-
mbstring :
-
pdo_mysql :
-
mysqli :
-
ZipArchive :
-
+
+
Already setが設定済みでNot setが未設定です。
+
PHPの必須モジュールの確認は全ての必須モジュールを対象に行われるものではありません。php側にてデフォルトでインストール・有効になっているものはチェック・表示しない場合がございます。
+ $status): ?>
+
+ :
+
+
+
+
uwuzu
Version :
diff --git a/api/auth.php b/api/auth.php
index 71e4ea2..039386b 100644
--- a/api/auth.php
+++ b/api/auth.php
@@ -68,7 +68,6 @@ if($is_login === false){
$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'");
diff --git a/api/me/index.php b/api/me/index.php
index d98ab59..9ce69b7 100644
--- a/api/me/index.php
+++ b/api/me/index.php
@@ -113,24 +113,18 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) {
}else{
$isAdmin = false;
}
- if(!(empty($userdata["follow"]))){
- $followee = preg_split("/,/", decode_yajirushi(htmlspecialchars_decode($userdata["follow"])));
- array_shift($followee);
- }else{
+
+ $followee = getFolloweeList($pdo, $userdata["userid"]);
+ if($followee === false){
$followee = array();
}
- if(!(empty($userdata["follower"]))){
- $follower = preg_split("/,/", decode_yajirushi(htmlspecialchars_decode($userdata["follower"])));
- array_shift($follower);
- }else{
+ $follower = getFollowerList($pdo, $userdata["userid"]);
+ if($follower === false){
$follower = array();
}
- $followcnts = explode(',', $userdata["follow"]);
- $userdata["follow_cnt"] = (int)count($followcnts)-1;
-
- $followercnts = explode(',', $userdata["follower"]);
- $userdata["follower_cnt"] = (int)count($followercnts)-1;
+ $userdata["follow_cnt"] = (int)count($followee);
+ $userdata["follower_cnt"] = (int)count($follower);
$allueuse = $pdo->prepare("SELECT account FROM ueuse WHERE account = :userid");
$allueuse->bindValue(':userid', $userdata["userid"]);
diff --git a/api/ueuse/replies.php b/api/ueuse/replies.php
index c46d94c..d7a6b37 100644
--- a/api/ueuse/replies.php
+++ b/api/ueuse/replies.php
@@ -119,6 +119,8 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) {
}
$favcnts = explode(',', $ueusedata["favorite"]);
$ueusedata["favorite_cnt"] = count($favcnts) - 1;
+
+ $userData = getUserData($pdo, $ueusedata["account"]);
if ($userData) {
$now_userdata = array(
diff --git a/api/users/index.php b/api/users/index.php
index f4d5fc0..1ffbdef 100644
--- a/api/users/index.php
+++ b/api/users/index.php
@@ -73,7 +73,7 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) {
if( !empty($pdo) ) {
$AuthData = APIAuth($pdo, $token, "read:users");
if($AuthData[0] === true){
- $userdata = $AuthData[2];
+ $userdata = getUserData($pdo, $userid);
if (empty($userdata)){
$response = array(
@@ -130,24 +130,18 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) {
}else{
$isAdmin = false;
}
- if(!(empty($userdata["follow"]))){
- $followee = preg_split("/,/", decode_yajirushi(htmlspecialchars_decode($userdata["follow"])));
- array_shift($followee);
- }else{
+
+ $followee = getFolloweeList($pdo, $userdata["userid"]);
+ if($followee === false){
$followee = array();
}
- if(!(empty($userdata["follower"]))){
- $follower = preg_split("/,/", decode_yajirushi(htmlspecialchars_decode($userdata["follower"])));
- array_shift($follower);
- }else{
+ $follower = getFollowerList($pdo, $userdata["userid"]);
+ if($follower === false){
$follower = array();
}
- $followcnts = explode(',', $userdata["follow"]);
- $userdata["follow_cnt"] = (int)count($followcnts)-1;
-
- $followercnts = explode(',', $userdata["follower"]);
- $userdata["follower_cnt"] = (int)count($followercnts)-1;
+ $userdata["follow_cnt"] = (int)count($followee);
+ $userdata["follower_cnt"] = (int)count($follower);
$allueuse = $pdo->prepare("SELECT account FROM ueuse WHERE account = :userid");
$allueuse->bindValue(':userid', $userdata["userid"]);
diff --git a/api/users/unfollow.php b/api/users/unfollow.php
index 0d71346..430cb86 100644
--- a/api/users/unfollow.php
+++ b/api/users/unfollow.php
@@ -80,7 +80,6 @@ if(isset($_GET['token']) || (!(empty($Get_Post_Json)))) {
$Follow_userdata = $DataQuery->fetch();
$userid = $userData["userid"];
- $myfollowlist = $userData["follow"];
if(!(empty($Follow_userdata))){
if(!($userid == $Follow_userdata['userid'])){
diff --git a/authcodechk.php b/authcodechk.php
index 5488513..dd1cc0f 100644
--- a/authcodechk.php
+++ b/authcodechk.php
@@ -27,17 +27,7 @@ $stmt = null;
$res = null;
$option = null;
-
-if( !empty($_SESSION['userid']) ) {
- $userid = $_SESSION['userid'];
-}else{
- header("Location: login.php");
- exit;
-}
-
-
// データベースに接続
-
try {
$option = array(
@@ -52,42 +42,60 @@ try {
$error_message[] = $e->getMessage();
}
-//ログイン認証---------------------------------------------------
-blockedIP($_SERVER['REMOTE_ADDR']);
-$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "user");
-if(!($is_login === false)){
- header("Location: /home/");
- exit;
-}
-//-------------------------------------------------------------
+if( !empty($pdo) ) {
+ $userData = getUserData($pdo, $_SESSION['userid']);
+ if(!(empty($userData))){
+ if($_SESSION['is_register_account'] === true){
+ $userid = $userData["userid"];
+ }else{
+ header("Location: login.php");
+ exit;
+ }
+ }else{
+ $_SESSION = array();
+ header("Location: index.php");
+ exit;
+ }
+
+ //ログイン認証---------------------------------------------------
+ blockedIP($_SERVER['REMOTE_ADDR']);
+ $is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "user");
+ if(!($is_login === false)){
+ header("Location: /home/");
+ exit;
+ }
+ //-------------------------------------------------------------
-if( !empty($_POST['btn_submit']) ) {
- $_SESSION['userid'] = $userid;
- // リダイレクト先のURLへ転送する
- $url = 'addauthcode.php';
- header('Location: ' . $url, true, 303);
+ if( !empty($_POST['btn_submit']) ) {
+ $_SESSION['userid'] = $userid;
+ $_SESSION['is_register_account'] = true;
+ // リダイレクト先のURLへ転送する
+ $url = 'addauthcode.php';
+ header('Location: ' . $url, true, 303);
- // すべての出力を終了
- exit;
-}
+ // すべての出力を終了
+ exit;
+ }
-if( !empty($_POST['skip_submit']) ) {
- 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, '/');
- }
- }
- $userid = "";
- // リダイレクト先のURLへ転送する
- $url = 'success.php';
- header('Location: ' . $url, true, 303);
+ if( !empty($_POST['skip_submit']) ) {
+ 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, '/');
+ }
+ }
+ $userid = "";
+ $_SESSION['is_register_account'] = true;
+ // リダイレクト先のURLへ転送する
+ $url = 'success.php';
+ header('Location: ' . $url, true, 303);
- // すべての出力を終了
- exit;
+ // すべての出力を終了
+ exit;
+ }
}
// データベースの接続を閉じる
diff --git a/authlogin.php b/authlogin.php
index 52ba753..83886f0 100644
--- a/authlogin.php
+++ b/authlogin.php
@@ -36,249 +36,271 @@ session_set_cookie_params([
session_start();
session_regenerate_id(true);
-if( !empty($_SESSION['userid']) ) {
- $userid = $_SESSION['userid'];
-}else{
- header("Location: login.php");
- exit;
-}
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);
-
- $userData = getUserData($pdo, $userid);
} 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: /home/");
- exit;
-}
-//-------------------------------------------------------------
-//パスワード試行回数制限-------------------------------------------
-if (!isset($_SESSION['login_passtry'])) {
- $_SESSION['login_passtry'] = 0;
-}
-//-------------------------------------------------------------
-
-if( !empty($_POST['btn_submit']) ) {
- if ($_SESSION["login_passtry"] <= 5) {
- $delay = $_SESSION["login_passtry"] * 2;
- } else {
- $delay = min(pow(2, $_SESSION["login_passtry"] - 2), 60);
+if( !empty($pdo) ) {
+ if( !empty($_SESSION['userid']) ) {
+ if($_SESSION['auth_status'] === "2fa_required"){
+ $userData = getUserData($pdo, $_SESSION['userid']);
+ if(!(empty($userData))){
+ $userid = $userData["userid"];
+ }else{
+ $_SESSION = array();
+ header("Location: login.php");
+ exit;
+ }
+ }elseif($_SESSION['auth_status'] === "authenticated"){
+ header("Location: check.php");
+ exit;
+ }else{
+ $_SESSION = array();
+ header("Location: login.php");
+ exit;
+ }
+ }else{
+ $_SESSION = array();
+ header("Location: login.php");
+ exit;
}
- sleep($delay);
- $useragent = safetext($_SERVER['HTTP_USER_AGENT']);
- $device = UserAgent_to_Device($useragent);
+ //ログイン認証---------------------------------------------------
+ blockedIP($_SERVER['REMOTE_ADDR']);
+ $is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "user");
+ if(!($is_login === false)){
+ header("Location: /home/");
+ exit;
+ }
+ //-------------------------------------------------------------
+ //パスワード試行回数制限-------------------------------------------
+ if (!isset($_SESSION['login_passtry'])) {
+ $_SESSION['login_passtry'] = 0;
+ }
+ //-------------------------------------------------------------
- $userbackupcode = $_POST['userbackupcode'];
+ if( !empty($_POST['btn_submit']) ) {
+ if ($_SESSION["login_passtry"] <= 5) {
+ $delay = $_SESSION["login_passtry"] * 2;
+ } else {
+ $delay = min(pow(2, $_SESSION["login_passtry"] - 2), 60);
+ }
+ sleep($delay);
- $options = array(
- // SQL実行失敗時に例外をスルー
- PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
- // デフォルトフェッチモードを連想配列形式に設定
- PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
- // バッファードクエリを使う(一度に結果セットを全て取得し、サーバー負荷を軽減)
- // SELECTで得た結果に対してもrowCountメソッドを使えるようにする
- PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
- );
+ $useragent = safetext($_SERVER['HTTP_USER_AGENT']);
+ $device = UserAgent_to_Device($useragent);
- $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $options);
+ $userbackupcode = $_POST['userbackupcode'];
- require_once 'authcode/GoogleAuthenticator.php';
+ $options = array(
+ // SQL実行失敗時に例外をスルー
+ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
+ // デフォルトフェッチモードを連想配列形式に設定
+ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
+ // バッファードクエリを使う(一度に結果セットを全て取得し、サーバー負荷を軽減)
+ // SELECTで得た結果に対してもrowCountメソッドを使えるようにする
+ PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
+ );
- $result = $dbh->prepare("SELECT * FROM account WHERE userid = :userid");
+ $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $options);
- $result->bindValue(':userid', $userid);
- // SQL実行
- $result->execute();
+ require_once 'authcode/GoogleAuthenticator.php';
- if(!(empty($userbackupcode))){
- $row = $result->fetch();
- $backuplogin = false;
- if(mb_strlen($row["backupcode"]) === 32 && mb_strlen($userbackupcode) === 32){
- if($row["backupcode"] === $userbackupcode){
- $backuplogin = true;
+ $result = $dbh->prepare("SELECT * FROM account WHERE userid = :userid");
+
+ $result->bindValue(':userid', $userid);
+ // SQL実行
+ $result->execute();
+
+ if(!(empty($userbackupcode))){
+ $row = $result->fetch();
+ $backuplogin = false;
+ if(mb_strlen($row["backupcode"]) === 32 && mb_strlen($userbackupcode) === 32){
+ if($row["backupcode"] === $userbackupcode){
+ $backuplogin = true;
+ }else{
+ $backuplogin = false;
+ }
}else{
$backuplogin = false;
}
- }else{
- $backuplogin = false;
- }
-
- if($backuplogin === true || uwuzu_password_verify($userbackupcode,$row["backupcode"])){
- $pdo->beginTransaction();
- try {
- $touserid = $userid;
- $datetime = date("Y-m-d H:i:s");
- $msg = "バックアップコードを使用しログインされました!\nバックアップコード変更のために二段階認証を再設定することを強くおすすめします。\nまた、もしバックアップコードを利用してログインした覚えがない場合は「その他」よりセッショントークンを再生成し、設定画面よりパスワードを変更し、二段階認証を再設定してください!\n\nログインした端末 : ".$device;
- $title = '🔴バックアップコード使用のお知らせ🔴';
- $url = '/settings';
- $userchk = 'none';
- // 通知用SQL作成
- $stmt = $pdo->prepare("INSERT INTO notification (fromuserid, touserid, msg, url, datetime, userchk, title) VALUES (:fromuserid, :touserid, :msg, :url, :datetime, :userchk, :title)");
-
- $stmt->bindParam(':fromuserid', safetext("uwuzu-fromsys"), PDO::PARAM_STR);
- $stmt->bindParam(':touserid', safetext($touserid), PDO::PARAM_STR);
- $stmt->bindParam(':msg', safetext($msg), PDO::PARAM_STR);
- $stmt->bindParam(':url', safetext($url), PDO::PARAM_STR);
- $stmt->bindParam(':userchk', safetext($userchk), PDO::PARAM_STR);
- $stmt->bindParam(':title', safetext($title), PDO::PARAM_STR);
+ if($backuplogin === true || uwuzu_password_verify($userbackupcode,$row["backupcode"])){
+ $pdo->beginTransaction();
+
+ try {
+ $touserid = $userid;
+ $datetime = date("Y-m-d H:i:s");
+ $msg = "バックアップコードを使用しログインされました!\nバックアップコード変更のために二段階認証を再設定することを強くおすすめします。\nまた、もしバックアップコードを利用してログインした覚えがない場合は「その他」よりセッショントークンを再生成し、設定画面よりパスワードを変更し、二段階認証を再設定してください!\n\nログインした端末 : ".$device;
+ $title = '🔴バックアップコード使用のお知らせ🔴';
+ $url = '/settings';
+ $userchk = 'none';
+ // 通知用SQL作成
+ $stmt = $pdo->prepare("INSERT INTO notification (fromuserid, touserid, msg, url, datetime, userchk, title) VALUES (:fromuserid, :touserid, :msg, :url, :datetime, :userchk, :title)");
+
+ $stmt->bindParam(':fromuserid', safetext("uwuzu-fromsys"), PDO::PARAM_STR);
+ $stmt->bindParam(':touserid', safetext($touserid), PDO::PARAM_STR);
+ $stmt->bindParam(':msg', safetext($msg), PDO::PARAM_STR);
+ $stmt->bindParam(':url', safetext($url), PDO::PARAM_STR);
+ $stmt->bindParam(':userchk', safetext($userchk), PDO::PARAM_STR);
+ $stmt->bindParam(':title', safetext($title), PDO::PARAM_STR);
- $stmt->bindParam(':datetime', safetext($datetime), PDO::PARAM_STR);
+ $stmt->bindParam(':datetime', safetext($datetime), PDO::PARAM_STR);
- // SQLクエリの実行
- $res = $stmt->execute();
+ // SQLクエリの実行
+ $res = $stmt->execute();
- // コミット
- $res = $pdo->commit();
+ // コミット
+ $res = $pdo->commit();
- } catch(Exception $e) {
+ } catch(Exception $e) {
- // エラーが発生した時はロールバック
- $pdo->rollBack();
- }
-
- clearstatcache();
-
- 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);
+ // エラーが発生した時はロールバック
+ $pdo->rollBack();
}
- }
- setcookie('loginid', $userData["loginid"],[
- 'expires' => time() + 60 * 60 * 24 * 28,
- 'path' => '/',
- 'samesite' => 'lax',
- 'secure' => true,
- 'httponly' => true,
- ]);
-
- $userEncKey = GenUserEnckey($userData["datetime"]);
- $userLoginKey = hash_hmac('sha256', $userData["loginid"], $userEncKey);
- setcookie('loginkey', $userLoginKey,[
- 'expires' => time() + 60 * 60 * 24 * 28,
- 'path' => '/',
- 'samesite' => 'lax',
- 'secure' => true,
- 'httponly' => true,
- ]);
-
- $_SESSION['userid'] = $userid;
- $_SESSION['loginid'] = $userData["loginid"];
- $_SESSION['loginkey'] = $userLoginKey;
-
- $_SESSION['username'] = $username;
- $_SESSION['password'] = null;
- $_SESSION["login_passtry"] = 0;
-
- // リダイレクト先のURLへ転送する
- $url = '/home';
- header('Location: ' . $url, true, 303);
-
- // すべての出力を終了
- exit;
- }else{
- $_SESSION["login_passtry"]++;
- $error_message[] = "そのバックアップコードは使用できません。(BACKUPCODE_DAME)";
- }
- }else{
-
- if($result->rowCount() > 0) {
- $row = $result->fetch();
-
- if(!(empty($row["encryption_ivkey"])) && (!(mb_strlen($row["authcode"]) === 16))){
- $tousercode = DecryptionUseEncrKey($row["authcode"], GenUserEnckey($row["datetime"]), $row["encryption_ivkey"]);
- }else{
- $tousercode = $row["authcode"];
- }
-
- $chkauthcode = new PHPGangsta_GoogleAuthenticator();
-
- $userauthcode = $_POST['usercode'];
-
- if(empty($userauthcode)){
- $error_message[] = "コードを入力してください。(AUTHCODE_INPUT_PLEASE)";
- }else{
-
- $discrepancy = 2;
-
- $checkResult = $chkauthcode->verifyCode($tousercode, $userauthcode, $discrepancy);
- if ($checkResult) {
-
- $msg = "アカウントにログインがありました。\nもしログインした覚えがない場合は「その他」よりセッショントークンを再生成し、パスワードを変更し、二段階認証を再設定してください。\n\nログインした端末 : ".$device;
- send_notification($userid,"uwuzu-fromsys","🚪ログイン通知🚪",$msg,"/settings", "login");
-
- clearstatcache();
-
- 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);
- }
+ clearstatcache();
+
+ 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('loginid', $userData["loginid"],[
- 'expires' => time() + 60 * 60 * 24 * 28,
- 'path' => '/',
- 'samesite' => 'lax',
- 'secure' => true,
- 'httponly' => true,
- ]);
-
- $userEncKey = GenUserEnckey($userData["datetime"]);
- $userLoginKey = hash_hmac('sha256', $userData["loginid"], $userEncKey);
- setcookie('loginkey', $userLoginKey,[
- 'expires' => time() + 60 * 60 * 24 * 28,
- 'path' => '/',
- 'samesite' => 'lax',
- 'secure' => true,
- 'httponly' => true,
- ]);
-
- $_SESSION['userid'] = $userid;
- $_SESSION['loginid'] = $userData["loginid"];
- $_SESSION['loginkey'] = $userLoginKey;
-
- $_SESSION['username'] = $username;
- $_SESSION['password'] = null;
- $_SESSION["login_passtry"] = 0;
-
- // リダイレクト先のURLへ転送する
- $url = '/home';
- header('Location: ' . $url, true, 303);
-
- // すべての出力を終了
- exit;
-
- }else {
- $_SESSION["login_passtry"]++;
- $error_message[] = '二段階認証が出来ませんでした。再度お試しください。(AUTHCODE_CHECK_DAME)';
}
+
+ setcookie('loginid', $userData["loginid"],[
+ 'expires' => time() + 60 * 60 * 24 * 28,
+ 'path' => '/',
+ 'samesite' => 'lax',
+ 'secure' => true,
+ 'httponly' => true,
+ ]);
+
+ $userEncKey = GenUserEnckey($userData["datetime"]);
+ $userLoginKey = hash_hmac('sha256', $userData["loginid"], $userEncKey);
+ setcookie('loginkey', $userLoginKey,[
+ 'expires' => time() + 60 * 60 * 24 * 28,
+ 'path' => '/',
+ 'samesite' => 'lax',
+ 'secure' => true,
+ 'httponly' => true,
+ ]);
+
+ $_SESSION['userid'] = $userid;
+ $_SESSION['loginid'] = $userData["loginid"];
+ $_SESSION['loginkey'] = $userLoginKey;
+
+ $_SESSION['username'] = $username;
+ $_SESSION['password'] = null;
+ $_SESSION["login_passtry"] = 0;
+
+ //ログイン失敗履歴のお掃除
+ cleanupOldLoginLogs($pdo);
+
+ // リダイレクト先のURLへ転送する
+ $url = '/home';
+ header('Location: ' . $url, true, 303);
+
+ // すべての出力を終了
+ exit;
+ }else{
+ $_SESSION["login_passtry"]++;
+ $error_message[] = "そのバックアップコードは使用できません。(BACKUPCODE_DAME)";
}
}else{
- $error_message[] = 'データの取得が出来ませんでした。再度お試しください。(AUTHCODE_GET_ACCOUNT_NOT_FOUND)';
- }
- }
+ if($result->rowCount() > 0) {
+ $row = $result->fetch();
+
+ if(!(empty($row["encryption_ivkey"])) && (!(mb_strlen($row["authcode"]) === 16))){
+ $tousercode = DecryptionUseEncrKey($row["authcode"], GenUserEnckey($row["datetime"]), $row["encryption_ivkey"]);
+ }else{
+ $tousercode = $row["authcode"];
+ }
+
+ $chkauthcode = new PHPGangsta_GoogleAuthenticator();
+
+ $userauthcode = $_POST['usercode'];
+
+ if(empty($userauthcode)){
+ $error_message[] = "コードを入力してください。(AUTHCODE_INPUT_PLEASE)";
+ }else{
+
+ $discrepancy = 2;
+
+ $checkResult = $chkauthcode->verifyCode($tousercode, $userauthcode, $discrepancy);
+ if ($checkResult) {
+
+ $msg = "アカウントにログインがありました。\nもしログインした覚えがない場合は「その他」よりセッショントークンを再生成し、パスワードを変更し、二段階認証を再設定してください。\n\nログインした端末 : ".$device;
+ send_notification($userid,"uwuzu-fromsys","🚪ログイン通知🚪",$msg,"/settings", "login");
+
+ clearstatcache();
+
+ 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('loginid', $userData["loginid"],[
+ 'expires' => time() + 60 * 60 * 24 * 28,
+ 'path' => '/',
+ 'samesite' => 'lax',
+ 'secure' => true,
+ 'httponly' => true,
+ ]);
+
+ $userEncKey = GenUserEnckey($userData["datetime"]);
+ $userLoginKey = hash_hmac('sha256', $userData["loginid"], $userEncKey);
+ setcookie('loginkey', $userLoginKey,[
+ 'expires' => time() + 60 * 60 * 24 * 28,
+ 'path' => '/',
+ 'samesite' => 'lax',
+ 'secure' => true,
+ 'httponly' => true,
+ ]);
+
+ $_SESSION['userid'] = $userid;
+ $_SESSION['loginid'] = $userData["loginid"];
+ $_SESSION['loginkey'] = $userLoginKey;
+
+ $_SESSION['username'] = $username;
+ $_SESSION['password'] = null;
+ $_SESSION["login_passtry"] = 0;
+
+ //ログイン失敗履歴のお掃除
+ cleanupOldLoginLogs($pdo);
+
+ // リダイレクト先のURLへ転送する
+ $url = '/home';
+ header('Location: ' . $url, true, 303);
+
+ // すべての出力を終了
+ exit;
+
+ }else {
+ $_SESSION["login_passtry"]++;
+ $error_message[] = '二段階認証が出来ませんでした。再度お試しください。(AUTHCODE_CHECK_DAME)';
+ }
+ }
+ }else{
+ $error_message[] = 'データの取得が出来ませんでした。再度お試しください。(AUTHCODE_GET_ACCOUNT_NOT_FOUND)';
+ }
+ }
+
+ }
}
// データベースの接続を閉じる
diff --git a/bookmark/index.php b/bookmark/index.php
index 65706c7..6a26686 100644
--- a/bookmark/index.php
+++ b/bookmark/index.php
@@ -55,7 +55,6 @@ if($is_login === false){
$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'");
diff --git a/check.php b/check.php
index 471f6e3..33d61af 100644
--- a/check.php
+++ b/check.php
@@ -35,21 +35,44 @@ 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();
+}
+
+
+if( !empty($pdo) ) {
if( !empty($_SESSION['userid']) ) {
- $userid = $_SESSION['userid'];
+ if($_SESSION['auth_status'] === "authenticated"){
+ $userData = getUserData($pdo, $_SESSION['userid']);
+ if(!(empty($userData))){
+ $userid = $userData["userid"];
+ }else{
+ $_SESSION = array();
+ header("Location: login.php");
+ exit;
+ }
+ }elseif($_SESSION['auth_status'] === "2fa_required"){
+ header("Location: authlogin.php");
+ exit;
+ }else{
+ $_SESSION = array();
+ header("Location: login.php");
+ exit;
+ }
}else{
+ $_SESSION = array();
header("Location: login.php");
exit;
}
- $userData = getUserData($pdo, $userid);
+ $userData = getUserData($pdo, $userid);
$roles = explode(',', $userData["role"]); // カンマで区切られたロールを配列に分割
$roleDataArray = array();
@@ -60,87 +83,85 @@ try {
$rerole->execute();
$roleDataArray[$roleId] = $rerole->fetch();
}
-} 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: /home/");
+ exit;
+ }
+ //-------------------------------------------------------------
-//ログイン認証---------------------------------------------------
-blockedIP($_SERVER['REMOTE_ADDR']);
-$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "user");
-if(!($is_login === false)){
- header("Location: /home/");
- exit;
-}
-//-------------------------------------------------------------
+ if( !empty($_POST['btn_submit']) ) {
+ $useragent = safetext($_SERVER['HTTP_USER_AGENT']);
+ $device = UserAgent_to_Device($useragent);
-if( !empty($_POST['btn_submit']) ) {
- $useragent = safetext($_SERVER['HTTP_USER_AGENT']);
- $device = UserAgent_to_Device($useragent);
+ $msg = "アカウントにログインがありました。\nもしログインした覚えがない場合は「その他」よりセッショントークンを再生成し、パスワードを変更してください。\n\nログインした端末 : ".$device;
+ send_notification($userid,"uwuzu-fromsys","🚪ログイン通知🚪",$msg,"/settings", "login");
- $msg = "アカウントにログインがありました。\nもしログインした覚えがない場合は「その他」よりセッショントークンを再生成し、パスワードを変更してください。\n\nログインした端末 : ".$device;
- send_notification($userid,"uwuzu-fromsys","🚪ログイン通知🚪",$msg,"/settings", "login");
+ clearstatcache();
- clearstatcache();
-
- 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);
+ 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('loginid', $userData["loginid"],[
+ 'expires' => time() + 60 * 60 * 24 * 28,
+ 'path' => '/',
+ 'samesite' => 'lax',
+ 'secure' => true,
+ 'httponly' => true,
+ ]);
+
+ $userEncKey = GenUserEnckey($userData["datetime"]);
+ $userLoginKey = hash_hmac('sha256', $userData["loginid"], $userEncKey);
+ setcookie('loginkey', $userLoginKey,[
+ 'expires' => time() + 60 * 60 * 24 * 28,
+ 'path' => '/',
+ 'samesite' => 'lax',
+ 'secure' => true,
+ 'httponly' => true,
+ ]);
+
+ $_SESSION['userid'] = $userid;
+ $_SESSION['loginid'] = $userData["loginid"];
+ $_SESSION['loginkey'] = $userLoginKey;
+
+ $_SESSION['username'] = $username;
+ $_SESSION['password'] = null;
+
+ //ログイン失敗履歴のお掃除
+ cleanupOldLoginLogs($pdo);
+
+ // リダイレクト先のURLへ転送する
+ $url = '/home';
+ header('Location: ' . $url, true, 303);
+
+ // すべての出力を終了
+ exit;
}
- setcookie('loginid', $userData["loginid"],[
- 'expires' => time() + 60 * 60 * 24 * 28,
- 'path' => '/',
- 'samesite' => 'lax',
- 'secure' => true,
- 'httponly' => true,
- ]);
+ if( !empty($_POST['btn_submit2']) ) {
- $userEncKey = GenUserEnckey($userData["datetime"]);
- $userLoginKey = hash_hmac('sha256', $userData["loginid"], $userEncKey);
- setcookie('loginkey', $userLoginKey,[
- 'expires' => time() + 60 * 60 * 24 * 28,
- 'path' => '/',
- 'samesite' => 'lax',
- 'secure' => true,
- 'httponly' => true,
- ]);
+ $_SESSION['admin_login'] = false;
+ $_SESSION['userid'] = "";
- $_SESSION['userid'] = $userid;
- $_SESSION['loginid'] = $userData["loginid"];
- $_SESSION['loginkey'] = $userLoginKey;
+ $_SESSION['username'] = "";
- $_SESSION['username'] = $username;
- $_SESSION['password'] = null;
+ // リダイレクト先のURLへ転送する
+ $url = 'index.php';
+ header('Location: ' . $url, true, 303);
- // リダイレクト先のURLへ転送する
- $url = '/home';
- header('Location: ' . $url, true, 303);
-
- // すべての出力を終了
- exit;
+ // すべての出力を終了
+ exit;
+ }
}
-
-if( !empty($_POST['btn_submit2']) ) {
-
- $_SESSION['admin_login'] = false;
- $_SESSION['userid'] = "";
-
- $_SESSION['username'] = "";
-
- // リダイレクト先のURLへ転送する
- $url = 'index.php';
- header('Location: ' . $url, true, 303);
-
- // すべての出力を終了
- exit;
-}
-
// データベースの接続を閉じる
$pdo = null;
diff --git a/css/home.css b/css/home.css
index 8ca78f6..b733f4c 100644
--- a/css/home.css
+++ b/css/home.css
@@ -4131,9 +4131,9 @@ label>input {
.loading {
text-align: center;
font-size: 48px;
- /* 絵文字のサイズ */
animation: rotate 0.5s infinite linear;
- /* アニメーションを適用 */
+ width: fit-content;
+ margin: auto;
}
@keyframes rotate {
@@ -5123,7 +5123,6 @@ summary {
padding-left: 12px;
padding-right: 12px;
padding-top: 8px;
- padding-bottom: 4px;
background-color: var(--background-color);
border: 1px solid var(--border-color);
width: auto;
@@ -5147,8 +5146,32 @@ summary {
list-style: none;
}
-.server_code summary::-webkit-details-marker {
- display: none;
+.report_summary{
+ display:flex;
+ justify-content:space-between;
+ align-items:center;
+ width:100%;
+}
+
+.report_summary .count{
+ font-size: 16px;
+ color: var(--subtext-color);
+ padding: 2px 8px;
+ background-color: var(--tl-color);
+ border: solid 1px var(--border-color);
+ border-radius: 32px;
+}
+
+.report-entry {
+ background-color: var(--tl-color);
+ border: solid 1px var(--border-color);
+ margin-bottom: 10px;
+ padding: 12px;
+ padding-bottom: 0px;
+ border-radius: 8px;
+}
+.report-entry .p2{
+ margin: 0px;
}
@keyframes slideInYopen {
@@ -8822,6 +8845,16 @@ noscript .noscript_modal .inner .center_text p {
color: var(--dark-subtext-color);
}
+ .report_summary .count{
+ color: var(--subtext-color);
+ background-color: var(--dark-sub-color);
+ border: solid 1px var(--dark-border-color);
+ }
+
+ .report-entry {
+ background-color: var(--dark-sub-color);
+ border: solid 1px var(--dark-border-color);
+ }
.terms {
background-color: var(--dark-sub-color);
diff --git a/emoji/index.php b/emoji/index.php
index c67264d..a4eb8e1 100644
--- a/emoji/index.php
+++ b/emoji/index.php
@@ -59,7 +59,6 @@ if($is_login === false){
$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'");
diff --git a/function/function.php b/function/function.php
index 7e07bdd..e75b1d4 100644
--- a/function/function.php
+++ b/function/function.php
@@ -1389,7 +1389,7 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$
$error_message[] = '内容を入力してください。(INPUT_PLEASE)';
} else {
// 文字数を確認
- if((int)safetext(file_get_contents($mojisizefile)) < mb_strlen($ueuse, 'UTF-8')) {
+ if((int)safetext(file_get_contents($mojisizefile)) < mb_strlen(str_replace("\r\n", "\n", $ueuse), 'UTF-8')) {
$error_message[] = '内容は'.safetext(file_get_contents($mojisizefile)).'文字以内で入力してください。(INPUT_OVER_MAX_COUNT)';
}
@@ -1710,6 +1710,8 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$
$mentionedUsers = array_unique(get_mentions_userid($ueuse));
$mentions = implode(",", $mentionedUsers);
+ $res = false;
+
if(empty($rpUniqid) && empty($ruUniqid)){
//-----------通常ユーズ-----------
// トランザクション開始
@@ -2115,40 +2117,34 @@ function follow_user($pdo, $to_userid, $userid){
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;
- $followerList = array_values(array_unique(array_filter($followerList)));
- $newFollowerList = implode(',', $followerList);
+ if(isMeFollow($pdo, $userid, $to_userid)){
+ actionLog($userid, "error", "follow_user", $to_userid, "すでにフォローしています。", 3);
+ return false;
+ }
- // 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();
+ if((migrationFollowNetwork($pdo, $userid) === true) && (migrationFollowNetwork($pdo, $to_userid) === true)){
+ $other_settings_me = is_OtherSettings($pdo, $userid);
+ $other_settings_user = is_OtherSettings($pdo, $to_userid);
+ if($other_settings_me === true && $other_settings_user === true){
+ $uniqid = createUniqId();
+ $datetime = date("Y-m-d H:i:s");
+ // トランザクションを開始
+ $pdo->beginTransaction();
+ try {
+ // SQL作成
+ $stmt = $pdo->prepare("INSERT INTO follow (uniqid, follower_id, followee_id, datetime) VALUES (:uniqid, :follower_id, :followee_id, :datetime)");
- // 自分のfollowカラムを更新
- $myflwlist = explode(',', $myData["follow"]);
- $myflwlist[] = $userData['userid'];
- $myflwlist = array_values(array_unique(array_filter($myflwlist)));
- $newFollowList = implode(',', $myflwlist);
+ $stmt->bindParam(':uniqid', $uniqid, PDO::PARAM_STR);
+ $stmt->bindParam(':follower_id', $userid, PDO::PARAM_STR);
+ $stmt->bindParam(':followee_id', $to_userid, PDO::PARAM_STR);
+ $stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR);
- $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();
+ // SQLクエリの実行
+ $res = $stmt->execute();
send_notification($userData["userid"], $userid, "🎉" . $userid . "さんにフォローされました!🎉", "" . $userid . "さんにフォローされました。", "/@" . $userid . "", "follow", $userid);
- if ($res && $res_follow) {
+ if ($res) {
$pdo->commit();
return true;
} else {
@@ -2156,13 +2152,13 @@ function follow_user($pdo, $to_userid, $userid){
actionLog($userid, "error", "follow_user", $to_userid, "フォローに失敗", 3);
return false;
}
- }else{
- $pdo->commit();
- return true;
+ } catch(Exception $e) {
+ // エラーが発生した時はロールバック
+ $pdo->rollBack();
+ actionLog($userid, "error", "follow_user", null, $e, 4);
+ return false;
}
- } catch (Exception $e) {
- $pdo->rollBack();
- actionLog($userid, "error", "follow_user", $to_userid, $e, 4);
+ }else{
return false;
}
}else{
@@ -2174,58 +2170,34 @@ function follow_user($pdo, $to_userid, $userid){
}
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((migrationFollowNetwork($pdo, $userid) === true) && (migrationFollowNetwork($pdo, $to_userid) === true)){
+ $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 {
+ // 削除クエリを実行
+ $deleteQuery = $pdo->prepare("DELETE FROM follow WHERE follower_id = :follower_id AND followee_id = :followee_id");
+ $deleteQuery->bindValue(':follower_id', $userid, PDO::PARAM_STR);
+ $deleteQuery->bindValue(':followee_id', $to_userid, PDO::PARAM_STR);
+ $res = $deleteQuery->execute();
- $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));
- $followerList = array_values(array_unique(array_filter($followerList)));
- $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']));
- $delfollowList = array_values(array_unique(array_filter($delfollowList)));
- $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) {
- // コミット
+ if ($res) {
$pdo->commit();
return true;
} else {
- // ロールバック
$pdo->rollBack();
actionLog($userid, "error", "unfollow_user", $to_userid, "フォロー解除に失敗", 3);
return false;
}
- }else{
- $pdo->commit();
- return true;
+ } catch(PDOException $e) {
+ // ロールバック
+ $pdo->rollBack();
+ actionLog($userid, "error", "unfollow_user", $to_userid, $e, 4);
+ return false;
}
- } catch (Exception $e) {
- // ロールバック
- $pdo->rollBack();
- actionLog($userid, "error", "unfollow_user", $to_userid, $e, 4);
+ }else{
return false;
}
}else{
@@ -2235,6 +2207,232 @@ function unfollow_user($pdo, $to_userid, $userid){
return false;
}
}
+
+function migrationFollowData($pdo, $userid){
+ if (!(empty($pdo)) && !(empty($userid))){
+ $pdo->beginTransaction();
+ try {
+ $stmt = $pdo->prepare("SELECT userid, follow FROM account WHERE userid = ?");
+ $stmt->execute([$userid]);
+ $user = $stmt->fetch(PDO::FETCH_ASSOC);
+
+ if (!(empty($user['follow']))) {
+ $followerId = $user['userid'];
+ $follows = array_filter(explode(",", $user['follow']));
+
+ $insert = $pdo->prepare("INSERT IGNORE INTO follow (uniqid, follower_id, followee_id, datetime) VALUES (?, ?, ?, ?)");
+
+ foreach ($follows as $followeeId) {
+ $uniqid = createUniqId();
+ $datetime = date("Y-m-d H:i:s");
+
+ $followeeId = trim($followeeId); // 数値にキャストせず文字列を保持
+ if ($followeeId !== "" && $followerId !== $followeeId) {
+ $insert->execute([$uniqid ,$followerId, $followeeId, $datetime]);
+ }
+ }
+
+ $clear = $pdo->prepare("UPDATE account SET follow = '', follower = '' WHERE userid = ?");
+ $clear->execute([$userid]);
+
+ $pdo->commit();
+ actionLog($userid, "info", "migrationFollowData", $userid, "フォロー情報の移行に成功しました!", 0);
+ return true;
+ }else{
+ $pdo->commit();
+ return true;
+ }
+ } catch (Exception $e) {
+ $pdo->rollBack();
+ actionLog($userid, "error", "migrationFollowData", $userid, $e, 4);
+ return false;
+ }
+ }else{
+ actionLog($userid, "error", "migrationFollowData", $userid, "フォロー情報の移行関数が呼び出されましたが値が不足しています。", 3);
+ return false;
+ }
+}
+
+function migrationFollowNetwork($pdo, $startUserId) {
+ if (empty($pdo) || empty($startUserId)) {
+ actionLog($startUserId, "error", "migrationFollowNetwork", $startUserId, "関数呼び出し時の値が不足しています。", 3);
+ return false;
+ }
+
+ $queue = [$startUserId];
+ $visited = [];
+
+ while (!empty($queue)) {
+ $userid = array_shift($queue);
+
+ if (isset($visited[$userid])) continue;
+
+ $stmt = $pdo->prepare("SELECT userid, follow, follower FROM account WHERE userid = ?");
+ $stmt->execute([$userid]);
+ $user = $stmt->fetch(PDO::FETCH_ASSOC);
+
+ if (!$user) continue;
+
+ $isMigrated =
+ (empty($user['follow']) || trim($user['follow']) === '') &&
+ (empty($user['follower']) || trim($user['follower']) === '');
+
+ if ($isMigrated) {
+ $visited[$userid] = true;
+ continue;
+ }
+
+ $pdo->beginTransaction();
+ try {
+ $followerId = $user['userid'];
+ $follows = array_filter(array_map('trim', explode(",", $user['follow'] ?? '')));
+ $followers = array_filter(array_map('trim', explode(",", $user['follower'] ?? '')));
+
+ $relations = [];
+
+ foreach ($follows as $followeeId) {
+ if ($followeeId !== "" && $followerId !== $followeeId) {
+ $relations[] = [$followerId, $followeeId];
+ $queue[] = $followeeId;
+ }
+ }
+
+ foreach ($followers as $followerUserId) {
+ if ($followerUserId !== "" && $followerUserId !== $followerId) {
+ $relations[] = [$followerUserId, $followerId];
+ $queue[] = $followerUserId;
+ }
+ }
+
+
+ if (!empty($relations)) {
+ $insert = $pdo->prepare("
+ INSERT IGNORE INTO follow (uniqid, follower_id, followee_id, datetime)
+ VALUES (?, ?, ?, ?)
+ ");
+ $datetime = date("Y-m-d H:i:s");
+
+ $check = $pdo->prepare("SELECT 1 FROM follow WHERE follower_id = ? AND followee_id = ? LIMIT 1");
+
+ foreach ($relations as [$from, $to]) {
+ $check->execute([$from, $to]);
+ if ($check->fetchColumn()) {
+ continue;
+ }
+
+ $uniqid = createUniqId();
+ $insert->execute([$uniqid, $from, $to, $datetime]);
+ }
+ }
+
+ $clear = $pdo->prepare("UPDATE account SET follow = '', follower = '' WHERE userid = ?");
+ $clear->execute([$userid]);
+
+ $pdo->commit();
+
+ $visited[$userid] = true;
+ actionLog($userid, "info", "migrationFollowNetwork", $userid, "フォロー情報の移行に成功しました!", 0);
+ } catch (Exception $e) {
+ $pdo->rollBack();
+ actionLog($userid, "error", "migrationFollowNetwork", $userid, $e->getMessage(), 4);
+ }
+ }
+ return true;
+}
+
+function checkFollowMigrationProgress($pdo) {
+ if (!(empty($pdo))) {
+ $stmtTotal = $pdo->query("SELECT COUNT(*) FROM account");
+ $total = (int)$stmtTotal->fetchColumn();
+
+ $stmtPending = $pdo->query("
+ SELECT COUNT(*)
+ FROM account
+ WHERE (follow IS NOT NULL AND TRIM(follow) <> '')
+ OR (follower IS NOT NULL AND TRIM(follower) <> '')
+ ");
+ $pending = (int)$stmtPending->fetchColumn();
+
+ $migrated = $total - $pending;
+
+ $progress = $total > 0 ? round(($migrated / $total) * 100, 2) : 0;
+
+ return [
+ 'total' => $total,//総ユーザー数
+ 'migrated' => $migrated,//移行済み
+ 'pending' => $pending,//未移行
+ 'progress' => $progress//%
+ ];
+ }
+}
+
+function getFolloweeList($pdo, $userid){
+ if (!(empty($pdo)) && !(empty($userid))){
+ $query = $pdo->prepare("SELECT followee_id FROM follow WHERE follower_id = :follower_id ORDER BY datetime DESC");
+ $query->bindValue(':follower_id', $userid, PDO::PARAM_STR);
+ $query->execute();
+ $all_followee = $query->fetchAll(PDO::FETCH_COLUMN);
+
+ if($all_followee){
+ return $all_followee;
+ }else{
+ $userdata = getUserData($pdo, $userid);
+ $followeeIds = array_filter(explode(',', $userdata['follow']));
+ if($followeeIds){
+ return $followeeIds;
+ }else{
+ return array();
+ }
+ }
+ }else{
+ return array();
+ }
+}
+function getFollowerList($pdo, $userid){
+ if (!(empty($pdo)) && !(empty($userid))){
+ $query = $pdo->prepare("SELECT follower_id FROM follow WHERE followee_id = :followee_id ORDER BY datetime DESC");
+ $query->bindValue(':followee_id', $userid, PDO::PARAM_STR);
+ $query->execute();
+ $all_follower = $query->fetchAll(PDO::FETCH_COLUMN);
+
+ if($all_follower){
+ return $all_follower;
+ }else{
+ $userdata = getUserData($pdo, $userid);
+ $followerIds = array_filter(explode(',', $userdata['follower']));
+ if($followerIds){
+ return $followerIds;
+ }else{
+ return array();
+ }
+ }
+ }else{
+ return array();
+ }
+}
+function isMeFollow($pdo, $userid, $to_userid){
+ if (!(empty($pdo)) && !(empty($userid)) && !(empty($to_userid))){
+ $query = $pdo->prepare("SELECT * FROM follow WHERE follower_id = :follower_id AND followee_id = :followee_id");
+ $query->bindValue(':follower_id', $userid, PDO::PARAM_STR);
+ $query->bindValue(':followee_id', $to_userid, PDO::PARAM_STR);
+ $query->execute();
+ $is_follower = $query->fetch(PDO::FETCH_ASSOC);
+
+ if($is_follower){
+ return true;
+ }else{
+ $is_inUserdata = getFolloweeList($pdo, $userid);
+ if(in_array($to_userid, $is_inUserdata)){
+ return true;
+ }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);
@@ -2630,30 +2828,35 @@ function changePopularity($pdo, $uniqid, $userid, $change_range){
$pdo->beginTransaction();
try {
// 投稿のいいね情報を取得
- $stmt = $pdo->prepare("SELECT popularity FROM ueuse WHERE uniqid = :uniqid");
+ $stmt = $pdo->prepare("SELECT account, 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;
- }
+ if(!($post['account'] == $userid)){
+ $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();
+ $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 {
+ if ($res) {
+ $pdo->commit();
+ return true;
+ } else {
+ $pdo->rollBack();
+ actionLog($userid, "error", "changePopularity", $uniqid, "いいねに失敗しました", 3);
+ return false;
+ }
+ }else{
$pdo->rollBack();
- actionLog($userid, "error", "changePopularity", $uniqid, "いいねに失敗しました", 3);
- return false;
- }
+ return true;
+ }
} else {
$pdo->rollBack();
return false;
@@ -2758,8 +2961,16 @@ function getUserDataForUpdate($pdo, $userid) {
return $query->fetch();
}
-function getUeuseData($pdo, $uniqid) {
- $query = $pdo->prepare("SELECT * FROM ueuse WHERE uniqid = :uniqid");
+function getUeuseData($pdo, $uniqid, $myblocklist = null) {
+ if(!(empty($myblocklist))){
+ $blocked_accounts = sqlBlockAccountList('account', $myblocklist);
+ $query = $pdo->prepare("SELECT * FROM ueuse WHERE uniqid = :uniqid {$blocked_accounts['sql']}");
+ foreach ($blocked_accounts['params'] as $ph => $val) {
+ $query->bindValue($ph, $val, PDO::PARAM_STR);
+ }
+ }else{
+ $query = $pdo->prepare("SELECT * FROM ueuse WHERE uniqid = :uniqid");
+ }
$query->bindValue(':uniqid', $uniqid, PDO::PARAM_STR);
$query->execute();
$ueuseDatas = $query->fetch();
@@ -2903,6 +3114,194 @@ function actionLog($userid, $type, $place, $target, $content, $importance){
}
}
+function secondsToHms($seconds){
+ if ($seconds < 0) {
+ $seconds = 0;
+ }
+ $date = new DateTimeImmutable('@0', new DateTimeZone('UTC'));
+ $futureDate = $date->modify("+{$seconds} seconds");
+ $interval = $date->diff($futureDate);
+ return $interval->format('%H時間%I分%S秒');
+}
+
+function createServerHashedParam($param){
+ return hash('sha3-512', ENC_KEY . $param);
+}
+
+function cleanupOldLoginLogs($pdo) {
+ try {
+ $threshold = date('Y-m-d H:i:s', strtotime('-7 days'));
+
+ $stmt = $pdo->prepare("
+ DELETE FROM loginlog
+ WHERE last_attack_datetime < :threshold
+ ");
+ $stmt->bindValue(':threshold', $threshold, PDO::PARAM_STR);
+ $stmt->execute();
+
+ actionLog(null, "info", "cleanupOldLoginLogs", null, "".$stmt->rowCount()."件の古いログイン失敗履歴を削除しました!", 0);
+ return true;
+ } catch (Exception $e) {
+ actionLog(null, "error", "cleanupOldLoginLogs", null, $e->getMessage(), 4);
+ return false;
+ }
+}
+
+function isUserLockedByloginLog($pdo, $userid, $ip_addr) {
+ $log = getloginLog($pdo, $userid, $ip_addr);
+ if (empty($log)) {
+ return [false, 0];
+ }
+
+ $now = time();
+ $blocked_until = strtotime($log['blocked_until_datetime']);
+
+ if ($blocked_until <= $now && $log['failure_count'] > 0) {
+ $stmt = $pdo->prepare("
+ UPDATE loginlog
+ SET failure_count = 0
+ WHERE uniqid = :uniqid
+ ");
+ $stmt->bindValue(':uniqid', $log['uniqid'], PDO::PARAM_STR);
+ $stmt->execute();
+ }
+
+ if ($blocked_until > $now) {
+ $remaining = $blocked_until - $now;
+ return [true, $remaining];
+ } else {
+ return [false, 0];
+ }
+}
+
+function getloginLog($pdo, $userid, $ip_addr){
+ if(empty($pdo) ||empty($userid) || empty($ip_addr)){
+ actionLog(null, "error", "getloginLog", null, "パラメータが不足しています。", 3);
+ return false;
+ }
+
+ $hash_ip_addr = createServerHashedParam($ip_addr);
+
+ if(!(empty($pdo))){
+ $query = $pdo->prepare("SELECT * FROM loginlog WHERE attack_userid = :userid AND ip_hash = :ip_hash ORDER BY datetime ASC LIMIT 1");
+ $query->bindParam(':userid', $userid, PDO::PARAM_STR);
+ $query->bindParam(':ip_hash', $hash_ip_addr, PDO::PARAM_STR);
+ $query->execute();
+ $log = $query->fetch(PDO::FETCH_ASSOC);
+
+ if($log){
+ return $log;
+ }else{
+ return false;
+ }
+ }
+}
+
+function addloginLog($pdo, $userid, $ip_addr){
+ //基本的にログイン失敗時のみ呼び出す
+ if(empty($pdo) ||empty($userid) || empty($ip_addr)){
+ actionLog(null, "error", "addloginLog", null, "パラメータが不足しています。", 3);
+ return false;
+ }
+
+ $hash_ip_addr = createServerHashedParam($ip_addr);
+
+ if(!(empty($pdo))){
+ $alreadyloginlog = getloginLog($pdo, $userid, $ip_addr);
+ $datetime = date('Y-m-d H:i:s');
+ $max_block_seconds = 86400;
+
+ if (!empty($alreadyloginlog)) {
+ $failure_count = $alreadyloginlog["failure_count"] + 1;
+
+ if ($failure_count <= 5) {
+ $block_seconds = $failure_count * 2;
+ } else {
+ $block_seconds = pow(2, $failure_count - 2);
+ }
+
+ if ($block_seconds > $max_block_seconds) {
+ $block_seconds = $max_block_seconds;
+ }
+
+ $blocked_until_datetime = date('Y-m-d H:i:s', strtotime($datetime) + $block_seconds);
+
+ $pdo->beginTransaction();
+ try {
+ $updateQuery = $pdo->prepare("
+ UPDATE loginlog
+ SET failure_count = :failure_count,
+ last_attack_datetime = :last_attack_datetime,
+ blocked_until_datetime = :blocked_until_datetime
+ WHERE uniqid = :uniqid
+ ");
+ $updateQuery->bindValue(':failure_count', $failure_count, PDO::PARAM_INT);
+ $updateQuery->bindValue(':last_attack_datetime', $datetime, PDO::PARAM_STR);
+ $updateQuery->bindValue(':blocked_until_datetime', $blocked_until_datetime, PDO::PARAM_STR);
+ $updateQuery->bindValue(':uniqid', $alreadyloginlog['uniqid'], PDO::PARAM_STR);
+
+ $res = $updateQuery->execute();
+
+ if ($res) {
+ $pdo->commit();
+ return true;
+ } else {
+ $pdo->rollBack();
+ actionLog($userid, "error", "addLoginLog(Update)", null, "ログイン失敗ログの更新に失敗しました", 3);
+ return false;
+ }
+ } catch (Exception $e) {
+ actionLog($userid, "error", "addLoginLog(Update)", null, $e->getMessage(), 4);
+ $pdo->rollBack();
+ return false;
+ }
+
+ } else {
+ $uniqid = createUniqId();
+ $failure_count = 1;
+ $block_seconds = 2;
+ $blocked_until_datetime = date('Y-m-d H:i:s', strtotime($datetime) + $block_seconds);
+
+ $pdo->beginTransaction();
+ try {
+ $stmt = $pdo->prepare("
+ INSERT INTO loginlog (
+ uniqid, attack_userid, ip_hash, failure_count,
+ last_attack_datetime, blocked_until_datetime, datetime
+ ) VALUES (
+ :uniqid, :attack_userid, :ip_hash, :failure_count,
+ :last_attack_datetime, :blocked_until_datetime, :datetime
+ )
+ ");
+
+ $stmt->bindParam(':uniqid', $uniqid, PDO::PARAM_STR);
+ $stmt->bindParam(':attack_userid', $userid, PDO::PARAM_STR);
+ $stmt->bindParam(':ip_hash', $hash_ip_addr, PDO::PARAM_STR);
+ $stmt->bindParam(':failure_count', $failure_count, PDO::PARAM_INT);
+ $stmt->bindParam(':last_attack_datetime', $datetime, PDO::PARAM_STR);
+ $stmt->bindParam(':blocked_until_datetime', $blocked_until_datetime, PDO::PARAM_STR);
+ $stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR);
+
+ $res = $stmt->execute();
+
+ if ($res) {
+ $pdo->commit();
+ return true;
+ } else {
+ $pdo->rollBack();
+ return false;
+ }
+ } catch (Exception $e) {
+ actionLog(null, "error", "addLoginLog", null, $e->getMessage(), 3);
+ $pdo->rollBack();
+ return false;
+ }
+ }
+
+ }
+}
+
+
function addJob($pdo, $userid, $job, $step){
$userid = getUserData($pdo, $userid)["userid"];
if(empty($userid)){
@@ -3306,7 +3705,6 @@ function GetActivityPubUser($userid, $domain) {
}
function FormatUeuseItem(array $value, string $myblocklist, string $mybookmark, $pdo, string $userId): ?array {
- if (in_array(safetext($value['account']), explode(",", $myblocklist))) return null;
if ($value["role"] === "ice") return null;
$value['iconname'] = filter_var($value['iconname'], FILTER_VALIDATE_URL)
@@ -3334,7 +3732,7 @@ function FormatUeuseItem(array $value, string $myblocklist, string $mybookmark,
} elseif (!empty($value['ruuniqid'])) {
$value["type"] = "Reuse";
- $reused = getUeuseData($pdo, $value['ruuniqid']);
+ $reused = getUeuseData($pdo, $value['ruuniqid'], $myblocklist);
if ($reused) {
$reusedUserData = getUserData($pdo, $reused['account']);
$reusedUserData["role"] = explode(',', $reusedUserData["role"]);
@@ -3688,4 +4086,28 @@ function getDatasUeuse(PDO $pdo, array $messages): array {
return $messages;
}
+function sqlBlockAccountList($column, $myblocklist){
+ if (is_string($myblocklist)) {
+ $myblocklist = array_filter(array_map('trim', explode(',', $myblocklist)));
+ }
+
+ if (empty($myblocklist)) {
+ return ['sql' => '', 'params' => []]; // 条件なし
+ }
+
+ $placeholders = [];
+ $params = [];
+ foreach ($myblocklist as $i => $id) {
+ $ph = ":block_$i";
+ $placeholders[] = $ph;
+ $params[$ph] = $id;
+ }
+
+ return [
+ 'sql' => "AND {$column} NOT IN (" . implode(',', $placeholders) . ")",
+ 'params' => $params
+ ];
+}
+
+
?>
\ No newline at end of file
diff --git a/home/index.php b/home/index.php
index d4b976b..a86c164 100644
--- a/home/index.php
+++ b/home/index.php
@@ -66,7 +66,6 @@ if($is_login === false){
$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"]);
}
@@ -77,13 +76,6 @@ $notiData = $notiQuery->fetch(PDO::FETCH_ASSOC);
$notificationcount = $notiData['notification_count'];
-//-----------------URLから取得----------------
-if(isset($_GET['text'])) {
- $ueuse = safetext(urldecode($_GET['text']));
-}elseif(isset($_COOKIE['ueuse'])) {
- $ueuse = safetext($_COOKIE['ueuse']);
-}
-
require('../logout/logout.php');
@@ -188,7 +180,7 @@ if ("serviceWorker" in navigator) {