diff --git a/.well-known/host-meta/index.php b/.well-known/host-meta/index.php index 9507b10..b05557c 100644 --- a/.well-known/host-meta/index.php +++ b/.well-known/host-meta/index.php @@ -2,7 +2,9 @@ $serversettings_file = "../../server/serversettings.ini"; $serversettings = parse_ini_file($serversettings_file, true); +require('../../db.php'); require("../../function/function.php"); +blockedIP($_SERVER['REMOTE_ADDR']); if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ header("Content-Type: application/xml; charset=UTF-8"); diff --git a/.well-known/nodeinfo/index.php b/.well-known/nodeinfo/index.php index 950dc0c..25b6112 100644 --- a/.well-known/nodeinfo/index.php +++ b/.well-known/nodeinfo/index.php @@ -2,7 +2,9 @@ $serversettings_file = "../../server/serversettings.ini"; $serversettings = parse_ini_file($serversettings_file, true); +require('../../db.php'); require("../../function/function.php"); +blockedIP($_SERVER['REMOTE_ADDR']); if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ header("Content-Type: application/activity+json; charset=utf-8"); diff --git a/.well-known/webfinger/index.php b/.well-known/webfinger/index.php index aac3b42..1267e3b 100644 --- a/.well-known/webfinger/index.php +++ b/.well-known/webfinger/index.php @@ -2,7 +2,9 @@ $serversettings_file = "../../server/serversettings.ini"; $serversettings = parse_ini_file($serversettings_file, true); +require('../../db.php'); require("../../function/function.php"); +blockedIP($_SERVER['REMOTE_ADDR']); if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ header("Content-Type: application/jrd+json; charset=utf-8"); diff --git a/abi/addabi.php b/abi/addabi.php index dc9502c..4373e81 100644 --- a/abi/addabi.php +++ b/abi/addabi.php @@ -8,6 +8,7 @@ $banurl = array_filter(preg_split("/\r\n|\n|\r/", $banurl_info)); require('../db.php'); require("../function/function.php"); +blockedIP($_SERVER['REMOTE_ADDR']); if (safetext(isset($_POST['uniqid'])) && safetext(isset($_POST['abitext'])) && safetext(isset($_POST['userid'])) && safetext(isset($_POST['account_id']))) { $userid = safetext($_POST['userid']); diff --git a/actor/index.php b/actor/index.php index 1c26c26..0d47419 100644 --- a/actor/index.php +++ b/actor/index.php @@ -2,7 +2,9 @@ $serversettings_file = "../server/serversettings.ini"; $serversettings = parse_ini_file($serversettings_file, true); +require('../db.php'); require("../function/function.php"); +blockedIP($_SERVER['REMOTE_ADDR']); if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ header("Content-Type: application/activity+json; charset=utf-8"); @@ -10,8 +12,6 @@ if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ $domain = $_SERVER['HTTP_HOST']; - require('../db.php'); - // データベースに接続 try { $option = array( diff --git a/addauthcode.php b/addauthcode.php index 2cc25de..9d93e5f 100644 --- a/addauthcode.php +++ b/addauthcode.php @@ -50,49 +50,14 @@ try { $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true && isset($_COOKIE['loginid']) && isset($_SESSION['userid'])) { - $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, - ); - $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); - $acck = $dbh->prepare("SELECT userid, loginid FROM account WHERE userid = :userid"); - $acck->bindValue(':userid', $_SESSION['userid']); - $acck->execute(); - $acck_data = $acck->fetch(); - if(!empty($acck_data)){ - if($_COOKIE['loginid'] === $acck_data["loginid"] && $_SESSION['userid'] === $acck_data["userid"] ){ - header("Location: home/index.php"); - exit; - } - } -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true && isset($_COOKIE['loginid']) && isset($_COOKIE['userid'])) { - $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, - ); - $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); - $acck = $dbh->prepare("SELECT userid, loginid FROM account WHERE userid = :userid"); - $acck->bindValue(':userid', $_COOKIE['userid']); - $acck->execute(); - $acck_data = $acck->fetch(); - if(!empty($acck_data)){ - if($_COOKIE['loginid'] === $acck_data["loginid"] && $_COOKIE['userid'] === $acck_data["userid"] ){ - header("Location: home/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'; diff --git a/admin/addadmin.php b/admin/addadmin.php index 76a649a..7967fca 100644 --- a/admin/addadmin.php +++ b/admin/addadmin.php @@ -3,6 +3,7 @@ require('../db.php'); //関数呼び出し //- EXIF require('../function/function.php'); +blockedIP($_SERVER['REMOTE_ADDR']); $serversettings_file = "../server/serversettings.ini"; $serversettings = parse_ini_file($serversettings_file, true); diff --git a/admin/index.php b/admin/index.php index 4c7e33e..356e2c6 100644 --- a/admin/index.php +++ b/admin/index.php @@ -1,6 +1,7 @@ getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true && isset($_COOKIE['loginid']) && isset($_SESSION['userid'])) { - $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, - ); - $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); - $acck = $dbh->prepare("SELECT userid, loginid FROM account WHERE userid = :userid"); - $acck->bindValue(':userid', $_SESSION['userid']); - $acck->execute(); - $acck_data = $acck->fetch(); - if(!empty($acck_data)){ - if($_COOKIE['loginid'] === $acck_data["loginid"] && $_SESSION['userid'] === $acck_data["userid"] ){ - header("Location: home/index.php"); - exit; - } - } -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true && isset($_COOKIE['loginid']) && isset($_COOKIE['userid'])) { - $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, - ); - $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); - $acck = $dbh->prepare("SELECT userid, loginid FROM account WHERE userid = :userid"); - $acck->bindValue(':userid', $_COOKIE['userid']); - $acck->execute(); - $acck_data = $acck->fetch(); - if(!empty($acck_data)){ - if($_COOKIE['loginid'] === $acck_data["loginid"] && $_COOKIE['userid'] === $acck_data["userid"] ){ - header("Location: home/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; diff --git a/authlogin.php b/authlogin.php index a0bc939..cc728cf 100644 --- a/authlogin.php +++ b/authlogin.php @@ -46,55 +46,21 @@ try { ); $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(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true && isset($_COOKIE['loginid']) && isset($_SESSION['userid'])) { - $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, - ); - $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); - $acck = $dbh->prepare("SELECT userid, loginid FROM account WHERE userid = :userid"); - $acck->bindValue(':userid', $_SESSION['userid']); - $acck->execute(); - $acck_data = $acck->fetch(); - if(!empty($acck_data)){ - if($_COOKIE['loginid'] === $acck_data["loginid"] && $_SESSION['userid'] === $acck_data["userid"] ){ - header("Location: home/index.php"); - exit; - } - } -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true && isset($_COOKIE['loginid']) && isset($_COOKIE['userid'])) { - $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, - ); - $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); - $acck = $dbh->prepare("SELECT userid, loginid FROM account WHERE userid = :userid"); - $acck->bindValue(':userid', $_COOKIE['userid']); - $acck->execute(); - $acck_data = $acck->fetch(); - if(!empty($acck_data)){ - if($_COOKIE['loginid'] === $acck_data["loginid"] && $_COOKIE['userid'] === $acck_data["userid"] ){ - header("Location: home/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']) ) { $useragent = safetext($_SERVER['HTTP_USER_AGENT']); @@ -180,41 +146,30 @@ if( !empty($_POST['btn_submit']) ) { } } - setcookie('userid', $userid,[ + setcookie('loginid', $userData["loginid"],[ 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); - setcookie('loginid', $row["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $row["username"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['loginid'] = $row["loginid"]; - $_SESSION['username'] = $row["username"]; - $_SESSION['password'] = ""; + $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; // リダイレクト先のURLへ転送する $url = '/home'; @@ -292,41 +247,29 @@ if( !empty($_POST['btn_submit']) ) { } } - setcookie('userid', $userid,[ + setcookie('loginid', $userData["loginid"],[ 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', 'secure' => true, 'httponly' => true, ]); - setcookie('loginid', $row["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $row["username"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - - $_SESSION['admin_login'] = true; - - $_SESSION['userid'] = $userid; - $_SESSION['loginid'] = $row["loginid"]; - $_SESSION['username'] = $row["username"]; + $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; // リダイレクト先のURLへ転送する diff --git a/check.php b/check.php index 6320414..1b8ec7f 100644 --- a/check.php +++ b/check.php @@ -18,9 +18,6 @@ $res = null; $option = null; $error_message = array(); -$row["userid"] = array(); -$row["password"] = array(); - $ruserid = array(); $rpassword = array(); @@ -47,54 +44,17 @@ try { $userid = $_SESSION['userid']; - - $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, - ); - - $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); - - - $result = $dbh->prepare("SELECT userid, username, profile, role FROM account WHERE userid = :userid"); - - $result->bindValue(':userid', $userid); - // SQL実行 - $result->execute(); - - - $row = $result->fetch(); // ここでデータベースから取得した値を $row に代入する - - $username = $row["username"]; - - $role = $row["role"]; - - - //-------------------------------------- - - $userQuery = $dbh->prepare("SELECT username, userid, loginid, profile, role, iconname FROM account WHERE userid = :userid"); - $userQuery->bindValue(':userid', $userid); - $userQuery->execute(); - $userData = $userQuery->fetch(); - + $userData = getUserData($pdo, $userid); $roles = explode(',', $userData["role"]); // カンマで区切られたロールを配列に分割 $roleDataArray = array(); foreach ($roles as $roleId) { - $rerole = $dbh->prepare("SELECT rolename, roleauth, rolecolor, roleeffect FROM role WHERE roleidname = :role"); + $rerole = $pdo->prepare("SELECT rolename, roleauth, rolecolor, roleeffect FROM role WHERE roleidname = :role"); $rerole->bindValue(':role', $roleId); $rerole->execute(); $roleDataArray[$roleId] = $rerole->fetch(); } - - - } catch(PDOException $e) { // 接続エラーのときエラー内容を取得する @@ -192,13 +152,6 @@ if( !empty($_POST['btn_submit']) ) { } } - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); setcookie('loginid', $userData["loginid"],[ 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', @@ -206,14 +159,10 @@ if( !empty($_POST['btn_submit']) ) { 'secure' => true, 'httponly' => true, ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ + + $userEncKey = GenUserEnckey($userData["datetime"]); + $userLoginKey = hash_hmac('sha256', $userData["loginid"], $userEncKey); + setcookie('loginkey', $userLoginKey,[ 'expires' => time() + 60 * 60 * 24 * 28, 'path' => '/', 'samesite' => 'lax', @@ -221,9 +170,9 @@ if( !empty($_POST['btn_submit']) ) { 'httponly' => true, ]); - $_SESSION['admin_login'] = true; $_SESSION['userid'] = $userid; $_SESSION['loginid'] = $userData["loginid"]; + $_SESSION['loginkey'] = $userLoginKey; $_SESSION['username'] = $username; $_SESSION['password'] = null; @@ -285,7 +234,7 @@ $pdo = null;

確認

-

あなたは ですか?

+

あなたは ですか?

+ + - - \ No newline at end of file + \ No newline at end of file diff --git a/migration/index.php b/migration/index.php index a5453f6..dde3a0a 100644 --- a/migration/index.php +++ b/migration/index.php @@ -41,49 +41,15 @@ $stmt = null; $res = null; $option = null; -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true && isset($_COOKIE['loginid']) && isset($_SESSION['userid'])) { - $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, - ); - $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); - $acck = $dbh->prepare("SELECT userid, loginid FROM account WHERE userid = :userid"); - $acck->bindValue(':userid', $_SESSION['userid']); - $acck->execute(); - $acck_data = $acck->fetch(); - if(!empty($acck_data)){ - if($_COOKIE['loginid'] === $acck_data["loginid"] && $_SESSION['userid'] === $acck_data["userid"] ){ - header("Location: /home/index.php"); - exit; - } - } -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true && isset($_COOKIE['loginid']) && isset($_COOKIE['userid'])) { - $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, - ); - $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); - $acck = $dbh->prepare("SELECT userid, loginid FROM account WHERE userid = :userid"); - $acck->bindValue(':userid', $_COOKIE['userid']); - $acck->execute(); - $acck_data = $acck->fetch(); - if(!empty($acck_data)){ - if($_COOKIE['loginid'] === $acck_data["loginid"] && $_COOKIE['userid'] === $acck_data["userid"] ){ - header("Location: /home/index.php"); - exit; - } - } +//ログイン認証--------------------------------------------------- +blockedIP($_SERVER['REMOTE_ADDR']); +$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "user"); +if(!($is_login === false)){ + header("Location: ../home/"); + exit; } +//------------------------------------------------------------- + try { $option = array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, diff --git a/new.php b/new.php index a28becc..ba64e97 100644 --- a/new.php +++ b/new.php @@ -56,50 +56,14 @@ try { $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true && isset($_COOKIE['loginid']) && isset($_SESSION['userid'])) { - $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, - ); - $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); - $acck = $dbh->prepare("SELECT userid, loginid FROM account WHERE userid = :userid"); - $acck->bindValue(':userid', $_SESSION['userid']); - $acck->execute(); - $acck_data = $acck->fetch(); - if(!empty($acck_data)){ - if($_COOKIE['loginid'] === $acck_data["loginid"] && $_SESSION['userid'] === $acck_data["userid"] ){ - header("Location: home/index.php"); - exit; - } - } -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true && isset($_COOKIE['loginid']) && isset($_COOKIE['userid'])) { - $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, - ); - $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); - $acck = $dbh->prepare("SELECT userid, loginid FROM account WHERE userid = :userid"); - $acck->bindValue(':userid', $_COOKIE['userid']); - $acck->execute(); - $acck_data = $acck->fetch(); - if(!empty($acck_data)){ - if($_COOKIE['loginid'] === $acck_data["loginid"] && $_COOKIE['userid'] === $acck_data["userid"] ){ - header("Location: home/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['form_data'] = $_POST; diff --git a/new_select.php b/new_select.php index 5bd12bf..1360f88 100644 --- a/new_select.php +++ b/new_select.php @@ -15,50 +15,14 @@ session_set_cookie_params([ ]); session_start(); - -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] === true && isset($_COOKIE['loginid']) && isset($_SESSION['userid'])) { - $option = 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, - ); - $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); - $acck = $dbh->prepare("SELECT userid, loginid FROM account WHERE userid = :userid"); - $acck->bindValue(':userid', $_SESSION['userid']); - $acck->execute(); - $acck_data = $acck->fetch(); - if(!empty($acck_data)){ - if($_COOKIE['loginid'] === $acck_data["loginid"] && $_SESSION['userid'] === $acck_data["userid"] ){ - header("Location: home/index.php"); - exit; - } - } -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true && isset($_COOKIE['loginid']) && isset($_COOKIE['userid'])) { - $option = 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, - ); - $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); - $acck = $dbh->prepare("SELECT userid, loginid FROM account WHERE userid = :userid"); - $acck->bindValue(':userid', $_COOKIE['userid']); - $acck->execute(); - $acck_data = $acck->fetch(); - if(!empty($acck_data)){ - if($_COOKIE['loginid'] === $acck_data["loginid"] && $_COOKIE['userid'] === $acck_data["userid"] ){ - header("Location: home/index.php"); - exit; - } - } +//ログイン認証--------------------------------------------------- +blockedIP($_SERVER['REMOTE_ADDR']); +$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "user"); +if(!($is_login === false)){ + header("Location: /home/"); + exit; } +//------------------------------------------------------------- $serversettings_file = "server/serversettings.ini"; $serversettings = parse_ini_file($serversettings_file, true); diff --git a/nextpage/bookmark.php b/nextpage/bookmark.php index 5e1ff04..adac82f 100644 --- a/nextpage/bookmark.php +++ b/nextpage/bookmark.php @@ -2,7 +2,7 @@ require('../db.php'); require("../function/function.php"); - +blockedIP($_SERVER['REMOTE_ADDR']); require('view.php'); diff --git a/nextpage/emojiview.php b/nextpage/emojiview.php index 5ea477b..1371120 100644 --- a/nextpage/emojiview.php +++ b/nextpage/emojiview.php @@ -2,7 +2,7 @@ require('../db.php'); require("../function/function.php"); - +blockedIP($_SERVER['REMOTE_ADDR']); // データベースに接続 try { diff --git a/nextpage/foryoupage.php b/nextpage/foryoupage.php index eb23dc2..f78d2fb 100644 --- a/nextpage/foryoupage.php +++ b/nextpage/foryoupage.php @@ -2,7 +2,7 @@ require('../db.php'); require("../function/function.php"); - +blockedIP($_SERVER['REMOTE_ADDR']); require('view.php'); diff --git a/nextpage/ftlpage.php b/nextpage/ftlpage.php index b795d62..ebeb49e 100644 --- a/nextpage/ftlpage.php +++ b/nextpage/ftlpage.php @@ -2,7 +2,7 @@ require('../db.php'); require("../function/function.php"); - +blockedIP($_SERVER['REMOTE_ADDR']); require('view.php'); diff --git a/nextpage/newueuse_chk.php b/nextpage/newueuse_chk.php index ebcf473..b5fa52a 100644 --- a/nextpage/newueuse_chk.php +++ b/nextpage/newueuse_chk.php @@ -2,7 +2,7 @@ require('../db.php'); require("../function/function.php"); - +blockedIP($_SERVER['REMOTE_ADDR']); // データベースに接続 try { diff --git a/nextpage/nextpage.php b/nextpage/nextpage.php index cafcf47..12d890c 100644 --- a/nextpage/nextpage.php +++ b/nextpage/nextpage.php @@ -2,7 +2,7 @@ require('../db.php'); require("../function/function.php"); - +blockedIP($_SERVER['REMOTE_ADDR']); require('view.php'); diff --git a/nextpage/notification.php b/nextpage/notification.php index 933b1cb..428383c 100644 --- a/nextpage/notification.php +++ b/nextpage/notification.php @@ -5,7 +5,7 @@ $serversettings = parse_ini_file($serversettings_file, true); require('../db.php'); require("../function/function.php"); - +blockedIP($_SERVER['REMOTE_ADDR']); require('notificationview.php'); diff --git a/nextpage/searchpage.php b/nextpage/searchpage.php index 1e13312..01b7daa 100644 --- a/nextpage/searchpage.php +++ b/nextpage/searchpage.php @@ -2,7 +2,7 @@ require('../db.php'); require("../function/function.php"); - +blockedIP($_SERVER['REMOTE_ADDR']); require('view.php'); diff --git a/nextpage/ueusepage.php b/nextpage/ueusepage.php index f83a1d7..0e16174 100644 --- a/nextpage/ueusepage.php +++ b/nextpage/ueusepage.php @@ -2,7 +2,7 @@ require('../db.php'); require("../function/function.php"); - +blockedIP($_SERVER['REMOTE_ADDR']); require('view.php'); diff --git a/nextpage/userlikepage.php b/nextpage/userlikepage.php index ca5a861..683767b 100644 --- a/nextpage/userlikepage.php +++ b/nextpage/userlikepage.php @@ -2,7 +2,7 @@ require('../db.php'); require("../function/function.php"); - +blockedIP($_SERVER['REMOTE_ADDR']); require('view.php'); diff --git a/nextpage/usermediapage.php b/nextpage/usermediapage.php index 9a27512..7969ee2 100644 --- a/nextpage/usermediapage.php +++ b/nextpage/usermediapage.php @@ -2,6 +2,7 @@ require('../db.php'); require("../function/function.php"); +blockedIP($_SERVER['REMOTE_ADDR']); require('view.php'); diff --git a/nextpage/userpage.php b/nextpage/userpage.php index 191b0d7..23bddea 100644 --- a/nextpage/userpage.php +++ b/nextpage/userpage.php @@ -2,7 +2,7 @@ require('../db.php'); require("../function/function.php"); - +blockedIP($_SERVER['REMOTE_ADDR']); require('view.php'); diff --git a/nodeinfo/2.1/index.php b/nodeinfo/2.1/index.php index 1e9ed70..f94f31e 100644 --- a/nodeinfo/2.1/index.php +++ b/nodeinfo/2.1/index.php @@ -1,11 +1,12 @@ getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +blockedIP($_SERVER['REMOTE_ADDR']); +$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "admin"); +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"]); } -if(!($res["admin"] === "yes")){ - header("Location: ../login.php"); - exit; -} $notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'"); $notiQuery->bindValue(':userid', $userid); $notiQuery->execute(); diff --git a/notice/index.php b/notice/index.php index 1ef27a6..498b0ca 100644 --- a/notice/index.php +++ b/notice/index.php @@ -46,130 +46,21 @@ try { } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +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); diff --git a/notification/index.php b/notification/index.php index 04b321a..09d4621 100644 --- a/notification/index.php +++ b/notification/index.php @@ -43,130 +43,21 @@ try { $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +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); diff --git a/others/account_migration.php b/others/account_migration.php index 526b5d7..403db24 100644 --- a/others/account_migration.php +++ b/others/account_migration.php @@ -55,130 +55,21 @@ try { $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +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); diff --git a/others/account_migration_done.php b/others/account_migration_done.php index 0515288..346b188 100644 --- a/others/account_migration_done.php +++ b/others/account_migration_done.php @@ -43,130 +43,21 @@ try { $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +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); diff --git a/others/cache_clear.php b/others/cache_clear.php index bd88dfe..8501957 100644 --- a/others/cache_clear.php +++ b/others/cache_clear.php @@ -1,6 +1,8 @@ "> - + キャッシュクリア中 \ No newline at end of file diff --git a/others/index.php b/others/index.php index c3d19ab..95c8eaf 100644 --- a/others/index.php +++ b/others/index.php @@ -49,130 +49,21 @@ try { $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +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); @@ -410,9 +301,13 @@ if( !empty($_POST['session_submit']) ) { } 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(); @@ -527,6 +422,12 @@ require('../logout/logout.php');
+

