・
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(); } 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 (!(empty($pdo))) { $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(isset($_GET['ueuseid'])) { $ueuseid = safetext(str_replace('!', '', $_GET['ueuseid'])); } } //返信先id取得 if (!(empty($pdo))) { $toUserIdQuery = $pdo->prepare("SELECT account FROM ueuse WHERE uniqid = :ueuseid ORDER BY datetime ASC LIMIT 1"); $toUserIdQuery->bindValue(':ueuseid', $ueuseid, PDO::PARAM_STR); $toUserIdQuery->execute(); $toUserId_res = $toUserIdQuery->fetch(); if(!(empty($toUserId_res))){ $touserid = $toUserId_res["account"]; }else{ $touserid = null; } } //-----------------URLから取得---------------- if(isset($_GET['text'])) { $ueuse = safetext(urldecode($_GET['text'])); }elseif(isset($_COOKIE['ueuse'])) { $ueuse = safetext($_COOKIE['ueuse']); } //------------------------------------------- if( !empty($_POST['btn_submit']) ) { $settingsJsonQuery = $pdo->prepare("SELECT userid, other_settings FROM account WHERE userid = :userid"); $settingsJsonQuery->bindValue(':userid', $userid); $settingsJsonQuery->execute(); $settingsJson = $settingsJsonQuery->fetch(); if(!(empty($settingsJson["other_settings"]))){ $isAIBWM = val_OtherSettings("isAIBlockWaterMark", $settingsJson["other_settings"]); }else{ $isAIBWM = false; } $ueuse = safetext($_POST['ueuse']); if(isset($_POST['nsfw_chk'])){ $nsfw_chk = safetext($_POST['nsfw_chk']); }else{ $nsfw_chk = "false"; } $photo1 = $_FILES['upload_images']; $photo2 = $_FILES['upload_images2']; $photo3 = $_FILES['upload_images3']; $photo4 = $_FILES['upload_images4']; $video1 = $_FILES['upload_videos1']; $rpUniqid = $ueuseid; $ruUniqid = ""; $ueuse_result = send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$photo4,$video1,$nsfw_chk,$isAIBWM); if($ueuse_result == null){ //一時保存していたユーズ内容の削除 setcookie("ueuse", "", time() - 3600, "/!".$ueuseid); $url = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; header("Location:".$url.""); exit; }else{ $error_message = $ueuse_result; } } if( !empty($_POST['logout']) ) { if (isset($_SERVER['HTTP_COOKIE'])) { $cookies = explode(';', $_SERVER['HTTP_COOKIE']); foreach($cookies as $cookie) { $parts = explode('=', $cookie); $name = trim($parts[0]); setcookie($name, '', time()-1000); setcookie($name, '', time()-1000, '/'); } } // リダイレクト先のURLへ転送する $url = '../index.php'; header('Location: ' . $url, true, 303); // すべての出力を終了 exit; } // データベースの接続を閉じる $pdo = null; ?>
・