diff --git a/.well-known/host-meta/index.php b/.well-known/host-meta/index.php index 33b264b..9507b10 100644 --- a/.well-known/host-meta/index.php +++ b/.well-known/host-meta/index.php @@ -5,8 +5,7 @@ $serversettings = parse_ini_file($serversettings_file, true); require("../../function/function.php"); if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ - header("Content-Type: application/xml"); - header("charset=UTF-8"); + header("Content-Type: application/xml; charset=UTF-8"); header("Access-Control-Allow-Origin: *"); $domain = $_SERVER['HTTP_HOST']; diff --git a/.well-known/nodeinfo/index.php b/.well-known/nodeinfo/index.php index 6f4d653..950dc0c 100644 --- a/.well-known/nodeinfo/index.php +++ b/.well-known/nodeinfo/index.php @@ -5,8 +5,7 @@ $serversettings = parse_ini_file($serversettings_file, true); require("../../function/function.php"); if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ - header("Content-Type: application/activity+json"); - header("charset=utf-8"); + header("Content-Type: application/activity+json; charset=utf-8"); header("Access-Control-Allow-Origin: *"); $domain = $_SERVER['HTTP_HOST']; diff --git a/.well-known/webfinger/index.php b/.well-known/webfinger/index.php index b9862d3..aac3b42 100644 --- a/.well-known/webfinger/index.php +++ b/.well-known/webfinger/index.php @@ -5,8 +5,7 @@ $serversettings = parse_ini_file($serversettings_file, true); require("../../function/function.php"); if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ - header("Content-Type: application/jrd+json"); - header("charset=utf-8"); + header("Content-Type: application/jrd+json; charset=utf-8"); header("Access-Control-Allow-Origin: *"); $domain = $_SERVER['HTTP_HOST']; diff --git a/actor/index.php b/actor/index.php index 11674f2..1c26c26 100644 --- a/actor/index.php +++ b/actor/index.php @@ -5,8 +5,7 @@ $serversettings = parse_ini_file($serversettings_file, true); require("../function/function.php"); if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ - header("Content-Type: application/activity+json"); - header("charset=utf-8"); + header("Content-Type: application/activity+json; charset=utf-8"); header("Access-Control-Allow-Origin: *"); $domain = $_SERVER['HTTP_HOST']; diff --git a/api/bot-api.php b/api/bot-api.php index ebc48e7..92fcc19 100644 --- a/api/bot-api.php +++ b/api/bot-api.php @@ -1,6 +1,5 @@ commit(); } catch(Exception $e) { $pdo->rollBack(); + actionLog($account, "error", "migration-api", null, $e, 4); } $newrole = "ice"; $newtoken = "ice"; @@ -87,6 +86,7 @@ if(isset($_GET['migration_code'])) { // エラーが発生した時はロールバック $pdo->rollBack(); + actionLog($account, "error", "migration-api", null, $e, 4); } //メール送信はナシ //------------ diff --git a/api/serverinfo-api.php b/api/serverinfo-api.php index 0f125a1..02a5af7 100644 --- a/api/serverinfo-api.php +++ b/api/serverinfo-api.php @@ -1,8 +1,7 @@ 'gif', + "image/jpeg" => 'jpg', + "image/png" => 'png', + "image/svg+xml" => 'svg', + "image/webp" => 'webp', + "image/bmp" => 'bmp', + "image/x-icon" => 'ico', + "image/tiff" => 'tiff' + ]; + + if (!(isset($safe_img_mime[$mime_type]))) { + return false; + } + + $extension = $safe_img_mime[$mime_type]; + + // 一時ファイルを作成 + $temp_file = tempnam(sys_get_temp_dir(), 'img'); + file_put_contents($temp_file, $decodedData); + + // 必要に応じてEXIFデータを削除 + delete_exif($extension, $temp_file); + + // ファイル名とアップロードパスを生成 + $newFilename = createUniqId() . '-' . $userid . '.' . $extension; + + // $_FILES形式の配列を作成して返す + return [ + 'name' => $newFilename, + 'type' => $mime_type, + 'tmp_name' => $temp_file, + 'error' => 0, + 'size' => filesize($temp_file), + ]; +} + function resizeImage($filePath, $maxWidth, $maxHeight) { if (file_exists($filePath)) { // 元の画像タイプを取得 @@ -670,11 +721,13 @@ function send_notification($to,$from,$title,$message,$url,$category){ return true; }else{ $pdo->rollBack(); + actionLog($from, "error", "send_notification", $to, "通知の送信に失敗しました(rollBack)", 3); return false; } } catch(Exception $e) { $pdo->rollBack(); + actionLog($from, "error", "send_notification", $to, $e, 4); return false; } }else{ @@ -728,13 +781,12 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ } if(!(empty($pdo))){ - - $result = $pdo->prepare("SELECT username FROM account WHERE userid = :userid"); - $result->bindValue(':userid', $userid); - $result->execute(); - $row = $result->fetch(); - $username = safetext($row["username"]); - + $userData = getUserData($pdo, $userid); + $username = safetext($userData["username"]); + $userRoleList = explode(',', safetext($userData["role"])); + if(in_array("ice", $userRoleList)){ + $error_message[] = 'アカウントが凍結されています。(ACCOUNT_HAS_BEEN_FROZEN)'; + } $ueuse = safetext($ueuse); if(safetext($nsfw) === "true"){ $save_nsfw = "true"; @@ -771,391 +823,400 @@ function send_ueuse($userid,$rpUniqid,$ruUniqid,$ueuse,$photo1,$photo2,$photo3,$ $rate_Query->execute(); $rate_count = $rate_Query->rowCount(); if(!($rate_count > $max_ueuse_rate_limit-1)){ - if (empty($photo1['name'])) { - $save_photo1 = "none"; - } else { - // アップロードされたファイル情報 - $uploadedFile = $photo1; - - if(!(empty($uploadedFile['tmp_name']))){ - if(check_mime($uploadedFile['tmp_name'])){ - // アップロードされたファイルの拡張子を取得 - $extension = pathinfo($uploadedFile['name'], PATHINFO_EXTENSION); - // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename = createUniqId() . '-'.$userid.'.' . $extension; - // 保存先のパスを生成 - $uploadedPath = '../ueuseimages/' . $newFilename; - // EXIF削除 - delete_exif($extension, $uploadedFile['tmp_name']); - // ファイルを移動 - $result = move_uploaded_file($uploadedFile['tmp_name'], $uploadedPath); - - if ($result) { - $save_photo1 = $uploadedPath; // 保存されたファイルのパスを使用 - } else { - $errnum = $uploadedFile['error']; - if($errnum === 1){$errcode = "FILE_DEKASUGUI_PHP_INI_KAKUNIN";} - if($errnum === 2){$errcode = "FILE_DEKASUGUI_HTML_KAKUNIN";} - if($errnum === 3){$errcode = "FILE_SUKOSHIDAKE_UPLOAD";} - if($errnum === 4){$errcode = "FILE_UPLOAD_DEKINAKATTA";} - if($errnum === 6){$errcode = "TMP_FOLDER_NAI";} - if($errnum === 7){$errcode = "FILE_KAKIKOMI_SIPPAI";} - if($errnum === 8){$errcode = "PHPINFO()_KAKUNIN";} - $error_message[] = 'アップロード失敗!(1)エラーコード:' .$errcode.''; - } - }else{ - $error_message[] = "使用できない画像形式です。(SORRY_FILE_HITAIOU)"; - } - }else{ - $error_message[] = "ファイルがアップロードできませんでした。(FILE_UPLOAD_DEKINAKATTA)"; - } - } - - if (empty($photo2['name'])) { - $save_photo2 = "none"; - } else { - if (empty($photo1['name'])){ - $error_message[] = '画像1から画像を選択してください!!!(PHOTO_SELECT_PLEASE)'; - } - // アップロードされたファイル情報 - $uploadedFile2 = $photo2; - - if(!(empty($uploadedFile2['tmp_name']))){ - if(check_mime($uploadedFile2['tmp_name'])){ - // アップロードされたファイルの拡張子を取得 - $extension2 = pathinfo($uploadedFile2['name'], PATHINFO_EXTENSION); - // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename2 = createUniqId() . '-'.$userid.'.' . $extension2; - // 保存先のパスを生成 - $uploadedPath2 = '../ueuseimages/' . $newFilename2; - // EXIF削除 - delete_exif($extension, $uploadedFile2['tmp_name']); - // ファイルを移動 - $result2 = move_uploaded_file($uploadedFile2['tmp_name'], $uploadedPath2); - if ($result2) { - $save_photo2 = $uploadedPath2; // 保存されたファイルのパスを使用 - } else { - $errnum = $uploadedFile2['error']; - if($errnum === 1){$errcode = "FILE_DEKASUGUI_PHP_INI_KAKUNIN";} - if($errnum === 2){$errcode = "FILE_DEKASUGUI_HTML_KAKUNIN";} - if($errnum === 3){$errcode = "FILE_SUKOSHIDAKE_UPLOAD";} - if($errnum === 4){$errcode = "FILE_UPLOAD_DEKINAKATTA";} - if($errnum === 6){$errcode = "TMP_FOLDER_NAI";} - if($errnum === 7){$errcode = "FILE_KAKIKOMI_SIPPAI";} - if($errnum === 8){$errcode = "PHPINFO()_KAKUNIN";} - $error_message[] = 'アップロード失敗!(2)エラーコード:' .$errcode.''; - } - }else{ - $error_message[] = "使用できない画像形式です。(SORRY_FILE_HITAIOU)"; - } - }else{ - $error_message[] = "ファイルがアップロードできませんでした。(FILE_UPLOAD_DEKINAKATTA)"; - } - } - - if (empty($photo3['name'])) { - $save_photo3 = "none"; - } else { - if (empty($photo2['name'])){ - $error_message[] = '画像2から画像を選択してください!!!(PHOTO_SELECT_PLEASE)'; - } - // アップロードされたファイル情報 - $uploadedFile3 = $photo3; - - if(!(empty($uploadedFile3['tmp_name']))){ - if(check_mime($uploadedFile3['tmp_name'])){ - // アップロードされたファイルの拡張子を取得 - $extension3 = pathinfo($uploadedFile3['name'], PATHINFO_EXTENSION); - // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename3 = createUniqId() . '-'.$userid.'.' . $extension3; - // 保存先のパスを生成 - $uploadedPath3 = '../ueuseimages/' . $newFilename3; - // EXIF削除 - delete_exif($extension3, $uploadedFile3['tmp_name']); - // ファイルを移動 - $result3 = move_uploaded_file($uploadedFile3['tmp_name'], $uploadedPath3); - if ($result3) { - $save_photo3 = $uploadedPath3; // 保存されたファイルのパスを使用 - } else { - $errnum = $uploadedFile3['error']; - if($errnum === 1){$errcode = "FILE_DEKASUGUI_PHP_INI_KAKUNIN";} - if($errnum === 2){$errcode = "FILE_DEKASUGUI_HTML_KAKUNIN";} - if($errnum === 3){$errcode = "FILE_SUKOSHIDAKE_UPLOAD";} - if($errnum === 4){$errcode = "FILE_UPLOAD_DEKINAKATTA";} - if($errnum === 6){$errcode = "TMP_FOLDER_NAI";} - if($errnum === 7){$errcode = "FILE_KAKIKOMI_SIPPAI";} - if($errnum === 8){$errcode = "PHPINFO()_KAKUNIN";} - $error_message[] = 'アップロード失敗!(3)エラーコード:' .$errcode.''; - } - }else{ - $error_message[] = "使用できない画像形式です。(SORRY_FILE_HITAIOU)"; - } - }else{ - $error_message[] = "ファイルがアップロードできませんでした。(FILE_UPLOAD_DEKINAKATTA)"; - } - } - - if (empty($photo4['name'])) { - $save_photo4 = "none"; - } else { - if (empty($photo3['name'])){ - $error_message[] = '画像3から画像を選択してください!!!(PHOTO_SELECT_PLEASE)'; - } - // アップロードされたファイル情報 - $uploadedFile4 = $photo4; - if(!(empty($uploadedFile4['tmp_name']))){ - if(check_mime($uploadedFile4['tmp_name'])){ - // アップロードされたファイルの拡張子を取得 - $extension4 = pathinfo($uploadedFile4['name'], PATHINFO_EXTENSION); - // 新しいファイル名を生成(uniqid + 拡張子) - $newFilename4 = createUniqId() . '-'.$userid.'.' . $extension4; - // 保存先のパスを生成 - $uploadedPath4 = '../ueuseimages/' . $newFilename4; - // EXIF削除 - delete_exif($extension4, $uploadedFile4['tmp_name']); - // ファイルを移動 - $result4 = move_uploaded_file($uploadedFile4['tmp_name'], $uploadedPath4); - if ($result4) { - $save_photo4 = $uploadedPath4; // 保存されたファイルのパスを使用 - } else { - $errnum = $uploadedFile4['error']; - if($errnum === 1){$errcode = "FILE_DEKASUGUI_PHP_INI_KAKUNIN";} - if($errnum === 2){$errcode = "FILE_DEKASUGUI_HTML_KAKUNIN";} - if($errnum === 3){$errcode = "FILE_SUKOSHIDAKE_UPLOAD";} - if($errnum === 4){$errcode = "FILE_UPLOAD_DEKINAKATTA";} - if($errnum === 6){$errcode = "TMP_FOLDER_NAI";} - if($errnum === 7){$errcode = "FILE_KAKIKOMI_SIPPAI";} - if($errnum === 8){$errcode = "PHPINFO()_KAKUNIN";} - $error_message[] = 'アップロード失敗!(4)エラーコード:' .$errcode.''; - } - }else{ - $error_message[] = "使用できない画像形式です。(SORRY_FILE_HITAIOU)"; - } - }else{ - $error_message[] = "ファイルがアップロードできませんでした。(FILE_UPLOAD_DEKINAKATTA)"; - } - } - - if (empty($video1['name'])) { - $save_video1 = "none"; - } else { - // アップロードされたファイル情報 - $uploadedVideo = $video1; - - if(!(empty($uploadedVideo['tmp_name']))){ - if(check_mime_video($uploadedVideo['tmp_name'])){ - // アップロードされたファイルの拡張子を取得 - $extensionVideo = strtolower(pathinfo($uploadedVideo['name'], PATHINFO_EXTENSION)); // 小文字に変換 - // 正しい拡張子の場合、新しいファイル名を生成 - $newFilenameVideo = createUniqId() . '-'.$userid.'.' . $extensionVideo; - // 保存先のパスを生成 - $uploadedPathVideo = '../ueusevideos/' . $newFilenameVideo; - // ファイルを移動 - $resultVideo = move_uploaded_file($uploadedVideo['tmp_name'], $uploadedPathVideo); - if ($resultVideo) { - $save_video1 = $uploadedPathVideo; // 保存されたファイルのパスを使用 - } else { - $errnum = $uploadedVideo['error']; - if($errnum === 1){$errcode = "FILE_DEKASUGUI_PHP_INI_KAKUNIN";} - if($errnum === 2){$errcode = "FILE_DEKASUGUI_HTML_KAKUNIN";} - if($errnum === 3){$errcode = "FILE_SUKOSHIDAKE_UPLOAD";} - if($errnum === 4){$errcode = "FILE_UPLOAD_DEKINAKATTA";} - if($errnum === 6){$errcode = "TMP_FOLDER_NAI";} - if($errnum === 7){$errcode = "FILE_KAKIKOMI_SIPPAI";} - if($errnum === 8){$errcode = "PHPINFO()_KAKUNIN";} - $error_message[] = 'アップロード失敗!(5)エラーコード:' .$errcode.''; - } - } else { - $error_message[] = '対応していないファイル形式です!(SORRY_FILE_HITAIOU)'; - } - }else{ - $error_message[] = "ファイルがアップロードできませんでした。(FILE_UPLOAD_DEKINAKATTA)"; - } - } - - if($aibwm === true && !empty(AIBWM_CHK && AIBWM_CHK == "true")){ - require('../plugin/AIBlockWaterMark/aiblockwatermark.php'); - if(!($save_photo1 == "none")){ - AIBlockWaterMark($save_photo1, $userid); - } - if(!($save_photo2 == "none")){ - AIBlockWaterMark($save_photo2, $userid); - } - if(!($save_photo3 == "none")){ - AIBlockWaterMark($save_photo3, $userid); - } - if(!($save_photo4 == "none")){ - AIBlockWaterMark($save_photo4, $userid); - } - } - - if(empty($error_message)) { - // 書き込み日時を取得 - $datetime = date("Y-m-d H:i:s"); - $uniqid = createUniqId(); - $abi = "none"; - - if(empty($rpUniqid) && empty($ruUniqid)){ - // トランザクション開始 - $pdo->beginTransaction(); - - try { - - // SQL作成 - $stmt = $pdo->prepare("INSERT INTO ueuse (username, account, uniqid, ueuse, photo1, photo2, photo3, photo4, video1, datetime, abi, nsfw) VALUES (:username, :account, :uniqid, :ueuse, :photo1, :photo2, :photo3, :photo4, :video1, :datetime, :abi, :nsfw)"); - - $stmt->bindParam(':username', $username, PDO::PARAM_STR); - $stmt->bindParam(':account', $userid, PDO::PARAM_STR); - $stmt->bindParam(':uniqid', $uniqid, PDO::PARAM_STR); - $stmt->bindParam(':ueuse', $ueuse, PDO::PARAM_STR); - - $stmt->bindParam(':photo1', $save_photo1, PDO::PARAM_STR); - $stmt->bindParam(':photo2', $save_photo2, PDO::PARAM_STR); - $stmt->bindParam(':photo3', $save_photo3, PDO::PARAM_STR); - $stmt->bindParam(':photo4', $save_photo4, PDO::PARAM_STR); - $stmt->bindParam(':video1', $save_video1, PDO::PARAM_STR); - $stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR); - - $stmt->bindParam(':nsfw', $save_nsfw, PDO::PARAM_STR); - - $stmt->bindParam(':abi', $abi, PDO::PARAM_STR); - - // SQLクエリの実行 - $res = $stmt->execute(); - - // コミット - $res = $pdo->commit(); - - $mentionedUsers = array_unique(get_mentions_userid($ueuse)); - - foreach ($mentionedUsers as $mentionedUser) { - send_notification($mentionedUser,$userid,"".$userid."さんにメンションされました!",$ueuse,"/!".$uniqid."", "mention"); - } - - } catch(Exception $e) { - // エラーが発生した時はロールバック - $pdo->rollBack(); - actionLog($userid, "error", "send_ueuse", null, $e, 4); - } - }elseif((!empty($rpUniqid)) && empty($ruUniqid)){ - $toUserIdQuery = $pdo->prepare("SELECT account FROM ueuse WHERE uniqid = :ueuseid ORDER BY datetime ASC LIMIT 1"); - $toUserIdQuery->bindValue(':ueuseid', $rpUniqid, PDO::PARAM_STR); - $toUserIdQuery->execute(); - $toUserId_res = $toUserIdQuery->fetch(); - - if(!(empty($toUserId_res))){ - $touserid = $toUserId_res["account"]; - }else{ - $touserid = null; - } - - // トランザクション開始 - $pdo->beginTransaction(); - - try { - // SQL作成 - $stmt = $pdo->prepare("INSERT INTO ueuse (username, account, uniqid, rpuniqid, ueuse, photo1, photo2, photo3, photo4, video1, datetime, abi, nsfw) VALUES (:username, :account, :uniqid, :rpuniqid, :ueuse, :photo1, :photo2, :photo3, :photo4, :video1, :datetime, :abi, :nsfw)"); - - $stmt->bindParam(':username', $username, PDO::PARAM_STR); - $stmt->bindParam(':account', $userid, PDO::PARAM_STR); - $stmt->bindParam(':uniqid', $uniqid, PDO::PARAM_STR); - $stmt->bindParam(':rpuniqid', $rpUniqid, PDO::PARAM_STR); - $stmt->bindParam(':ueuse', $ueuse, PDO::PARAM_STR); - - $stmt->bindParam(':photo1', $save_photo1, PDO::PARAM_STR); - $stmt->bindParam(':photo2', $save_photo2, PDO::PARAM_STR); - $stmt->bindParam(':photo3', $save_photo3, PDO::PARAM_STR); - $stmt->bindParam(':photo4', $save_photo4, PDO::PARAM_STR); - $stmt->bindParam(':video1', $save_video1, PDO::PARAM_STR); - $stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR); - - $stmt->bindParam(':nsfw', $save_nsfw, PDO::PARAM_STR); - - $stmt->bindParam(':abi', $abi, PDO::PARAM_STR); - - // SQLクエリの実行 - $res = $stmt->execute(); - - // コミット - $res = $pdo->commit(); - - $mentionedUsers = array_unique(get_mentions_userid($ueuse)); - - foreach ($mentionedUsers as $mentionedUser) { - send_notification($mentionedUser,$userid,"".$userid."さんにメンションされました!",$ueuse,"/!".$uniqid."", "mention"); - } - - send_notification($touserid,$userid,"".$userid."さんが返信しました!",$ueuse,"/!".$uniqid."", "reply"); - } catch(Exception $e) { - // エラーが発生した時はロールバック - $pdo->rollBack(); - actionLog($userid, "error", "send_ueuse", null, $e, 4); - } - }elseif(empty($rpUniqid) && (!empty($ruUniqid))){ - $toUserIdQuery = $pdo->prepare("SELECT account FROM ueuse WHERE uniqid = :ueuseid ORDER BY datetime ASC LIMIT 1"); - $toUserIdQuery->bindValue(':ueuseid', $ruUniqid, PDO::PARAM_STR); - $toUserIdQuery->execute(); - $toUserId_res = $toUserIdQuery->fetch(); - - if(!(empty($toUserId_res))){ - $touserid = $toUserId_res["account"]; - }else{ - $touserid = null; - } - // トランザクション開始 - $pdo->beginTransaction(); - - try { - // SQL作成 - $stmt = $pdo->prepare("INSERT INTO ueuse (username, account, uniqid, ruuniqid, ueuse, photo1, photo2, photo3, photo4, video1, datetime, abi, nsfw) VALUES (:username, :account, :uniqid, :ruuniqid, :ueuse, :photo1, :photo2, :photo3, :photo4, :video1, :datetime, :abi, :nsfw)"); - - $stmt->bindParam(':username', $username, PDO::PARAM_STR); - $stmt->bindParam(':account', $userid, PDO::PARAM_STR); - $stmt->bindParam(':uniqid', $uniqid, PDO::PARAM_STR); - $stmt->bindParam(':ruuniqid', $ruUniqid, PDO::PARAM_STR); - $stmt->bindParam(':ueuse', $ueuse, PDO::PARAM_STR); - - $stmt->bindParam(':photo1', $save_photo1, PDO::PARAM_STR); - $stmt->bindParam(':photo2', $save_photo2, PDO::PARAM_STR); - $stmt->bindParam(':photo3', $save_photo3, PDO::PARAM_STR); - $stmt->bindParam(':photo4', $save_photo4, PDO::PARAM_STR); - $stmt->bindParam(':video1', $save_video1, PDO::PARAM_STR); - $stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR); - - $stmt->bindParam(':nsfw', $save_nsfw, PDO::PARAM_STR); - - $stmt->bindParam(':abi', $abi, PDO::PARAM_STR); - - - // SQLクエリの実行 - $res = $stmt->execute(); - - // コミット - $res = $pdo->commit(); - - $mentionedUsers = array_unique(get_mentions_userid($ueuse)); - - foreach ($mentionedUsers as $mentionedUser) { - send_notification($mentionedUser,$userid,"".$userid."さんにメンションされました!",$ueuse,"/!".$uniqid."", "mention"); - } - - send_notification($touserid,$userid,"".$userid."さんがリユーズしました!",$ueuse,"/!".$uniqid."", "reuse"); - - } catch(Exception $e) { - // エラーが発生した時はロールバック - $pdo->rollBack(); - actionLog($userid, "error", "send_ueuse", null, $e, 4); - } - } - if( $res ) { - return null; + if(empty($error_message)) { + if (empty($photo1['name'])) { + $save_photo1 = "none"; } else { - $error_message[] = $e->getMessage(); + // アップロードされたファイル情報 + $uploadedFile = $photo1; + + if(!(empty($uploadedFile['tmp_name']))){ + if(check_mime($uploadedFile['tmp_name'])){ + // アップロードされたファイルの拡張子を取得 + $extension = strtolower(pathinfo($uploadedFile['name'], PATHINFO_EXTENSION)); + // 新しいファイル名を生成(uniqid + 拡張子) + $newFilename = createUniqId() . '-'.$userid.'.' . $extension; + // 保存先のパスを生成 + $uploadedPath = '../ueuseimages/' . $newFilename; + // EXIF削除 + delete_exif($extension, $uploadedFile['tmp_name']); + // ファイルを移動 + $result = move_uploaded_file($uploadedFile['tmp_name'], $uploadedPath); + + if ($result) { + $save_photo1 = $uploadedPath; // 保存されたファイルのパスを使用 + } else { + $errnum = $uploadedFile['error']; + if($errnum === 1){$errcode = "FILE_DEKASUGUI_PHP_INI_KAKUNIN";} + if($errnum === 2){$errcode = "FILE_DEKASUGUI_HTML_KAKUNIN";} + if($errnum === 3){$errcode = "FILE_SUKOSHIDAKE_UPLOAD";} + if($errnum === 4){$errcode = "FILE_UPLOAD_DEKINAKATTA";} + if($errnum === 6){$errcode = "TMP_FOLDER_NAI";} + if($errnum === 7){$errcode = "FILE_KAKIKOMI_SIPPAI";} + if($errnum === 8){$errcode = "PHPINFO()_KAKUNIN";} + $error_message[] = 'アップロード失敗!(1)エラーコード:' .$errcode.''; + } + }else{ + $error_message[] = "使用できない画像形式です。(SORRY_FILE_HITAIOU)"; + } + }else{ + $error_message[] = "ファイルがアップロードできませんでした。(FILE_UPLOAD_DEKINAKATTA)"; + } + } + + if (empty($photo2['name'])) { + $save_photo2 = "none"; + } else { + if (empty($photo1['name'])){ + $error_message[] = '画像1から画像を選択してください!!!(PHOTO_SELECT_PLEASE)'; + } + // アップロードされたファイル情報 + $uploadedFile2 = $photo2; + + if(!(empty($uploadedFile2['tmp_name']))){ + if(check_mime($uploadedFile2['tmp_name'])){ + // アップロードされたファイルの拡張子を取得 + $extension2 = strtolower(pathinfo($uploadedFile2['name'], PATHINFO_EXTENSION)); + // 新しいファイル名を生成(uniqid + 拡張子) + $newFilename2 = createUniqId() . '-'.$userid.'.' . $extension2; + // 保存先のパスを生成 + $uploadedPath2 = '../ueuseimages/' . $newFilename2; + // EXIF削除 + delete_exif($extension2, $uploadedFile2['tmp_name']); + // ファイルを移動 + $result2 = move_uploaded_file($uploadedFile2['tmp_name'], $uploadedPath2); + if ($result2) { + $save_photo2 = $uploadedPath2; // 保存されたファイルのパスを使用 + } else { + $errnum = $uploadedFile2['error']; + if($errnum === 1){$errcode = "FILE_DEKASUGUI_PHP_INI_KAKUNIN";} + if($errnum === 2){$errcode = "FILE_DEKASUGUI_HTML_KAKUNIN";} + if($errnum === 3){$errcode = "FILE_SUKOSHIDAKE_UPLOAD";} + if($errnum === 4){$errcode = "FILE_UPLOAD_DEKINAKATTA";} + if($errnum === 6){$errcode = "TMP_FOLDER_NAI";} + if($errnum === 7){$errcode = "FILE_KAKIKOMI_SIPPAI";} + if($errnum === 8){$errcode = "PHPINFO()_KAKUNIN";} + $error_message[] = 'アップロード失敗!(2)エラーコード:' .$errcode.''; + } + }else{ + $error_message[] = "使用できない画像形式です。(SORRY_FILE_HITAIOU)"; + } + }else{ + $error_message[] = "ファイルがアップロードできませんでした。(FILE_UPLOAD_DEKINAKATTA)"; + } + } + + if (empty($photo3['name'])) { + $save_photo3 = "none"; + } else { + if (empty($photo2['name'])){ + $error_message[] = '画像2から画像を選択してください!!!(PHOTO_SELECT_PLEASE)'; + } + // アップロードされたファイル情報 + $uploadedFile3 = $photo3; + + if(!(empty($uploadedFile3['tmp_name']))){ + if(check_mime($uploadedFile3['tmp_name'])){ + // アップロードされたファイルの拡張子を取得 + $extension3 = strtolower(pathinfo($uploadedFile3['name'], PATHINFO_EXTENSION)); + // 新しいファイル名を生成(uniqid + 拡張子) + $newFilename3 = createUniqId() . '-'.$userid.'.' . $extension3; + // 保存先のパスを生成 + $uploadedPath3 = '../ueuseimages/' . $newFilename3; + // EXIF削除 + delete_exif($extension3, $uploadedFile3['tmp_name']); + // ファイルを移動 + $result3 = move_uploaded_file($uploadedFile3['tmp_name'], $uploadedPath3); + if ($result3) { + $save_photo3 = $uploadedPath3; // 保存されたファイルのパスを使用 + } else { + $errnum = $uploadedFile3['error']; + if($errnum === 1){$errcode = "FILE_DEKASUGUI_PHP_INI_KAKUNIN";} + if($errnum === 2){$errcode = "FILE_DEKASUGUI_HTML_KAKUNIN";} + if($errnum === 3){$errcode = "FILE_SUKOSHIDAKE_UPLOAD";} + if($errnum === 4){$errcode = "FILE_UPLOAD_DEKINAKATTA";} + if($errnum === 6){$errcode = "TMP_FOLDER_NAI";} + if($errnum === 7){$errcode = "FILE_KAKIKOMI_SIPPAI";} + if($errnum === 8){$errcode = "PHPINFO()_KAKUNIN";} + $error_message[] = 'アップロード失敗!(3)エラーコード:' .$errcode.''; + } + }else{ + $error_message[] = "使用できない画像形式です。(SORRY_FILE_HITAIOU)"; + } + }else{ + $error_message[] = "ファイルがアップロードできませんでした。(FILE_UPLOAD_DEKINAKATTA)"; + } + } + + if (empty($photo4['name'])) { + $save_photo4 = "none"; + } else { + if (empty($photo3['name'])){ + $error_message[] = '画像3から画像を選択してください!!!(PHOTO_SELECT_PLEASE)'; + } + // アップロードされたファイル情報 + $uploadedFile4 = $photo4; + if(!(empty($uploadedFile4['tmp_name']))){ + if(check_mime($uploadedFile4['tmp_name'])){ + // アップロードされたファイルの拡張子を取得 + $extension4 = strtolower(pathinfo($uploadedFile4['name'], PATHINFO_EXTENSION)); + // 新しいファイル名を生成(uniqid + 拡張子) + $newFilename4 = createUniqId() . '-'.$userid.'.' . $extension4; + // 保存先のパスを生成 + $uploadedPath4 = '../ueuseimages/' . $newFilename4; + // EXIF削除 + delete_exif($extension4, $uploadedFile4['tmp_name']); + // ファイルを移動 + $result4 = move_uploaded_file($uploadedFile4['tmp_name'], $uploadedPath4); + if ($result4) { + $save_photo4 = $uploadedPath4; // 保存されたファイルのパスを使用 + } else { + $errnum = $uploadedFile4['error']; + if($errnum === 1){$errcode = "FILE_DEKASUGUI_PHP_INI_KAKUNIN";} + if($errnum === 2){$errcode = "FILE_DEKASUGUI_HTML_KAKUNIN";} + if($errnum === 3){$errcode = "FILE_SUKOSHIDAKE_UPLOAD";} + if($errnum === 4){$errcode = "FILE_UPLOAD_DEKINAKATTA";} + if($errnum === 6){$errcode = "TMP_FOLDER_NAI";} + if($errnum === 7){$errcode = "FILE_KAKIKOMI_SIPPAI";} + if($errnum === 8){$errcode = "PHPINFO()_KAKUNIN";} + $error_message[] = 'アップロード失敗!(4)エラーコード:' .$errcode.''; + } + }else{ + $error_message[] = "使用できない画像形式です。(SORRY_FILE_HITAIOU)"; + } + }else{ + $error_message[] = "ファイルがアップロードできませんでした。(FILE_UPLOAD_DEKINAKATTA)"; + } + } + + if (empty($video1['name'])) { + $save_video1 = "none"; + } else { + // アップロードされたファイル情報 + $uploadedVideo = $video1; + + if(!(empty($uploadedVideo['tmp_name']))){ + if(check_mime_video($uploadedVideo['tmp_name'])){ + // アップロードされたファイルの拡張子を取得 + $extensionVideo = strtolower(pathinfo($uploadedVideo['name'], PATHINFO_EXTENSION)); // 小文字に変換 + // 正しい拡張子の場合、新しいファイル名を生成 + $newFilenameVideo = createUniqId() . '-'.$userid.'.' . $extensionVideo; + // 保存先のパスを生成 + $uploadedPathVideo = '../ueusevideos/' . $newFilenameVideo; + // ファイルを移動 + $resultVideo = move_uploaded_file($uploadedVideo['tmp_name'], $uploadedPathVideo); + if ($resultVideo) { + $save_video1 = $uploadedPathVideo; // 保存されたファイルのパスを使用 + } else { + $errnum = $uploadedVideo['error']; + if($errnum === 1){$errcode = "FILE_DEKASUGUI_PHP_INI_KAKUNIN";} + if($errnum === 2){$errcode = "FILE_DEKASUGUI_HTML_KAKUNIN";} + if($errnum === 3){$errcode = "FILE_SUKOSHIDAKE_UPLOAD";} + if($errnum === 4){$errcode = "FILE_UPLOAD_DEKINAKATTA";} + if($errnum === 6){$errcode = "TMP_FOLDER_NAI";} + if($errnum === 7){$errcode = "FILE_KAKIKOMI_SIPPAI";} + if($errnum === 8){$errcode = "PHPINFO()_KAKUNIN";} + $error_message[] = 'アップロード失敗!(5)エラーコード:' .$errcode.''; + } + } else { + $error_message[] = '対応していないファイル形式です!(SORRY_FILE_HITAIOU)'; + } + }else{ + $error_message[] = "ファイルがアップロードできませんでした。(FILE_UPLOAD_DEKINAKATTA)"; + } + } + + if($aibwm === true && !empty(AIBWM_CHK && AIBWM_CHK == "true")){ + require('../plugin/AIBlockWaterMark/aiblockwatermark.php'); + if(!($save_photo1 == "none")){ + AIBlockWaterMark($save_photo1, $userid); + } + if(!($save_photo2 == "none")){ + AIBlockWaterMark($save_photo2, $userid); + } + if(!($save_photo3 == "none")){ + AIBlockWaterMark($save_photo3, $userid); + } + if(!($save_photo4 == "none")){ + AIBlockWaterMark($save_photo4, $userid); + } + } + + if(empty($error_message)) { + // 書き込み日時を取得 + $datetime = date("Y-m-d H:i:s"); + $uniqid = createUniqId(); + $abi = "none"; + + if(empty($rpUniqid) && empty($ruUniqid)){ + // トランザクション開始 + $pdo->beginTransaction(); + + try { + + // SQL作成 + $stmt = $pdo->prepare("INSERT INTO ueuse (username, account, uniqid, ueuse, photo1, photo2, photo3, photo4, video1, datetime, abi, nsfw) VALUES (:username, :account, :uniqid, :ueuse, :photo1, :photo2, :photo3, :photo4, :video1, :datetime, :abi, :nsfw)"); + + $stmt->bindParam(':username', $username, PDO::PARAM_STR); + $stmt->bindParam(':account', $userid, PDO::PARAM_STR); + $stmt->bindParam(':uniqid', $uniqid, PDO::PARAM_STR); + $stmt->bindParam(':ueuse', $ueuse, PDO::PARAM_STR); + + $stmt->bindParam(':photo1', $save_photo1, PDO::PARAM_STR); + $stmt->bindParam(':photo2', $save_photo2, PDO::PARAM_STR); + $stmt->bindParam(':photo3', $save_photo3, PDO::PARAM_STR); + $stmt->bindParam(':photo4', $save_photo4, PDO::PARAM_STR); + $stmt->bindParam(':video1', $save_video1, PDO::PARAM_STR); + $stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR); + + $stmt->bindParam(':nsfw', $save_nsfw, PDO::PARAM_STR); + + $stmt->bindParam(':abi', $abi, PDO::PARAM_STR); + + // SQLクエリの実行 + $res = $stmt->execute(); + + // コミット + $res = $pdo->commit(); + + $mentionedUsers = array_unique(get_mentions_userid($ueuse)); + + foreach ($mentionedUsers as $mentionedUser) { + send_notification($mentionedUser,$userid,"".$userid."さんにメンションされました!",$ueuse,"/!".$uniqid."", "mention"); + } + + } catch(Exception $e) { + // エラーが発生した時はロールバック + $pdo->rollBack(); + actionLog($userid, "error", "send_ueuse", null, $e, 4); + } + }elseif((!empty($rpUniqid)) && empty($ruUniqid)){ + $toUserIdQuery = $pdo->prepare("SELECT account FROM ueuse WHERE uniqid = :ueuseid ORDER BY datetime ASC LIMIT 1"); + $toUserIdQuery->bindValue(':ueuseid', $rpUniqid, PDO::PARAM_STR); + $toUserIdQuery->execute(); + $toUserId_res = $toUserIdQuery->fetch(); + + if(!(empty($toUserId_res))){ + $touserid = $toUserId_res["account"]; + }else{ + $touserid = null; + } + + // トランザクション開始 + $pdo->beginTransaction(); + + try { + // SQL作成 + $stmt = $pdo->prepare("INSERT INTO ueuse (username, account, uniqid, rpuniqid, ueuse, photo1, photo2, photo3, photo4, video1, datetime, abi, nsfw) VALUES (:username, :account, :uniqid, :rpuniqid, :ueuse, :photo1, :photo2, :photo3, :photo4, :video1, :datetime, :abi, :nsfw)"); + + $stmt->bindParam(':username', $username, PDO::PARAM_STR); + $stmt->bindParam(':account', $userid, PDO::PARAM_STR); + $stmt->bindParam(':uniqid', $uniqid, PDO::PARAM_STR); + $stmt->bindParam(':rpuniqid', $rpUniqid, PDO::PARAM_STR); + $stmt->bindParam(':ueuse', $ueuse, PDO::PARAM_STR); + + $stmt->bindParam(':photo1', $save_photo1, PDO::PARAM_STR); + $stmt->bindParam(':photo2', $save_photo2, PDO::PARAM_STR); + $stmt->bindParam(':photo3', $save_photo3, PDO::PARAM_STR); + $stmt->bindParam(':photo4', $save_photo4, PDO::PARAM_STR); + $stmt->bindParam(':video1', $save_video1, PDO::PARAM_STR); + $stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR); + + $stmt->bindParam(':nsfw', $save_nsfw, PDO::PARAM_STR); + + $stmt->bindParam(':abi', $abi, PDO::PARAM_STR); + + // SQLクエリの実行 + $res = $stmt->execute(); + + // コミット + $res = $pdo->commit(); + + $mentionedUsers = array_unique(get_mentions_userid($ueuse)); + + foreach ($mentionedUsers as $mentionedUser) { + send_notification($mentionedUser,$userid,"".$userid."さんにメンションされました!",$ueuse,"/!".$uniqid."", "mention"); + } + + send_notification($touserid,$userid,"".$userid."さんが返信しました!",$ueuse,"/!".$uniqid."", "reply"); + } catch(Exception $e) { + // エラーが発生した時はロールバック + $pdo->rollBack(); + actionLog($userid, "error", "send_ueuse", null, $e, 4); + } + }elseif(empty($rpUniqid) && (!empty($ruUniqid))){ + $toUserIdQuery = $pdo->prepare("SELECT account FROM ueuse WHERE uniqid = :ueuseid ORDER BY datetime ASC LIMIT 1"); + $toUserIdQuery->bindValue(':ueuseid', $ruUniqid, PDO::PARAM_STR); + $toUserIdQuery->execute(); + $toUserId_res = $toUserIdQuery->fetch(); + + if(!(empty($toUserId_res))){ + $touserid = $toUserId_res["account"]; + }else{ + $touserid = null; + } + // トランザクション開始 + $pdo->beginTransaction(); + + try { + // SQL作成 + $stmt = $pdo->prepare("INSERT INTO ueuse (username, account, uniqid, ruuniqid, ueuse, photo1, photo2, photo3, photo4, video1, datetime, abi, nsfw) VALUES (:username, :account, :uniqid, :ruuniqid, :ueuse, :photo1, :photo2, :photo3, :photo4, :video1, :datetime, :abi, :nsfw)"); + + $stmt->bindParam(':username', $username, PDO::PARAM_STR); + $stmt->bindParam(':account', $userid, PDO::PARAM_STR); + $stmt->bindParam(':uniqid', $uniqid, PDO::PARAM_STR); + $stmt->bindParam(':ruuniqid', $ruUniqid, PDO::PARAM_STR); + $stmt->bindParam(':ueuse', $ueuse, PDO::PARAM_STR); + + $stmt->bindParam(':photo1', $save_photo1, PDO::PARAM_STR); + $stmt->bindParam(':photo2', $save_photo2, PDO::PARAM_STR); + $stmt->bindParam(':photo3', $save_photo3, PDO::PARAM_STR); + $stmt->bindParam(':photo4', $save_photo4, PDO::PARAM_STR); + $stmt->bindParam(':video1', $save_video1, PDO::PARAM_STR); + $stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR); + + $stmt->bindParam(':nsfw', $save_nsfw, PDO::PARAM_STR); + + $stmt->bindParam(':abi', $abi, PDO::PARAM_STR); + + + // SQLクエリの実行 + $res = $stmt->execute(); + + // コミット + $res = $pdo->commit(); + + $mentionedUsers = array_unique(get_mentions_userid($ueuse)); + + foreach ($mentionedUsers as $mentionedUser) { + send_notification($mentionedUser,$userid,"".$userid."さんにメンションされました!",$ueuse,"/!".$uniqid."", "mention"); + } + + send_notification($touserid,$userid,"".$userid."さんがリユーズしました!",$ueuse,"/!".$uniqid."", "reuse"); + + } catch(Exception $e) { + // エラーが発生した時はロールバック + $pdo->rollBack(); + actionLog($userid, "error", "send_ueuse", null, $e, 4); + } + }else{ + $error_message[] = '返信とリユーズを同時に行うことはできません。(ERROR)'; + return $error_message; + } + + if( $res ) { + return null; + } else { + $error_message[] = "ユーズに失敗しました。(REGISTERED_DAME)"; + return $error_message; + } + + // プリペアドステートメントを削除 + $stmt = null; + }else{ + actionLog($userid, "error", "send_ueuse", null, $error_message, 0); return $error_message; } - - // プリペアドステートメントを削除 - $stmt = null; }else{ actionLog($userid, "error", "send_ueuse", null, $error_message, 0); return $error_message; diff --git a/nextpage/bookmark.php b/nextpage/bookmark.php index 5b8d712..5e1ff04 100644 --- a/nextpage/bookmark.php +++ b/nextpage/bookmark.php @@ -23,14 +23,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $userid = safetext($_GET['userid']); $loginid = safetext($_GET['account_id']); - // データベース接続の設定 - $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, - )); - - $query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); + $query = $pdo->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); $query->execute(array(':userid' => $userid)); @@ -57,15 +50,9 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $messages = array(); 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, - )); // フォローしているユーザーIDを取得し、カンマで区切る - $bookmarkQuery = $dbh->prepare("SELECT bookmark FROM account WHERE userid = :userid"); + $bookmarkQuery = $pdo->prepare("SELECT bookmark FROM account WHERE userid = :userid"); $bookmarkQuery->bindValue(':userid', $userid); $bookmarkQuery->execute(); $bookmarkData = $bookmarkQuery->fetch(); diff --git a/nextpage/emojiview.php b/nextpage/emojiview.php index 1fd2ce5..5ea477b 100644 --- a/nextpage/emojiview.php +++ b/nextpage/emojiview.php @@ -29,14 +29,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id']) && isset($_GET['search_ } $offset = ($pageNumber - 1) * $itemsPerPage; - // データベース接続の設定 - $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, - )); - - $query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); + $query = $pdo->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); $query->execute(array(':userid' => $userid)); diff --git a/nextpage/foryoupage.php b/nextpage/foryoupage.php index 35e0d45..eb23dc2 100644 --- a/nextpage/foryoupage.php +++ b/nextpage/foryoupage.php @@ -22,14 +22,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $userid = safetext($_GET['userid']); $loginid = safetext($_GET['account_id']); - // データベース接続の設定 - $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, - )); - - $query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); + $query = $pdo->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); $query->execute(array(':userid' => $userid)); @@ -68,9 +61,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $all_stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT); $all_stmt->execute(); - while ($row = $all_stmt->fetch(PDO::FETCH_ASSOC)) { - $all_messages[] = $row; - } + $all_messages = $all_stmt->fetchAll(PDO::FETCH_ASSOC); if(empty($all_messages)){ $all_messages = []; } @@ -87,13 +78,14 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $Before7daysPosts = $cnt_stmt->fetchAll(PDO::FETCH_ASSOC); // 結果が15件に満たない場合 - if(count($Before7daysPosts) < 15){ + $postCount = count($Before7daysPosts); + if($postCount < 15){ $get_day = 90; - }elseif(count($Before7daysPosts) > 15 && count($Before7daysPosts) < 150){ + }elseif($postCount > 15 && $postCount < 150){ $get_day = 31; - }elseif(count($Before7daysPosts) > 150 && count($Before7daysPosts) < 750){ + }elseif($postCount > 150 && $postCount < 750){ $get_day = 7; - }elseif(count($Before7daysPosts) > 750){ + }elseif($postCount > 750){ $get_day = 5; }else{ $get_day = 2; @@ -127,10 +119,8 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $pop_stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT); $pop_stmt->execute(); - while ($row = $pop_stmt->fetch(PDO::FETCH_ASSOC)) { - $pop_messages[] = $row; - } - if(empty($flw_messages)){ + $pop_messages = $pop_stmt->fetchAll(PDO::FETCH_ASSOC); + if(empty($pop_messages)){ $pop_messages = []; } @@ -175,53 +165,45 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $fav_stmt = $pdo->prepare($fav_sql); $fav_stmt->bindValue(':userid', $userid, PDO::PARAM_STR); $fav_stmt->execute(); - while ($row = $fav_stmt->fetch(PDO::FETCH_ASSOC)) { - $fav_ueuse_lists[] = $row; - } - if(!(empty($fav_ueuse_lists))){ + $fav_ueuse_lists = $fav_stmt->fetchAll(PDO::FETCH_ASSOC); + + if (!empty($fav_ueuse_lists)) { $many_fav_accounts = array_column($fav_ueuse_lists, 'account'); $many_fav_account_counts = array_count_values($many_fav_accounts); arsort($many_fav_account_counts); - $top_fav_accounts = array_slice($many_fav_account_counts, 0, 15, true); + $top_fav_accounts = array_slice($many_fav_account_counts, 0, 15, true); - foreach ($top_fav_accounts as $favUserId => $count) { - $favget_sql = "SELECT ueuse.* + $favget_messages = []; + $favget_sql = "SELECT ueuse.* FROM ueuse LEFT JOIN account ON ueuse.account = account.userid WHERE ueuse.rpuniqid = '' AND account.role != 'ice' AND ueuse.account = :fav_account AND ueuse.datetime >= NOW() - INTERVAL :getday DAY ORDER BY ueuse.datetime DESC LIMIT :offset, :itemsPerPage"; - - $favget_stmt = $pdo->prepare($favget_sql); - $favget_stmt->bindValue(':getday', $get_day, PDO::PARAM_INT); - $favget_stmt->bindValue(':offset', $offset, PDO::PARAM_INT); - $favget_stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT); + + $favget_stmt = $pdo->prepare($favget_sql); + $favget_stmt->bindValue(':getday', $get_day, PDO::PARAM_INT); + $favget_stmt->bindValue(':offset', $offset, PDO::PARAM_INT); + $favget_stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT); + + foreach ($top_fav_accounts as $favUserId => $count) { $favget_stmt->bindValue(':fav_account', $favUserId, PDO::PARAM_STR); $favget_stmt->execute(); - - while ($row = $favget_stmt->fetch(PDO::FETCH_ASSOC)) { - $favget_messages[] = $row; - } + $favget_messages = array_merge($favget_messages, $favget_stmt->fetchAll(PDO::FETCH_ASSOC)); } - if(empty($favget_messages)){ - $favget_messages = []; - } - }else{ + } else { $favget_messages = []; } - //基本的には人気・フォロー中・いいねする事が多いユーザーのユーズでTLを構成するけど全部出きったらLTLと同じにする - if(empty($pop_messages) && empty($flw_messages) && empty($favget_messages)){ + // 基本的には人気・フォロー中・いいねする事が多いユーザーのユーズでTLを構成するけど全部出きったらLTLと同じにする + $messages = array_merge($pop_messages, $flw_messages, $favget_messages); + if (empty($messages)) { $messages = $all_messages; - }elseif(count(array_merge($pop_messages, $flw_messages, $favget_messages)) < 15){ - $total_messages = array_unique(array_merge($all_messages, $pop_messages, $flw_messages, $favget_messages), SORT_REGULAR); - shuffle($total_messages); - $messages = array_slice($total_messages, 0, 15); - }else{ - $total_messages = array_unique(array_merge($pop_messages, $flw_messages, $favget_messages), SORT_REGULAR); - shuffle($total_messages); - $messages = array_slice($total_messages, 0, 15); + } elseif (count($messages) < 15) { + $messages = array_merge($messages, $all_messages); } + $messages = array_slice(array_unique($messages, SORT_REGULAR), 0, 15); + shuffle($messages); // ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える foreach ($messages as &$message) { diff --git a/nextpage/ftlpage.php b/nextpage/ftlpage.php index d80e3d8..b795d62 100644 --- a/nextpage/ftlpage.php +++ b/nextpage/ftlpage.php @@ -23,14 +23,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $userid = safetext($_GET['userid']); $loginid = safetext($_GET['account_id']); - // データベース接続の設定 - $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, - )); - - $query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); + $query = $pdo->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); $query->execute(array(':userid' => $userid)); @@ -57,15 +50,8 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $messages = array(); 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, - )); - // フォローしているユーザーIDを取得し、カンマで区切る - $followQuery = $dbh->prepare("SELECT follow FROM account WHERE userid = :userid"); + $followQuery = $pdo->prepare("SELECT follow FROM account WHERE userid = :userid"); $followQuery->bindValue(':userid', $userid); $followQuery->execute(); $followData = $followQuery->fetch(); diff --git a/nextpage/newueuse_chk.php b/nextpage/newueuse_chk.php index b3ad7ae..ebcf473 100644 --- a/nextpage/newueuse_chk.php +++ b/nextpage/newueuse_chk.php @@ -20,14 +20,7 @@ if (isset($_POST['userid']) && isset($_POST['account_id'])) { $userid = safetext($_POST['userid']); $loginid = safetext($_POST['account_id']); - // データベース接続の設定 - $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, - )); - - $query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); + $query = $pdo->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); $query->execute(array(':userid' => $userid)); diff --git a/nextpage/nextpage.php b/nextpage/nextpage.php index 2784453..cafcf47 100644 --- a/nextpage/nextpage.php +++ b/nextpage/nextpage.php @@ -22,14 +22,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $userid = safetext($_GET['userid']); $loginid = safetext($_GET['account_id']); - // データベース接続の設定 - $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, - )); - - $query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); + $query = $pdo->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); $query->execute(array(':userid' => $userid)); diff --git a/nextpage/notification.php b/nextpage/notification.php index f654f9b..933b1cb 100644 --- a/nextpage/notification.php +++ b/nextpage/notification.php @@ -51,14 +51,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $messages = array(); 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, - )); - - $messageQuery = $dbh->prepare("SELECT fromuserid,title,msg,url,datetime,userchk FROM notification WHERE touserid = :userid ORDER BY datetime DESC LIMIT :offset, :itemsPerPage"); + $messageQuery = $pdo->prepare("SELECT fromuserid,title,msg,url,datetime,userchk FROM notification WHERE touserid = :userid ORDER BY datetime DESC LIMIT :offset, :itemsPerPage"); $messageQuery->bindValue(':userid', $userid, PDO::PARAM_STR); $messageQuery->bindValue(':offset', $offset, PDO::PARAM_INT); $messageQuery->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT); @@ -81,7 +74,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $value["servericon"] = safetext($serversettings["serverinfo"]["server_icon"]); if(!(empty($value['fromuserid']))){ if(!($value['fromuserid'] == "uwuzu-fromsys")){ - $userQuery = $dbh->prepare("SELECT username,iconname FROM account WHERE userid = :userid"); + $userQuery = $pdo->prepare("SELECT username,iconname FROM account WHERE userid = :userid"); $userQuery->bindValue(':userid', $value['fromuserid']); $userQuery->execute(); $user_array = $userQuery->fetch(); diff --git a/nextpage/searchpage.php b/nextpage/searchpage.php index 6f2b254..1e13312 100644 --- a/nextpage/searchpage.php +++ b/nextpage/searchpage.php @@ -24,14 +24,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $userid = safetext($_GET['userid']); $loginid = safetext($_GET['account_id']); - // データベース接続の設定 - $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, - )); - - $query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); + $query = $pdo->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); $query->execute(array(':userid' => $userid)); @@ -60,18 +53,12 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $myblocklist = safetext($res["blocklist"]); $mybookmark = safetext($res["bookmark"]); - $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, - )); - $keywordPattern = '/from:@(\w+)\s+(.+)/'; if (preg_match($keywordPattern, $keyword, $matches)) { $username = $matches[1]; $searchKeyword = $matches[2]; - $messageQuery = $dbh->prepare("SELECT * FROM ueuse WHERE account = :username AND (ueuse LIKE :searchKeyword OR abi LIKE :searchKeyword) ORDER BY datetime DESC LIMIT :offset, :itemsPerPage"); + $messageQuery = $pdo->prepare("SELECT * FROM ueuse WHERE account = :username AND (ueuse LIKE :searchKeyword OR abi LIKE :searchKeyword) ORDER BY datetime DESC LIMIT :offset, :itemsPerPage"); $messageQuery->bindValue(':username', $username, PDO::PARAM_STR); $messageQuery->bindValue(':searchKeyword', '%' . $searchKeyword . '%', PDO::PARAM_STR); $messageQuery->bindValue(':offset', $offset, PDO::PARAM_INT); @@ -79,7 +66,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $messageQuery->execute(); $message_array = $messageQuery->fetchAll(); } else { - $messageQuery = $dbh->prepare("SELECT * FROM ueuse WHERE ueuse LIKE :keyword OR abi LIKE :keyword ORDER BY datetime DESC LIMIT :offset, :itemsPerPage"); + $messageQuery = $pdo->prepare("SELECT * FROM ueuse WHERE ueuse LIKE :keyword OR abi LIKE :keyword ORDER BY datetime DESC LIMIT :offset, :itemsPerPage"); $messageQuery->bindValue(':keyword', '%' . $keyword . '%', PDO::PARAM_STR); $messageQuery->bindValue(':offset', $offset, PDO::PARAM_INT); $messageQuery->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT); @@ -88,7 +75,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { } $user_keyword = str_replace('@', '', $keyword); - $usersQuery = $dbh->prepare("SELECT * FROM account WHERE username LIKE :keyword OR userid LIKE :keyword OR profile LIKE :keyword ORDER BY datetime DESC LIMIT :offset, :itemsPerPage"); + $usersQuery = $pdo->prepare("SELECT * FROM account WHERE username LIKE :keyword OR userid LIKE :keyword OR profile LIKE :keyword ORDER BY datetime DESC LIMIT :offset, :itemsPerPage"); $usersQuery->bindValue(':offset', $offset, PDO::PARAM_INT); $usersQuery->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT); $usersQuery->bindValue(':keyword', '%' . $user_keyword . '%', PDO::PARAM_STR); diff --git a/nextpage/ueusepage.php b/nextpage/ueusepage.php index 3e4ba9b..f83a1d7 100644 --- a/nextpage/ueusepage.php +++ b/nextpage/ueusepage.php @@ -21,14 +21,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $userid = safetext($_GET['userid']); $loginid = safetext($_GET['account_id']); - // データベース接続の設定 - $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, - )); - - $query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); + $query = $pdo->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); $query->execute(array(':userid' => $userid)); @@ -57,17 +50,8 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $messages = array(); 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, - )); - // 投稿内容の取得(新しい順に取得) - $messageQuery = $dbh->prepare("SELECT * FROM ueuse WHERE uniqid = :ueuseid OR rpuniqid = :rpueuseid ORDER BY datetime ASC LIMIT :offset, :itemsPerPage"); + $messageQuery = $pdo->prepare("SELECT * FROM ueuse WHERE uniqid = :ueuseid OR rpuniqid = :rpueuseid ORDER BY datetime ASC LIMIT :offset, :itemsPerPage"); $messageQuery->bindValue(':ueuseid', $ueuseid, PDO::PARAM_STR); $messageQuery->bindValue(':rpueuseid', $ueuseid, PDO::PARAM_STR); $messageQuery->bindValue(':offset', $offset, PDO::PARAM_INT); @@ -77,9 +61,6 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $messages = array(); - - - foreach ($message_array as $row) { if(!(empty($row["rpuniqid"]))){ if(!($row["rpuniqid"] == $ueuseid)){ diff --git a/nextpage/userlikepage.php b/nextpage/userlikepage.php index 78a1cb4..ca5a861 100644 --- a/nextpage/userlikepage.php +++ b/nextpage/userlikepage.php @@ -22,14 +22,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $userid = safetext($_GET['userid']); $loginid = safetext($_GET['account_id']); - // データベース接続の設定 - $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, - )); - - $query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); + $query = $pdo->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); $query->execute(array(':userid' => $userid)); @@ -58,13 +51,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { 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, follower FROM account WHERE userid = :userid"); + $userQuery = $pdo->prepare("SELECT username, userid, profile, role, follower FROM account WHERE userid = :userid"); $userQuery->bindValue(':userid', $uwuzuid); $userQuery->execute(); $userData = $userQuery->fetch(); diff --git a/nextpage/usermediapage.php b/nextpage/usermediapage.php index e9f6142..9a27512 100644 --- a/nextpage/usermediapage.php +++ b/nextpage/usermediapage.php @@ -21,14 +21,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $userid = safetext($_GET['userid']); $loginid = safetext($_GET['account_id']); - // データベース接続の設定 - $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, - )); - - $query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); + $query = $pdo->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); $query->execute(array(':userid' => $userid)); @@ -56,19 +49,12 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $messages = array(); 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, follower FROM account WHERE userid = :userid"); + $userQuery = $pdo->prepare("SELECT username, userid, profile, role, follower FROM account WHERE userid = :userid"); $userQuery->bindValue(':userid', $uwuzuid); $userQuery->execute(); $userData = $userQuery->fetch(); - $messageQuery = $dbh->prepare("SELECT * FROM ueuse WHERE account = :userid AND rpuniqid = '' AND ( + $messageQuery = $pdo->prepare("SELECT * FROM ueuse WHERE account = :userid AND rpuniqid = '' AND ( (photo1 IS NOT NULL AND photo1 != '' AND photo1 != 'none') OR (photo2 IS NOT NULL AND photo2 != '' AND photo2 != 'none') OR (photo3 IS NOT NULL AND photo3 != '' AND photo3 != 'none') OR diff --git a/nextpage/userpage.php b/nextpage/userpage.php index c52b686..191b0d7 100644 --- a/nextpage/userpage.php +++ b/nextpage/userpage.php @@ -22,14 +22,7 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $userid = safetext($_GET['userid']); $loginid = safetext($_GET['account_id']); - // データベース接続の設定 - $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, - )); - - $query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); + $query = $pdo->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); $query->execute(array(':userid' => $userid)); @@ -57,19 +50,12 @@ if (isset($_GET['userid']) && isset($_GET['account_id'])) { $messages = array(); 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, follower FROM account WHERE userid = :userid"); + $userQuery = $pdo->prepare("SELECT username, userid, profile, role, follower FROM account WHERE userid = :userid"); $userQuery->bindValue(':userid', $uwuzuid); $userQuery->execute(); $userData = $userQuery->fetch(); - $messageQuery = $dbh->prepare("SELECT * FROM ueuse WHERE account = :userid AND rpuniqid = ''ORDER BY datetime DESC LIMIT :offset, :itemsPerPage"); + $messageQuery = $pdo->prepare("SELECT * FROM ueuse WHERE account = :userid AND rpuniqid = ''ORDER BY datetime DESC LIMIT :offset, :itemsPerPage"); $messageQuery->bindValue(':userid', $uwuzuid); $messageQuery->bindValue(':offset', $offset, PDO::PARAM_INT); $messageQuery->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT); diff --git a/sample.php b/sample.php deleted file mode 100644 index ad5bb22..0000000 --- a/sample.php +++ /dev/null @@ -1,28 +0,0 @@ - 1) { - return strtoupper($parts[1]); // 国コード (例: US, FR, JP) - } - return null; -} - -$browserLanguage = getBrowserLanguage(); -$countryCode = getCountryFromLanguage($browserLanguage); -if ($countryCode) { - echo "推測される国: " . $countryCode; -} else { - echo "国を推測できませんでした"; -} - -?> \ No newline at end of file diff --git a/search/opensearch.php b/search/opensearch.php index 41be1a7..49028ff 100644 --- a/search/opensearch.php +++ b/search/opensearch.php @@ -4,8 +4,7 @@ require("../function/function.php"); $serversettings_file = "../server/serversettings.ini"; $serversettings = parse_ini_file($serversettings_file, true); -header("Content-Type: application/xml"); -header("charset=UTF-8"); +header("Content-Type: application/xml; charset=UTF-8"); header("Access-Control-Allow-Origin: *"); $domain = $_SERVER['HTTP_HOST']; diff --git a/server/uwuzuinfo.txt b/server/uwuzuinfo.txt index b96dd87..5227526 100644 --- a/server/uwuzuinfo.txt +++ b/server/uwuzuinfo.txt @@ -1,4 +1,4 @@ uwuzu -1.4.10 -2024/12/27 +1.4.11 +2024/12/29 daichimarukana,putonfps \ No newline at end of file diff --git a/server/uwuzurelease.txt b/server/uwuzurelease.txt index 3775e9f..3ad1975 100644 --- a/server/uwuzurelease.txt +++ b/server/uwuzurelease.txt @@ -1,6 +1,17 @@ ## リリースノートだぜぇぇぇぇぇぇい!!!!!!! ここにはuwuzuの更新情報を載せてくぜぇ~!(いやまてテンションおかしいだろ...) +## Version 1.4.11 (Funium) +2024/12/29 +fix: CGI版のphpでエラーが発生してしまう問題を修正しました。 +fix: 凍結されているアカウントがユーズできてしまう恐れのある問題を修正しました。 +fix: 凍結されているアカウントが設定を変更できてしまう恐れのある問題を修正しました。 +fix: 画像付きのユーズが投稿できない可能性のある問題を修正しました。 +fix: 通報時に正常に管理者に通知が届かなくなってしまう可能性のある問題を修正しました。 +fix: その他様々な問題を修正しました。 +chg: すべてのタイムラインの取得を若干~大幅に効率化しました(APIを除く) +chg: ユーザープロフィールでのフォロー・フォロワー一覧の並びを新しい順にしました! + ## Version 1.4.10 (Funium) 2024/12/27 fix: serverinfo-apiが使用できない問題を修正しました! diff --git a/settings_admin/api/code_delete.php b/settings_admin/api/code_delete.php index 810fb4d..0c416b3 100644 --- a/settings_admin/api/code_delete.php +++ b/settings_admin/api/code_delete.php @@ -2,8 +2,7 @@ require('../../db.php'); require("../../function/function.php"); -header("Content-Type: application/json"); -header("charset=utf-8"); +header("Content-Type: application/json; charset=utf-8"); header("Access-Control-Allow-Origin: *"); if (safetext(isset($_POST['code'])) && safetext(isset($_POST['userid'])) && safetext(isset($_POST['account_id']))){ @@ -22,14 +21,7 @@ if (safetext(isset($_POST['code'])) && safetext(isset($_POST['userid'])) && safe $error_message[] = $e->getMessage(); } - // データベース接続の設定 - $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, - )); - - $query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); + $query = $pdo->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); $query->execute(array(':userid' => $postUserid)); @@ -38,8 +30,6 @@ if (safetext(isset($_POST['code'])) && safetext(isset($_POST['userid'])) && safe if($result2["loginid"] === $loginid){ if($result2["admin"] === "yes"){ try { - $pdo = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST , DB_USER, DB_PASS); - // 削除クエリを実行 $deleteQuery = $pdo->prepare("DELETE FROM invitation WHERE code = :code"); $deleteQuery->bindValue(':code', $postCode, PDO::PARAM_STR); diff --git a/settings_admin/api/update_query.php b/settings_admin/api/update_query.php index d40e62b..c66335a 100644 --- a/settings_admin/api/update_query.php +++ b/settings_admin/api/update_query.php @@ -2,8 +2,7 @@ require('../../db.php'); require("../../function/function.php"); -header("Content-Type: application/json"); -header("charset=utf-8"); +header("Content-Type: application/json; charset=utf-8"); header("Access-Control-Allow-Origin: *"); if (isset($_FILES['update_zip']) && isset($_POST['userid']) && isset($_POST['account_id'])){ @@ -22,14 +21,7 @@ if (isset($_FILES['update_zip']) && isset($_POST['userid']) && isset($_POST['acc $error_message[] = $e->getMessage(); } - // データベース接続の設定 - $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, - )); - - $query = $dbh->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); + $query = $pdo->prepare('SELECT * FROM account WHERE userid = :userid limit 1'); $query->execute(array(':userid' => $postUserid)); diff --git a/settings_admin/overview_admin.php b/settings_admin/overview_admin.php index e07ad8c..ae187ff 100644 --- a/settings_admin/overview_admin.php +++ b/settings_admin/overview_admin.php @@ -217,22 +217,56 @@ if(!empty($pdo)){ //DB_Data try { $dbname = DB_NAME; - - $query = " - SELECT - table_name AS `Table`, - ROUND(((data_length + index_length) / 1024 / 1024), 2) AS `Size` - FROM - information_schema.TABLES - WHERE - table_schema = :database - ORDER BY - `Size` DESC; - "; + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + // データベース内の全テーブル名を取得 + $query = "SELECT table_name FROM information_schema.tables WHERE table_schema = :database"; $stmt = $pdo->prepare($query); $stmt->bindParam(':database', $dbname); $stmt->execute(); - $db_results = $stmt->fetchAll(PDO::FETCH_ASSOC); + $tables = $stmt->fetchAll(PDO::FETCH_COLUMN); + + // 各テーブルの正確な行数を取得 + $db_results = []; + foreach ($tables as $table) { + // 行数を取得 + $rowQuery = "SELECT COUNT(*) as count FROM `$table`"; + $rowStmt = $pdo->query($rowQuery); + $rowCount = (int)$rowStmt->fetchColumn(); + + // テーブルサイズを取得 + $sizeQuery = " + SELECT + ROUND(((data_length + index_length) / 1024 / 1024), 2) AS `Size` + FROM + information_schema.TABLES + WHERE + table_schema = :database AND table_name = :table; + "; + $sizeStmt = $pdo->prepare($sizeQuery); + $sizeStmt->execute([':database' => $dbname, ':table' => $table]); + $size = (float)$sizeStmt->fetchColumn(); + + // 結果を格納 + $db_results[] = [ + 'Table' => $table, + 'Rows' => $rowCount, + 'Size' => $size, + ]; + } + + // サイズで並び替え + usort($db_results, function ($a, $b) { + return $b['Size'] <=> $a['Size']; + }); + + // 行数を最大桁数に揃えて0埋め + $maxRows = max(array_column($db_results, 'Rows')); + foreach ($db_results as &$table) { + $table['Rows'] = str_pad($table['Rows'], strlen($maxRows), '0', STR_PAD_LEFT); + } + unset($table); // 参照を解除 + } catch (PDOException $e) { $db_results = null; } @@ -405,6 +439,7 @@ require('../logout/logout.php'); echo ""; echo "".$value['Table'].""; echo "".$value['Size']." MB"; + echo "".$value['Rows']." Records"; echo ""; } } diff --git a/ueuse/activity/index.php b/ueuse/activity/index.php index dbec3c0..9c24dcd 100644 --- a/ueuse/activity/index.php +++ b/ueuse/activity/index.php @@ -4,8 +4,7 @@ require("../../function/function.php"); $serversettings_file = "../../server/serversettings.ini"; $serversettings = parse_ini_file($serversettings_file, true); if(safetext($serversettings["serverinfo"]["server_activitypub"]) == "true"){ - header("Content-Type: application/activity+json"); - header("charset=utf-8"); + header("Content-Type: application/activity+json; charset=utf-8"); header("Access-Control-Allow-Origin: *"); $domain = $_SERVER['HTTP_HOST']; diff --git a/update.json b/update.json index b02b9fe..2ec823f 100644 --- a/update.json +++ b/update.json @@ -1,12 +1,57 @@ { "software": "uwuzu", - "version": "1.4.10", - "release_date": "2024/12/27", - "release_notes": "このアップデートではserverinfo-apiが使用できない問題の修正が含まれます!", + "version": "1.4.11", + "release_date": "2024/12/29", + "release_notes": "このアップデートではCGI版のphpで通常想定されないエラーが発生してしまう問題などいくつかの重要なバグの修正が含まれます!", "notices": "アップデートの前にデータのバックアップを行うことをおすすめします!", "files": { "overwrite": [ + "/.well-known/host-meta/index.php", + "/.well-known/nodeinfo/index.php", + "/.well-known/webfinger/index.php", + "/actor/index.php", + "/api/favorite/change.php", + "/api/favorite/get.php", + "/api/me/index.php", + "/api/ueuse/create.php", + "/api/ueuse/delete.php", + "/api/ueuse/get.php", + "/api/ueuse/index.php", + "/api/ueuse/mentions.php", + "/api/ueuse/replies.php", + "/api/ueuse/search.php", + "/api/users/follow.php", + "/api/users/index.php", + "/api/users/unfollow.php", + "/api/v1/instance.php", + "/api/bot-api.php", + "/api/migration-api.php", "/api/serverinfo-api.php", + "/api/bot-api.php", + "/function/function.php", + "/nextpage/bookmark.php", + "/nextpage/emojiview.php", + "/nextpage/foryoupage.php", + "/nextpage/ftlpage.php", + "/nextpage/newueuse_chk.php", + "/nextpage/nextpage.php", + "/nextpage/notification.php", + "/nextpage/searchpage.php", + "/nextpage/ueusepage.php", + "/nextpage/userlikepage.php", + "/nextpage/usermediapage.php", + "/nextpage/userpage.php", + "/search/opensearch.php", + "/settings_admin/api/code_delete.php", + "/settings_admin/api/update_query.php", + "/settings_admin/overview_admin.php", + "/ueuse/activity/index.php", + "/user/followers/index.php", + "/user/following/index.php", + "/user/inbox/index.php", + "/user/outbox/index.php", + "/user/index.php", + "/user/report.php", "/server/uwuzuabout.txt", "/server/uwuzuinfo.txt", "/server/uwuzurelease.txt" diff --git a/user/followers/index.php b/user/followers/index.php index 738ae08..5d2d639 100644 --- a/user/followers/index.php +++ b/user/followers/index.php @@ -4,8 +4,7 @@ require("../../function/function.php"); $serversettings_file = "../../server/serversettings.ini"; $serversettings = parse_ini_file($serversettings_file, true); if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ - header("Content-Type: application/activity+json"); - header("charset=utf-8"); + header("Content-Type: application/activity+json; charset=utf-8"); header("Access-Control-Allow-Origin: *"); $domain = $_SERVER['HTTP_HOST']; diff --git a/user/following/index.php b/user/following/index.php index 1f224e3..307c2ad 100644 --- a/user/following/index.php +++ b/user/following/index.php @@ -4,8 +4,7 @@ require("../../function/function.php"); $serversettings_file = "../../server/serversettings.ini"; $serversettings = parse_ini_file($serversettings_file, true); if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ - header("Content-Type: application/activity+json"); - header("charset=utf-8"); + header("Content-Type: application/activity+json; charset=utf-8"); header("Access-Control-Allow-Origin: *"); $domain = $_SERVER['HTTP_HOST']; diff --git a/user/inbox/index.php b/user/inbox/index.php index 869168d..78b78d3 100644 --- a/user/inbox/index.php +++ b/user/inbox/index.php @@ -4,8 +4,7 @@ require("../../function/function.php"); $serversettings_file = "../../server/serversettings.ini"; $serversettings = parse_ini_file($serversettings_file, true); if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ - header("Content-Type: application/activity+json"); - header("charset=utf-8"); + header("Content-Type: application/activity+json; charset=utf-8"); header("Access-Control-Allow-Origin: *"); $domain = $_SERVER['HTTP_HOST']; diff --git a/user/index.php b/user/index.php index c2da4cd..f7bc033 100644 --- a/user/index.php +++ b/user/index.php @@ -222,7 +222,7 @@ if (!empty($pdo)) { $follow = $userdata['follow']; // コンマで区切られたユーザーIDを含む変数 // コンマで区切って配列に分割し、要素数を数える - $followIds = explode(',', $follow); + $followIds = array_reverse(explode(',', $follow)); $followCount = count($followIds) - 1; $follow_on_me = array_search($userid, $followIds); @@ -237,7 +237,7 @@ if (!empty($pdo)) { $follower = $userdata['follower']; // コンマで区切られたユーザーIDを含む変数 // コンマで区切って配列に分割し、要素数を数える - $followerIds = explode(',', $follower); + $followerIds = array_reverse(explode(',', $follower)); $followerCount = count($followerIds) - 1; $profileText = safetext($userData['profile']); diff --git a/user/outbox/index.php b/user/outbox/index.php index 5af10c3..30e8bc4 100644 --- a/user/outbox/index.php +++ b/user/outbox/index.php @@ -4,8 +4,7 @@ require("../../function/function.php"); $serversettings_file = "../../server/serversettings.ini"; $serversettings = parse_ini_file($serversettings_file, true); if(safetext($serversettings["serverinfo"]["server_activitypub"]) === "true"){ - header("Content-Type: application/activity+json"); - header("charset=utf-8"); + header("Content-Type: application/activity+json; charset=utf-8"); header("Access-Control-Allow-Origin: *"); $domain = $_SERVER['HTTP_HOST']; diff --git a/user/report.php b/user/report.php index 513155f..c2aaa7d 100644 --- a/user/report.php +++ b/user/report.php @@ -247,9 +247,6 @@ if (!empty($_POST['report'])) { $res = $pdo->commit(); foreach ($admin_res as $to_admin) { - - $pdo->beginTransaction(); - $fromuserid = $userid; $touserid2 = $to_admin["userid"];//管理者宛通知 $msg = "通報情報をご確認ください!";