ログアウト

+

ログアウトです。他のログイン済みの端末からはログアウトされません。

+ + +
+

キャッシュクリア

下のボタンを押すことでキャッシュクリアが可能です。

この機能は試験的なものであり、正常に動作しない可能性があります。
diff --git a/others/token.php b/others/token.php index cc2a2bb..2e7ee86 100644 --- a/others/token.php +++ b/others/token.php @@ -47,130 +47,21 @@ try { $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +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); diff --git a/passrecovery/badrecovery.php b/passrecovery/badrecovery.php index 6f53258..953809e 100644 --- a/passrecovery/badrecovery.php +++ b/passrecovery/badrecovery.php @@ -1,9 +1,18 @@ diff --git a/passrecovery/donerecovery.php b/passrecovery/donerecovery.php index 10a27b5..b0ab676 100644 --- a/passrecovery/donerecovery.php +++ b/passrecovery/donerecovery.php @@ -1,9 +1,18 @@ diff --git a/passrecovery/index.php b/passrecovery/index.php index 097e84e..a79664e 100644 --- a/passrecovery/index.php +++ b/passrecovery/index.php @@ -66,13 +66,18 @@ 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($_POST['btn_submit']) ) { - - - //$row['userid'] = "daichimarukn"; - - $userid = $_POST['userid']; - $mailadds = $_POST['mailadds']; + $userid = safetext($_POST['userid']); + $mailadds = safetext($_POST['mailadds']); if(!empty(H_CAPTCHA_ONOFF && H_CAPTCHA_ONOFF == "true")){ if(isset($_POST['h-captcha-response'])){ @@ -219,10 +224,6 @@ if( !empty($_POST['btn_submit']) ) { } - // ... (後略) - - - } // データベースの接続を閉じる diff --git a/passrecovery/startrecovery.php b/passrecovery/startrecovery.php index 9ce0962..d311063 100644 --- a/passrecovery/startrecovery.php +++ b/passrecovery/startrecovery.php @@ -62,6 +62,16 @@ 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(!($userid == null)){ if( !empty($_SESSION['mailadds']) ) { $result = $pdo->prepare("SELECT userid, username, mailadds, loginid, authcode, encryption_ivkey, datetime FROM account WHERE userid = :userid"); diff --git a/require/leftbox.php b/require/leftbox.php index a7fdd89..0e40a76 100644 --- a/require/leftbox.php +++ b/require/leftbox.php @@ -26,15 +26,11 @@ $serversettings = parse_ini_file($serversettings_file, true); プロフィール 設定 その他 - +
お知らせ配信 サーバー設定 -
-
- -
\ No newline at end of file diff --git a/rule/privacypolicy.php b/rule/privacypolicy.php index 52a0904..1a3904d 100644 --- a/rule/privacypolicy.php +++ b/rule/privacypolicy.php @@ -1,7 +1,9 @@ getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +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"]); } if(isset($_GET['q'])){ diff --git a/search/opensearch.php b/search/opensearch.php index 49028ff..a123609 100644 --- a/search/opensearch.php +++ b/search/opensearch.php @@ -1,5 +1,7 @@ getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +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); diff --git a/settings/index.php b/settings/index.php index a58d2a8..a6be35f 100644 --- a/settings/index.php +++ b/settings/index.php @@ -52,130 +52,21 @@ try { $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist,mail_settings FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist,mail_settings FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +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); @@ -185,19 +76,14 @@ $notiData = $notiQuery->fetch(PDO::FETCH_ASSOC); $notificationcount = $notiData['notification_count']; //ページ内のみ使用変数------------------------- -$mail_settings = safetext($res["mail_settings"]); +$mail_settings = safetext($is_login["mail_settings"]); //------------------------------------------ //phpmailer-------------------------------------------- require('../settings_admin/plugin_settings/phpmailer_settings.php'); //------------------------------------------------------ require('../settings_admin/plugin_settings/aiblockwatermark_settings.php'); if( !empty($pdo) ) { - - // データベース接続の設定 - $userQuery = $pdo->prepare("SELECT * FROM account WHERE userid = :userid"); - $userQuery->bindValue(':userid', $userid); - $userQuery->execute(); - $userData = $userQuery->fetch(); + $userData = getUserData($pdo, $userid); $role = $userData["role"]; @@ -220,158 +106,164 @@ if( !empty($pdo) ) { if( !empty($_POST['btn_submit']) ) { - - if(!(empty($_POST['im_bot']))){ - if($_POST['im_bot'] == "on"){ - $saveim_bot = "bot"; + $userRoleList = explode(',', safetext($role)); + if(in_array("ice", $userRoleList)){ + $error_message[] = 'アカウントが凍結されています。(ACCOUNT_HAS_BEEN_FROZEN)'; + } + if( empty($error_message) ) { + if(!(empty($_POST['im_bot']))){ + if($_POST['im_bot'] == "on"){ + $saveim_bot = "bot"; + }else{ + $saveim_bot = "none"; + } }else{ $saveim_bot = "none"; } - }else{ - $saveim_bot = "none"; - } - $username = safetext($_POST['username']); + $username = safetext($_POST['username']); - $mailadds = safetext($_POST['mailadds']); + $mailadds = safetext($_POST['mailadds']); - if( !empty($_POST['isAIBlock']) ) { - $new_isAIBlock = safetext($_POST['isAIBlock']); - }else{ - $new_isAIBlock = "false"; - } + if( !empty($_POST['isAIBlock']) ) { + $new_isAIBlock = safetext($_POST['isAIBlock']); + }else{ + $new_isAIBlock = "false"; + } - if($new_isAIBlock === "true"){ - $save_isAIBlock = true; - }else{ - $save_isAIBlock = false; - } - $other_settings_json = val_AddOtherSettings("isAIBlock", $save_isAIBlock, $userData["other_settings"]); + if($new_isAIBlock === "true"){ + $save_isAIBlock = true; + }else{ + $save_isAIBlock = false; + } + $other_settings_json = val_AddOtherSettings("isAIBlock", $save_isAIBlock, $userData["other_settings"]); - if( !empty($_POST['isAIBMW']) ) { - $new_isAIBMW = safetext($_POST['isAIBMW']); - }else{ - $new_isAIBMW = "false"; - } - if($new_isAIBMW === "true"){ - $save_isAIBMW = true; - }else{ - $save_isAIBMW = false; - } - $other_settings_json = val_AddOtherSettings("isAIBlockWaterMark", $save_isAIBMW, $other_settings_json); + if( !empty($_POST['isAIBMW']) ) { + $new_isAIBMW = safetext($_POST['isAIBMW']); + }else{ + $new_isAIBMW = "false"; + } + if($new_isAIBMW === "true"){ + $save_isAIBMW = true; + }else{ + $save_isAIBMW = false; + } + $other_settings_json = val_AddOtherSettings("isAIBlockWaterMark", $save_isAIBMW, $other_settings_json); - if( !empty($_POST['mail_important']) ) { - $mail_important = safetext($_POST['mail_important']); - }else{ - $mail_important = "false"; - } - if(!(empty($mailadds))){ - if(filter_var($mailadds, FILTER_VALIDATE_EMAIL)){ - if($mail_important === "true"){ - $savemail_important = "important"; + if( !empty($_POST['mail_important']) ) { + $mail_important = safetext($_POST['mail_important']); + }else{ + $mail_important = "false"; + } + if(!(empty($mailadds))){ + if(filter_var($mailadds, FILTER_VALIDATE_EMAIL)){ + if($mail_important === "true"){ + $savemail_important = "important"; + }else{ + $savemail_important = "none"; + } + + if(!(empty($userData["encryption_ivkey"]))){ + $userEnckey = GenUserEnckey($userData["datetime"]); + $enc_mailadds = EncryptionUseEncrKey($mailadds, $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_mailadds = EncryptionUseEncrKey($mailadds, $userEnckey, $iv); + } }else{ $savemail_important = "none"; - } - - if(!(empty($userData["encryption_ivkey"]))){ - $userEnckey = GenUserEnckey($userData["datetime"]); - $enc_mailadds = EncryptionUseEncrKey($mailadds, $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_mailadds = EncryptionUseEncrKey($mailadds, $userEnckey, $iv); + $error_message[] = 'メールアドレスが正しい形式ではありません。(MAILADDS_CHECK_DAME)'; } }else{ - $savemail_important = "none"; - $error_message[] = 'メールアドレスが正しい形式ではありません。(MAILADDS_CHECK_DAME)'; + $enc_mailadds = ""; } - }else{ - $enc_mailadds = ""; - } - + - $profile = safetext($_POST['profile']); - if( 1024 < mb_strlen($profile, 'UTF-8') ) { - $error_message[] = 'プロフィールは1024文字以内で入力してください。(INPUT_OVER_MAX_COUNT)'; - } - - // ユーザーネームの入力チェック - if( empty($username) ) { - $error_message[] = '表示名を入力してください。(USERNAME_INPUT_PLEASE)'; - } else { - // 文字数を確認 - if( 50 < mb_strlen($username, 'UTF-8') ) { - $error_message[] = 'ユーザーネームは50文字以内で入力してください。(USERNAME_OVER_MAX_COUNT)'; - } - } - - if( empty($error_message) ) { - // トランザクション開始 - $pdo->beginTransaction(); - - try { - // SQL作成 - $stmt = $pdo->prepare("UPDATE account SET username = :username, mailadds = :mailadds, profile = :profile, sacinfo = :saveimbot, mail_settings = :mail_settings, other_settings = :other_settings WHERE userid = :userid;"); - - // 他の値をセット - $stmt->bindParam(':username', $username, PDO::PARAM_STR); - $stmt->bindParam(':mailadds', $enc_mailadds, PDO::PARAM_STR); - $stmt->bindParam(':profile', $profile, PDO::PARAM_STR); - $stmt->bindParam(':saveimbot', $saveim_bot, PDO::PARAM_STR); - $stmt->bindParam(':mail_settings', $savemail_important, PDO::PARAM_STR); - $stmt->bindParam(':other_settings', $other_settings_json, PDO::PARAM_STR); - - // 条件を指定 - // 以下の部分を適切な条件に置き換えてください - $stmt->bindValue(':userid', $userid, PDO::PARAM_STR); - - // SQLクエリの実行 - $res = $stmt->execute(); - - // コミット - $res = $pdo->commit(); - - } catch (Exception $e) { - - // エラーが発生した時はロールバック - $pdo->rollBack(); + $profile = safetext($_POST['profile']); + if( 1024 < mb_strlen($profile, 'UTF-8') ) { + $error_message[] = 'プロフィールは1024文字以内で入力してください。(INPUT_OVER_MAX_COUNT)'; } - if ($res) { - $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; - header("Location:".$url.""); - exit; + // ユーザーネームの入力チェック + if( empty($username) ) { + $error_message[] = '表示名を入力してください。(USERNAME_INPUT_PLEASE)'; } else { - $error_message[] = '更新に失敗しました。(REGISTERED_DAME)'; + // 文字数を確認 + if( 50 < mb_strlen($username, 'UTF-8') ) { + $error_message[] = 'ユーザーネームは50文字以内で入力してください。(USERNAME_OVER_MAX_COUNT)'; + } } - // プリペアドステートメントを削除 - $stmt = null; - } + if( empty($error_message) ) { + // トランザクション開始 + $pdo->beginTransaction(); + + try { + // SQL作成 + $stmt = $pdo->prepare("UPDATE account SET username = :username, mailadds = :mailadds, profile = :profile, sacinfo = :saveimbot, mail_settings = :mail_settings, other_settings = :other_settings WHERE userid = :userid;"); + + // 他の値をセット + $stmt->bindParam(':username', $username, PDO::PARAM_STR); + $stmt->bindParam(':mailadds', $enc_mailadds, PDO::PARAM_STR); + $stmt->bindParam(':profile', $profile, PDO::PARAM_STR); + $stmt->bindParam(':saveimbot', $saveim_bot, PDO::PARAM_STR); + $stmt->bindParam(':mail_settings', $savemail_important, PDO::PARAM_STR); + $stmt->bindParam(':other_settings', $other_settings_json, PDO::PARAM_STR); + + // 条件を指定 + // 以下の部分を適切な条件に置き換えてください + $stmt->bindValue(':userid', $userid, PDO::PARAM_STR); + + // SQLクエリの実行 + $res = $stmt->execute(); + + // コミット + $res = $pdo->commit(); + + } catch (Exception $e) { + + // エラーが発生した時はロールバック + $pdo->rollBack(); + actionLog($userid, "error", "user-settings", null, $e, 4); + } + + if ($res) { + $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + header("Location:".$url.""); + exit; + } else { + $error_message[] = '更新に失敗しました。(REGISTERED_DAME)'; + } + + // プリペアドステートメントを削除 + $stmt = null; + } + } } diff --git a/settings/success.php b/settings/success.php index cae219e..9aac321 100644 --- a/settings/success.php +++ b/settings/success.php @@ -48,130 +48,21 @@ try { $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +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); diff --git a/settings_admin/actionlog_admin.php b/settings_admin/actionlog_admin.php index f26938f..3f1fd3c 100644 --- a/settings_admin/actionlog_admin.php +++ b/settings_admin/actionlog_admin.php @@ -47,136 +47,23 @@ try { // 接続エラーのときエラー内容を取得する $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +blockedIP($_SERVER['REMOTE_ADDR']); +$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "admin"); +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"]); } -if(!($res["admin"] === "yes")){ - header("Location: ../login.php"); - exit; -} $notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'"); $notiQuery->bindValue(':userid', $userid); $notiQuery->execute(); diff --git a/settings_admin/ad_admin.php b/settings_admin/ad_admin.php index e09bffc..eebecaf 100644 --- a/settings_admin/ad_admin.php +++ b/settings_admin/ad_admin.php @@ -47,136 +47,23 @@ try { // 接続エラーのときエラー内容を取得する $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +blockedIP($_SERVER['REMOTE_ADDR']); +$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "admin"); +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"]); } -if(!($res["admin"] === "yes")){ - header("Location: ../login.php"); - exit; -} $notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'"); $notiQuery->bindValue(':userid', $userid); $notiQuery->execute(); @@ -241,9 +128,11 @@ if( !empty($_POST['ads_btn_submit']) ) { // エラーが発生した時はロールバック $pdo->rollBack(); + actionLog($userid, "error", "ad_admin", null, $e, 4); } if( $res ) { + actionLog($userid, "info", "ad_admin", null, "広告が新規作成されました", 0); $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; header("Location:".$url.""); exit; diff --git a/settings_admin/addemoji_admin.php b/settings_admin/addemoji_admin.php index b50d4d4..708e3ca 100644 --- a/settings_admin/addemoji_admin.php +++ b/settings_admin/addemoji_admin.php @@ -45,136 +45,23 @@ try { $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +blockedIP($_SERVER['REMOTE_ADDR']); +$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "admin"); +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"]); } -if(!($res["admin"] === "yes")){ - header("Location: ../login.php"); - exit; -} $notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'"); $notiQuery->bindValue(':userid', $userid); $notiQuery->execute(); @@ -312,9 +199,11 @@ if( !empty($_POST['btn_submit']) ) { // エラーが発生した時はロールバック $pdo->rollBack(); + actionLog($userid, "error", "addemoji_admin", null, $e, 4); } if( $res ) { + actionLog($userid, "info", "addemoji_admin", null, "カスタム絵文字が追加されました", 0); $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; header("Location:".$url.""); exit; @@ -353,9 +242,11 @@ if( !empty($_POST['emoji_del']) ) { } catch (Exception $e) { $pdo->rollBack(); + actionLog($userid, "error", "addemoji_admin_del", null, $e, 4); } if( $res ) { + actionLog($userid, "info", "addemoji_admin_del", null, "カスタム絵文字が削除されました", 0); $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; header("Location:".$url.""); exit; diff --git a/settings_admin/api/code_delete.php b/settings_admin/api/code_delete.php index 0c416b3..5b144b7 100644 --- a/settings_admin/api/code_delete.php +++ b/settings_admin/api/code_delete.php @@ -1,6 +1,7 @@ getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +blockedIP($_SERVER['REMOTE_ADDR']); +$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "admin"); +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"]); } -if(!($res["admin"] === "yes")){ - header("Location: ../login.php"); - exit; -} $notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'"); $notiQuery->bindValue(':userid', $userid); $notiQuery->execute(); @@ -259,10 +146,12 @@ if( !empty($_POST['code_btn_submit']) ) { } } if ($res) { + actionLog($userid, "info", "codeadmin", null, "招待コードを".$make_code."件発行しました", 0); $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; header("Location:".$url.""); exit; } else { + actionLog($userid, "error", "codeadmin", null, "招待コードを".$make_code."件発行できませんでした", 3); $error_message[] = '発行に失敗しました。(REGISTERED_DAME)'; } diff --git a/settings_admin/customize_admin.php b/settings_admin/customize_admin.php index 52b1289..896c1e8 100644 --- a/settings_admin/customize_admin.php +++ b/settings_admin/customize_admin.php @@ -60,136 +60,23 @@ try { // 接続エラーのときエラー内容を取得する $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +blockedIP($_SERVER['REMOTE_ADDR']); +$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "admin"); +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"]); } -if(!($res["admin"] === "yes")){ - header("Location: ../login.php"); - exit; -} $notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'"); $notiQuery->bindValue(':userid', $userid); $notiQuery->execute(); @@ -262,6 +149,8 @@ if( !empty($_POST['btn_submit']) ) { fputs($file, $data); fclose($file); + actionLog($userid, "info", "customize_admin", null, "サーバーカスタマイズを更新しました", 0); + $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; header("Location:".$url.""); exit; diff --git a/settings_admin/ipblock_admin.php b/settings_admin/ipblock_admin.php new file mode 100644 index 0000000..9512c1b --- /dev/null +++ b/settings_admin/ipblock_admin.php @@ -0,0 +1,275 @@ + 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'], "admin"); +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 username, userid, profile, role FROM account WHERE userid = :userid"); + $userQuery->bindValue(':userid', $userid); + $userQuery->execute(); + $userData = $userQuery->fetch(); + + $role = $userData["role"]; + + $dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); + + $rerole = $dbh->prepare("SELECT username, userid, password, mailadds, profile, iconname, headname, role, datetime FROM account WHERE userid = :userid"); + + $rerole->bindValue(':userid', $userid); + // SQL実行 + $rerole->execute(); + + $userdata = $rerole->fetch(); // ここでデータベースから取得した値を $role に代入する + + +} + +if (!empty($pdo)) { + + $sql = "SELECT ipaddr,note,adduserid,datetime FROM ipblock ORDER BY datetime DESC"; + $ipaddr_query = $pdo->query($sql); + + while ($row = $ipaddr_query->fetch(PDO::FETCH_ASSOC)) { + $ipaddr_list[] = $row; + } +} + +if( !empty($_POST['ip_btn_submit']) ) { + $ipaddr = safetext($_POST['ipaddr']); + $note = safetext($_POST['note']); + + if(filter_var($ipaddr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) || filter_var($ipaddr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){ + + $search_query = $pdo->prepare('SELECT * FROM ipblock WHERE ipaddr = :ipaddr limit 1'); + $search_query->execute(array(':ipaddr' => $ipaddr)); + $result = $search_query->fetch(); + + if($result > 0){ + $error_message[] = 'IPアドレスはすでに登録されています。(ERROR)'; + } else { + $pdo->beginTransaction(); + $datetime = date("Y-m-d H:i:s"); + try { + $stmt = $pdo->prepare("INSERT INTO ipblock (ipaddr, note, adduserid, datetime) VALUES (:ipaddr, :note, :adduserid, :datetime)"); + + $stmt->bindParam(':ipaddr', $ipaddr, PDO::PARAM_STR); + $stmt->bindParam(':note', $note, PDO::PARAM_STR); + $stmt->bindParam(':adduserid', $userid, PDO::PARAM_STR); + $stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR); + + // SQLクエリの実行 + $res = $stmt->execute(); + + $res = $pdo->commit(); + } catch (Exception $e) { + $pdo->rollBack(); + actionLog($userid, "error", "ipblock_admin_add", null, $e, 4); + } + + if ($res) { + actionLog($userid, "info", "ipblock_admin_add", null, "ブロックするIPアドレスを追加しました", 0); + $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + header("Location:".$url.""); + exit; + } else { + actionLog($userid, "error", "ipblock_admin_add", null, "ブロックするIPアドレスを追加できませんでした", 3); + $error_message[] = '登録に失敗しました。(REGISTERED_DAME)'; + } + + $stmt = null; + } + } else { + $error_message[] = '不正なIPアドレスです。(ERROR)'; + } +} + +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)){ + $search_query = $pdo->prepare('SELECT * FROM ipblock WHERE ipaddr = :ipaddr limit 1'); + $search_query->execute(array(':ipaddr' => $ipaddr)); + $result = $search_query->fetch(); + + if($result > 0){ + $pdo->beginTransaction(); + try{ + $deleteQuery = $pdo->prepare("DELETE FROM ipblock WHERE ipaddr = :ipaddr"); + $deleteQuery->bindValue(':ipaddr', $ipaddr, PDO::PARAM_STR); + $res = $deleteQuery->execute(); + $res = $pdo->commit(); + } catch (Exception $e) { + $pdo->rollBack(); + $res = null; + actionLog($userid, "error", "ipblock_admin_del", null, $e, 4); + } + + if ($res) { + actionLog($userid, "info", "ipblock_admin_del", null, "ブロックするIPアドレスを削除しました", 0); + $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + header("Location:".$url.""); + exit; + } else { + actionLog($userid, "error", "ipblock_admin_del", null, "ブロックするIPアドレスを削除できませんでした", 3); + $error_message[] = '削除に失敗しました。(REGISTERED_DAME)'; + } + } else { + $error_message[] = 'IPアドレスが見つかりませんでした。(ERROR)'; + } + } else { + $error_message[] = '不正なIPアドレスです。(ERROR)'; + } +} +require('../logout/logout.php'); +?> + + + + + + + + + + + +IPブロック - <?php echo safetext($serversettings["serverinfo"]["server_name"]);?> + + + + + +
+ + + + +
+ + +
+
+

