・
0, 'path' => '/', 'domain' => '', 'secure' => true, 'httponly' => true, 'samesite' => 'Lax' ]); session_start(); session_regenerate_id(true); try { $option = array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::MYSQL_ATTR_MULTI_STATEMENTS => false ); $pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS, $option); } catch(PDOException $e) { // 接続エラーのときエラー内容を取得する $error_message[] = $e->getMessage(); } //ログイン認証--------------------------------------------------- blockedIP($_SERVER['REMOTE_ADDR']); $is_login = uwuzuUserLogin($_SESSION, $_COOKIE, $_SERVER['REMOTE_ADDR'], "user"); if($is_login === false){ header("Location: ../index.php"); exit; }else{ $userid = safetext($is_login['userid']); $username = safetext($is_login['username']); $loginid = safetext($is_login["loginid"]); $role = safetext($is_login["role"]); $sacinfo = safetext($is_login["sacinfo"]); $myblocklist = safetext($is_login["blocklist"]); $myfollowlist = safetext($is_login["follow"]); $is_Admin = safetext($is_login["admin"]); } $notiQuery = $pdo->prepare("SELECT COUNT(*) as notification_count FROM notification WHERE touserid = :userid AND userchk = 'none'"); $notiQuery->bindValue(':userid', $userid); $notiQuery->execute(); $notiData = $notiQuery->fetch(PDO::FETCH_ASSOC); $notificationcount = $notiData['notification_count']; //ページ内のみ使用変数------------------------- $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) ) { $userData = getUserData($pdo, $userid); $role = $userData["role"]; $isAIBlock = val_OtherSettings("isAIBlock", $userData["other_settings"]); $isAIBWM = val_OtherSettings("isAIBlockWaterMark", $userData["other_settings"]); if(!(empty($userData["encryption_ivkey"]))){ $view_mailadds = DecryptionUseEncrKey($userData["mailadds"], GenUserEnckey($userData["datetime"]), $userData["encryption_ivkey"]); }else{ $view_mailadds = $userData["mailadds"]; } if(empty($userData["notification_settings"])){ $notification_settings_list = ["system","favorite","reply","reuse","ueuse","follow","mention","other"]; }else{ $notification_settings_list = explode(',', $userData["notification_settings"]); } if(filter_var($userData['iconname'], FILTER_VALIDATE_URL)){ $userData['iconname'] = $userData['iconname']; }else{ $userData['iconname'] = "../" . $userData['iconname']; } if(filter_var($userData['headname'], FILTER_VALIDATE_URL)){ $userData['headname'] = $userData['headname']; }else{ $userData['headname'] = "../" . $userData['headname']; } $apitokenQuery = $pdo->prepare("SELECT 1 FROM api WHERE userid = :userid LIMIT 1"); $apitokenQuery->bindValue(':userid', $userid); $apitokenQuery->execute(); if ($apitokenQuery->fetch()) { $is_allow_bot = true; } else { $is_allow_bot = false; } } if( !empty($_POST['btn_submit']) ) { $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"; } $username = safetext($_POST['username']); $mailadds = safetext($_POST['mailadds']); 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( !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"; }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"; $error_message[] = 'メールアドレスが正しい形式ではありません。(MAILADDS_CHECK_DAME)'; } }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(); 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; } } } if( !empty($_POST['pass_submit']) ) { $pass_chk = safetext($_POST['passchk_userid']); $password = $_POST['password']; if(empty($pass_chk)){ $error_message[] = 'ユーザーidを入力してください。(USERID_INPUT_PLEASE)'; }else{ if(!(preg_match("/^[a-zA-Z0-9_]+$/", $pass_chk))){ $error_message[] = "IDは半角英数字で作成してください。(「_」は使用可能です。)(USERID_DONT_USE_WORD)"; }else{ if(!($pass_chk === $userData["userid"])){ $error_message[] = 'ユーザーidが不正です。(USERID_CHIGAUYANKE)'; } } } // パスワードの入力チェック if( empty($password) ) { $error_message[] = 'パスワードを入力してください。(PASSWORD_INPUT_PLEASE)'; } else { if(in_array($password, $badpass) === true ){ $error_message[] = "パスワードが弱いです。セキュリティ上変更してください。(PASSWORD_ZEIJAKU)"; } if( 4 > mb_strlen($password, 'UTF-8') ) { $error_message[] = 'パスワードは4文字以上である必要があります。(PASSWORD_TODOITENAI_MIN_COUNT)'; } // 文字数を確認 if( 256 < mb_strlen($password, 'UTF-8') ) { $error_message[] = 'パスワードは256文字以内で入力してください。(PASSWORD_OVER_MAX_COUNT)'; } } if( empty($error_message) ) { // トランザクション開始 $pdo->beginTransaction(); $hashpassword = uwuzu_password_hash($password); try { // SQL作成 $stmt = $pdo->prepare("UPDATE account SET password = :password WHERE userid = :userid"); // 他の値をセット $stmt->bindParam(':password', $hashpassword, PDO::PARAM_STR); // 条件を指定 // 以下の部分を適切な条件に置き換えてください $stmt->bindValue(':userid', $userid, PDO::PARAM_STR); // SQLクエリの実行 $res = $stmt->execute(); // コミット $res = $pdo->commit(); } catch (Exception $e) { // エラーが発生した時はロールバック $pdo->rollBack(); } if ($res) { $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; header("Location:".$url.""); exit; } else { $error_message[] = '更新に失敗しました。(REGISTERED_DAME)'; } // プリペアドステートメントを削除 $stmt = null; } } if( !empty($_POST['auth_on_submit']) ) { $_SESSION['userid'] = $userid; // リダイレクト先のURLへ転送する $url = 'addauthcode.php'; header('Location: ' . $url, true, 303); // すべての出力を終了 exit; } if( !empty($_POST['auth_off_submit']) ) { if( empty($error_message) ) { $secret = ""; $backupcode = ""; // トランザクション開始 $pdo->beginTransaction(); try { // SQL作成 $stmt = $pdo->prepare("UPDATE account SET authcode = :authcode,backupcode = :backupcode WHERE userid = :userid"); $stmt->bindValue(':authcode', $secret, PDO::PARAM_STR); $stmt->bindValue(':backupcode', $backupcode, PDO::PARAM_STR); // ユーザーIDのバインド(WHERE句に必要) $stmt->bindValue(':userid', $userid, PDO::PARAM_STR); // SQLクエリの実行 $res = $stmt->execute(); // コミット $res = $pdo->commit(); } catch (Exception $e) { // エラーが発生した時はロールバック $pdo->rollBack(); } if ($res) { $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; header("Location:".$url.""); exit; } else { $error_message[] = '更新に失敗しました。(REGISTERED_DAME)'; } // プリペアドステートメントを削除 $stmt = null; } } if( !empty($_POST['notification_submit']) ) { $New_notification_list = ["system", "other"]; if(!(empty($_POST['notification_favorite']))){ if($_POST['notification_favorite'] == "on"){ $New_notification_list[] = "favorite"; } } if(!(empty($_POST['notification_reuse']))){ if($_POST['notification_reuse'] == "on"){ $New_notification_list[] = "reuse"; } } if(!(empty($_POST['notification_reply']))){ if($_POST['notification_reply'] == "on"){ $New_notification_list[] = "reply"; } } if(!(empty($_POST['notification_mention']))){ if($_POST['notification_mention'] == "on"){ $New_notification_list[] = "mention"; } } if(!(empty($_POST['notification_follow']))){ if($_POST['notification_follow'] == "on"){ $New_notification_list[] = "follow"; } } if( empty($error_message) ) { $Save_notification_list = implode(',', array_unique($New_notification_list)); // トランザクション開始 $pdo->beginTransaction(); try { $stmt = $pdo->prepare("UPDATE account SET notification_settings = :notification_settings WHERE userid = :userid"); $stmt->bindValue(':notification_settings', $Save_notification_list, PDO::PARAM_STR); $stmt->bindValue(':userid', $userid, PDO::PARAM_STR); $res = $stmt->execute(); // コミット $res = $pdo->commit(); } catch (Exception $e) { $pdo->rollBack(); } if ($res) { $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; header("Location:".$url.""); exit; } else { $error_message[] = '更新に失敗しました。(REGISTERED_DAME)'; } // プリペアドステートメントを削除 $stmt = null; } } // データベースの接続を閉じる $pdo = null; ?>
・