IPブロック

+

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

+
+

IPアドレス

+
IPv4とIPv6に対応しています。
+ +
+
+

ノート

+ +
+ +
+
+

ブロック中のIPアドレス

+ +
+
+ +

登録ユーザー:

+

登録日時:

+
+

+
+
+

削除ボタンを押すとこのIPアドレスは削除されます。

+ "> + +
+
+
+ + +

IPアドレスは登録されていません。

+ +
+
+
+
+ + + + + + + \ No newline at end of file diff --git a/settings_admin/maintenance_admin.php b/settings_admin/maintenance_admin.php index 24074b8..bda0a32 100644 --- a/settings_admin/maintenance_admin.php +++ b/settings_admin/maintenance_admin.php @@ -59,136 +59,23 @@ try { // 接続エラーのときエラー内容を取得する $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +blockedIP($_SERVER['REMOTE_ADDR']); +$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "admin"); +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"]); } -if(!($res["admin"] === "yes")){ - header("Location: ../login.php"); - exit; -} $notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'"); $notiQuery->bindValue(':userid', $userid); $notiQuery->execute(); @@ -276,6 +163,8 @@ RewriteRule ^.*$ - [R=403,L] fputs($file, $data); fclose($file); + actionLog($userid, "info", "maintenance_admin", null, "サーバーを停止しました", 0); + $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; header("Location:".$url.""); exit; diff --git a/settings_admin/moderation_admin.php b/settings_admin/moderation_admin.php index 5864ba2..938f5c4 100644 --- a/settings_admin/moderation_admin.php +++ b/settings_admin/moderation_admin.php @@ -60,136 +60,23 @@ try { // 接続エラーのときエラー内容を取得する $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +blockedIP($_SERVER['REMOTE_ADDR']); +$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "admin"); +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"]); } -if(!($res["admin"] === "yes")){ - header("Location: ../login.php"); - exit; -} $notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'"); $notiQuery->bindValue(':userid', $userid); $notiQuery->execute(); diff --git a/settings_admin/overview_admin.php b/settings_admin/overview_admin.php index ae187ff..920d01c 100644 --- a/settings_admin/overview_admin.php +++ b/settings_admin/overview_admin.php @@ -60,136 +60,23 @@ try { // 接続エラーのときエラー内容を取得する $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +blockedIP($_SERVER['REMOTE_ADDR']); +$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "admin"); +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"]); } -if(!($res["admin"] === "yes")){ - header("Location: ../login.php"); - exit; -} $notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'"); $notiQuery->bindValue(':userid', $userid); $notiQuery->execute(); diff --git a/settings_admin/plugin_admin.php b/settings_admin/plugin_admin.php index 1a64853..1d43f65 100644 --- a/settings_admin/plugin_admin.php +++ b/settings_admin/plugin_admin.php @@ -66,136 +66,23 @@ try { // 接続エラーのときエラー内容を取得する $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +blockedIP($_SERVER['REMOTE_ADDR']); +$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "admin"); +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"]); } -if(!($res["admin"] === "yes")){ - header("Location: ../login.php"); - exit; -} $notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'"); $notiQuery->bindValue(':userid', $userid); $notiQuery->execute(); diff --git a/settings_admin/role_admin.php b/settings_admin/role_admin.php index 4502c43..046f061 100644 --- a/settings_admin/role_admin.php +++ b/settings_admin/role_admin.php @@ -47,136 +47,23 @@ try { // 接続エラーのときエラー内容を取得する $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +blockedIP($_SERVER['REMOTE_ADDR']); +$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "admin"); +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"]); } -if(!($res["admin"] === "yes")){ - header("Location: ../login.php"); - exit; -} $notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'"); $notiQuery->bindValue(':userid', $userid); $notiQuery->execute(); diff --git a/settings_admin/serveradmin.php b/settings_admin/serveradmin.php index 1804083..d732aea 100644 --- a/settings_admin/serveradmin.php +++ b/settings_admin/serveradmin.php @@ -59,136 +59,23 @@ try { // 接続エラーのときエラー内容を取得する $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +blockedIP($_SERVER['REMOTE_ADDR']); +$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "admin"); +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"]); } -if(!($res["admin"] === "yes")){ - header("Location: ../login.php"); - exit; -} $notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'"); $notiQuery->bindValue(':userid', $userid); $notiQuery->execute(); @@ -280,6 +167,13 @@ if( !empty($_POST['btn_submit']) ) { $savemigration = "false"; } + $get_ip_addr = safetext($_POST['get_ip_addr']); + if($get_ip_addr === "true"){ + $saveget_ip_addr = "true"; + }else{ + $saveget_ip_addr = "false"; + } + $postrobots = safetext($_POST['robots']); if($postrobots === "true"){ //GPTBotによるクロールを拒否 @@ -319,6 +213,8 @@ if( !empty($_POST['btn_submit']) ) { server_activitypub = "'.$saveactivitypub.'" ;アカウントの移行登録を許可するか server_account_migration = "'.$savemigration.'" + ;IPアドレスを取得するか + server_get_ip = "'.$saveget_ip_addr.'" '; //サーバー設定上書き @@ -471,7 +367,7 @@ require('../logout/logout.php');

招待制にするかどうか

- + @@ -485,7 +381,7 @@ require('../logout/logout.php');

アカウントの移行登録を許可するか

他のuwuzuサーバーからのアカウント移行を許可するかです。
このサーバーが招待制の場合移行登録にも招待コードが必要となります。
- + @@ -514,7 +410,7 @@ require('../logout/logout.php');

ActivityPubサーバーとして認識されるようにするか

ActivityPubの仮実装をオンにするかです。inboxに入ってきた内容には今現在これといったレスポンスを返しません。
また、publicKeyも返却しません。
現状ActivityPubサーバーと連合を組むことは出来ません。(リモートユーザーの確認程度なら出来ます。)
オフの状態だと410 Goneを返します。
- + @@ -524,6 +420,20 @@ require('../logout/logout.php');
+
+

IPアドレスを取得するか

+
ユーザーの最終アクセス時のIPアドレスを取得して保存するかどうかを設定します。
IPアドレスは最終アクセス時のものを暗号化されて保存されます。
プライバシーに関わる事項のため注意して設定してください。
+
+ + + + + + + +
+
+

利用規約

diff --git a/settings_admin/settings_left_menu.php b/settings_admin/settings_left_menu.php index af95f9b..c4eb2fa 100644 --- a/settings_admin/settings_left_menu.php +++ b/settings_admin/settings_left_menu.php @@ -12,6 +12,7 @@ メンテナンス プラグイン アップデート + IPブロック ログ
\ No newline at end of file diff --git a/settings_admin/update_admin.php b/settings_admin/update_admin.php index babb182..0846007 100644 --- a/settings_admin/update_admin.php +++ b/settings_admin/update_admin.php @@ -43,136 +43,23 @@ try { // 接続エラーのときエラー内容を取得する $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +blockedIP($_SERVER['REMOTE_ADDR']); +$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "admin"); +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"]); } -if(!($res["admin"] === "yes")){ - header("Location: ../login.php"); - exit; -} $notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'"); $notiQuery->bindValue(':userid', $userid); $notiQuery->execute(); diff --git a/settings_admin/useradmin.php b/settings_admin/useradmin.php index bfe142f..094ee95 100644 --- a/settings_admin/useradmin.php +++ b/settings_admin/useradmin.php @@ -47,136 +47,23 @@ try { // 接続エラーのときエラー内容を取得する $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +blockedIP($_SERVER['REMOTE_ADDR']); +$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "admin"); +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"]); } -if(!($res["admin"] === "yes")){ - header("Location: ../login.php"); - exit; -} $notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'"); $notiQuery->bindValue(':userid', $userid); $notiQuery->execute(); diff --git a/settings_admin/userinfo.php b/settings_admin/userinfo.php index bb4d351..82ae1de 100644 --- a/settings_admin/userinfo.php +++ b/settings_admin/userinfo.php @@ -47,135 +47,21 @@ try { // 接続エラーのときエラー内容を取得する $error_message[] = $e->getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); - exit; -} - -if(!($res["admin"] === "yes")){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +blockedIP($_SERVER['REMOTE_ADDR']); +$is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "admin"); +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"]); } if(empty($_SESSION["query_userid"])){ @@ -204,8 +90,10 @@ if (!empty($pdo)) { if(!(empty($userdata["encryption_ivkey"]))){ $view_mailadds = DecryptionUseEncrKey($userdata["mailadds"], GenUserEnckey($userdata["datetime"]), $userdata["encryption_ivkey"]); + $view_ip_addr = DecryptionUseEncrKey($userdata["last_ip"], GenUserEnckey($userdata["datetime"]), $userdata["encryption_ivkey"]); }else{ $view_mailadds = $userdata["mailadds"]; + $view_ip_addr = $userdata["last_ip"]; } $roles = explode(',', $userdata["role"]); @@ -683,6 +571,9 @@ require('../logout/logout.php');
アカウント登録日時


+
最終アクセス時のIPアドレス
+

+
アカウント操作
diff --git a/success.php b/success.php index eaac871..a19f3cd 100644 --- a/success.php +++ b/success.php @@ -1,5 +1,7 @@ getMessage(); } -if(isset($_SESSION['admin_login']) && $_SESSION['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_SESSION['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_SESSION['loginid'] === $res["loginid"] && $_SESSION['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // セッションに格納されている値をそのままセット - $username = safetext($res['username']); // セッションに格納されている値をそのままセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid, [ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} elseif (isset($_COOKIE['admin_login']) && $_COOKIE['admin_login'] == true) { - - $passQuery = $pdo->prepare("SELECT username,userid,loginid,follow,admin,role,sacinfo,blocklist FROM account WHERE userid = :userid"); - $passQuery->bindValue(':userid', safetext($_COOKIE['userid'])); - $passQuery->execute(); - $res = $passQuery->fetch(); - if(empty($res["userid"])){ - header("Location: ../login.php"); - exit; - }elseif($_COOKIE['loginid'] === $res["loginid"] && $_COOKIE['userid'] == $res["userid"]){ - // セッションに値をセット - $userid = safetext($res['userid']); // クッキーから取得した値をセット - $username = safetext($res['username']); // クッキーから取得した値をセット - $loginid = safetext($res["loginid"]); - $role = safetext($res["role"]); - $sacinfo = safetext($res["sacinfo"]); - $myblocklist = safetext($res["blocklist"]); - $myfollowlist = safetext($res["follow"]); - $_SESSION['admin_login'] = true; - $_SESSION['userid'] = $userid; - $_SESSION['username'] = $username; - $_SESSION['loginid'] = $res["loginid"]; - setcookie('userid', $userid,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('username', $username,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('loginid', $res["loginid"],[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - setcookie('admin_login', true,[ - 'expires' => time() + 60 * 60 * 24 * 28, - 'path' => '/', - 'samesite' => 'lax', - 'secure' => true, - 'httponly' => true, - ]); - }else{ - header("Location: ../login.php"); - exit; - } - - -} else { - // ログインが許可されていない場合、ログインページにリダイレクト - header("Location: ../login.php"); - exit; -} -if(empty($userid)){ - header("Location: ../login.php"); - exit; -} -if(empty($username)){ - header("Location: ../login.php"); +//ログイン認証--------------------------------------------------- +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"]); } if (!(empty($pdo))) { @@ -377,6 +268,10 @@ $pdo = null;
+ +