mirror of
https://github.com/Daichimarukana/uwuzu.git
synced 2026-06-04 19:14:41 +00:00
uwuzu v1.6.12 Hapuego
This commit is contained in:
+117
-114
@@ -14,135 +14,138 @@ if (safetext(isset($_POST['page'])) && safetext(isset($_POST['userid'])) && safe
|
||||
if ($is_login === false) {
|
||||
echo json_encode(['success' => false, 'error' => 'bad_request']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// データベースに接続
|
||||
try {
|
||||
$option = array(
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
|
||||
);
|
||||
$pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
|
||||
} catch (PDOException $e) {
|
||||
// 接続エラーのときエラー内容を取得する
|
||||
$error_message[] = $e->getMessage();
|
||||
}
|
||||
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){
|
||||
$pageNumber = 1;
|
||||
}elseif(is_sameUserid($userId, $is_login["userid"]) === 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();
|
||||
}
|
||||
|
||||
$messages = array();
|
||||
|
||||
$bookmarkQuery = $pdo->prepare("SELECT bookmark FROM account WHERE userid = :userid");
|
||||
$bookmarkQuery->bindValue(':userid', $userId);
|
||||
$bookmarkQuery->execute();
|
||||
$bookmarkData = $bookmarkQuery->fetch();
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
$allBookmarks = explode(',', $bookmarkData['bookmark'] ?? '');
|
||||
$reversedBookmarks = array_reverse($allBookmarks);
|
||||
$bookmarkList = array_chunk($reversedBookmarks, $itemsPerPage);
|
||||
|
||||
$list_Page = max(0, (int)$pageNumber - 1);
|
||||
$messages = [];
|
||||
|
||||
$blocked_accounts = sqlBlockAccountList('account', $myblocklist);
|
||||
|
||||
if (!empty($bookmarkList[$list_Page])) {
|
||||
$currentPageUniqIds = $bookmarkList[$list_Page];
|
||||
|
||||
// 名前付きプレースホルダ作成
|
||||
$placeholders = [];
|
||||
$params = [];
|
||||
foreach ($currentPageUniqIds as $i => $uniqid) {
|
||||
$key = ":uniqid$i";
|
||||
$placeholders[] = $key;
|
||||
$params[$key] = $uniqid;
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){
|
||||
$pageNumber = 1;
|
||||
}
|
||||
$placeholderStr = implode(',', $placeholders);
|
||||
|
||||
$sql = "SELECT ueuse.*
|
||||
FROM ueuse
|
||||
LEFT JOIN account ON ueuse.account = account.userid
|
||||
WHERE ueuse.uniqid IN ($placeholderStr) AND account.role != 'ice' {$blocked_accounts['sql']}
|
||||
ORDER BY FIELD(ueuse.uniqid, $placeholderStr)";
|
||||
$messages = array();
|
||||
|
||||
$bookmarkQuery = $pdo->prepare("SELECT bookmark FROM account WHERE userid = :userid");
|
||||
$bookmarkQuery->bindValue(':userid', $userId);
|
||||
$bookmarkQuery->execute();
|
||||
$bookmarkData = $bookmarkQuery->fetch();
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
foreach ($params as $key => $val) {
|
||||
$stmt->bindValue($key, $val, PDO::PARAM_STR);
|
||||
}
|
||||
foreach ($blocked_accounts['params'] as $ph => $val) {
|
||||
$stmt->bindValue($ph, $val, PDO::PARAM_STR);
|
||||
}
|
||||
$stmt->execute();
|
||||
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
$allBookmarks = explode(',', $bookmarkData['bookmark'] ?? '');
|
||||
$reversedBookmarks = array_reverse($allBookmarks);
|
||||
$bookmarkList = array_chunk($reversedBookmarks, $itemsPerPage);
|
||||
|
||||
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
//adsystem------------------
|
||||
$list_Page = max(0, (int)$pageNumber - 1);
|
||||
$messages = [];
|
||||
|
||||
$message['ads'] = "false";
|
||||
$blocked_accounts = sqlBlockAccountList('account', $myblocklist);
|
||||
|
||||
$today = date("Y-m-d H:i:s");
|
||||
if (!empty($bookmarkList[$list_Page])) {
|
||||
$currentPageUniqIds = $bookmarkList[$list_Page];
|
||||
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if(!(empty($adsresult))){
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
|
||||
$ueuseItems = array();
|
||||
if(!empty($messages)){
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
// 名前付きプレースホルダ作成
|
||||
$placeholders = [];
|
||||
$params = [];
|
||||
foreach ($currentPageUniqIds as $i => $uniqid) {
|
||||
$key = ":uniqid$i";
|
||||
$placeholders[] = $key;
|
||||
$params[$key] = $uniqid;
|
||||
}
|
||||
$placeholderStr = implode(',', $placeholders);
|
||||
|
||||
$sql = "SELECT ueuse.*
|
||||
FROM ueuse
|
||||
LEFT JOIN account ON ueuse.account = account.userid
|
||||
WHERE ueuse.uniqid IN ($placeholderStr) AND account.role != 'ice' {$blocked_accounts['sql']}
|
||||
ORDER BY FIELD(ueuse.uniqid, $placeholderStr)";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
foreach ($params as $key => $val) {
|
||||
$stmt->bindValue($key, $val, PDO::PARAM_STR);
|
||||
}
|
||||
foreach ($blocked_accounts['params'] as $ph => $val) {
|
||||
$stmt->bindValue($ph, $val, PDO::PARAM_STR);
|
||||
}
|
||||
$stmt->execute();
|
||||
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
if($message['ads'] === "true"){
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
//adsystem------------------
|
||||
|
||||
$message['ads'] = "false";
|
||||
|
||||
$today = date("Y-m-d H:i:s");
|
||||
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if(!(empty($adsresult))){
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
|
||||
$ueuseItems = array();
|
||||
if(!empty($messages)){
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
}
|
||||
}
|
||||
|
||||
if($message['ads'] === "true"){
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
);
|
||||
}else{
|
||||
$adsystem = null;
|
||||
}
|
||||
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuseItems,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
}else{
|
||||
$adsystem = null;
|
||||
}
|
||||
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuseItems,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$pdo = null;
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$pdo = null;
|
||||
}
|
||||
}else{
|
||||
echo json_encode(['success' => false, 'error' => '認証に失敗しました。(AUTH_INVALID)']);
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$item = array(
|
||||
|
||||
+103
-100
@@ -14,121 +14,124 @@ if (safetext(isset($_POST['page'])) && safetext(isset($_POST['userid'])) && safe
|
||||
if ($is_login === false) {
|
||||
echo json_encode(['success' => false, 'error' => 'bad_request']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// データベースに接続
|
||||
try {
|
||||
$option = array(
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
|
||||
);
|
||||
$pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
|
||||
} catch (PDOException $e) {
|
||||
// 接続エラーのときエラー内容を取得する
|
||||
$error_message[] = $e->getMessage();
|
||||
}
|
||||
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){
|
||||
$pageNumber = 1;
|
||||
}elseif(is_sameUserid($userId, $is_login["userid"]) === 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();
|
||||
}
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
|
||||
$followList = getFolloweeList($pdo, $userId);
|
||||
$messages = array(); // 初期化
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
// 空ならエラー回避
|
||||
if (!(empty($followList))){
|
||||
$placeholders = implode(',', array_fill(0, count($followList), '?'));
|
||||
|
||||
$sql = "SELECT ueuse.*
|
||||
FROM ueuse
|
||||
LEFT JOIN account ON ueuse.account = account.userid
|
||||
WHERE ueuse.rpuniqid = ''
|
||||
AND account.role != 'ice'
|
||||
AND ueuse.account IN ($placeholders)
|
||||
ORDER BY ueuse.datetime DESC
|
||||
LIMIT ? OFFSET ?";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
|
||||
$i = 1;
|
||||
foreach ($followList as $uid) {
|
||||
$stmt->bindValue($i++, $uid, PDO::PARAM_STR);
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){
|
||||
$pageNumber = 1;
|
||||
}
|
||||
$stmt->bindValue($i++, $itemsPerPage, PDO::PARAM_INT);
|
||||
$stmt->bindValue($i++, $offset, PDO::PARAM_INT);
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
|
||||
$stmt->execute();
|
||||
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}else{
|
||||
$messages = [];
|
||||
}
|
||||
|
||||
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
//adsystem------------------
|
||||
$followList = getFolloweeList($pdo, $userId);
|
||||
$messages = array(); // 初期化
|
||||
|
||||
$message['ads'] = "false";
|
||||
// 空ならエラー回避
|
||||
if (!(empty($followList))){
|
||||
$placeholders = implode(',', array_fill(0, count($followList), '?'));
|
||||
|
||||
$today = date("Y-m-d H:i:s");
|
||||
$sql = "SELECT ueuse.*
|
||||
FROM ueuse
|
||||
LEFT JOIN account ON ueuse.account = account.userid
|
||||
WHERE ueuse.rpuniqid = ''
|
||||
AND account.role != 'ice'
|
||||
AND ueuse.account IN ($placeholders)
|
||||
ORDER BY ueuse.datetime DESC
|
||||
LIMIT ? OFFSET ?";
|
||||
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if(!(empty($adsresult))){
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
$stmt = $pdo->prepare($sql);
|
||||
|
||||
$ueuseItems = array();
|
||||
if(!empty($messages)){
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
$i = 1;
|
||||
foreach ($followList as $uid) {
|
||||
$stmt->bindValue($i++, $uid, PDO::PARAM_STR);
|
||||
}
|
||||
}
|
||||
$stmt->bindValue($i++, $itemsPerPage, PDO::PARAM_INT);
|
||||
$stmt->bindValue($i++, $offset, PDO::PARAM_INT);
|
||||
|
||||
if($message['ads'] === "true"){
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
);
|
||||
$stmt->execute();
|
||||
$messages = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
}else{
|
||||
$adsystem = null;
|
||||
$messages = [];
|
||||
}
|
||||
|
||||
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
//adsystem------------------
|
||||
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuseItems,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
$message['ads'] = "false";
|
||||
|
||||
$today = date("Y-m-d H:i:s");
|
||||
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if(!(empty($adsresult))){
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
|
||||
$ueuseItems = array();
|
||||
if(!empty($messages)){
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
}
|
||||
}
|
||||
|
||||
if($message['ads'] === "true"){
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
);
|
||||
}else{
|
||||
$adsystem = null;
|
||||
}
|
||||
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuseItems,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
|
||||
$pdo = null;
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$pdo = null;
|
||||
}
|
||||
}else{
|
||||
echo json_encode(['success' => false, 'error' => '認証に失敗しました。(AUTH_INVALID)']);
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$item = array(
|
||||
|
||||
+227
-224
@@ -14,259 +14,262 @@ if (safetext(isset($_POST['page'])) && safetext(isset($_POST['userid'])) && safe
|
||||
if ($is_login === false) {
|
||||
echo json_encode(['success' => false, 'error' => 'bad_request']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// データベースに接続
|
||||
try {
|
||||
$option = array(
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
|
||||
);
|
||||
$pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
|
||||
} catch (PDOException $e) {
|
||||
// 接続エラーのときエラー内容を取得する
|
||||
$error_message[] = $e->getMessage();
|
||||
}
|
||||
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){
|
||||
$pageNumber = 1;
|
||||
}
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
|
||||
$messages = array();
|
||||
|
||||
$blocked_accounts = sqlBlockAccountList('account', $myblocklist);
|
||||
|
||||
//------------------------------------------すべてのユーズを取得----------------------------------------------
|
||||
$all_sql = "SELECT ueuse.*
|
||||
FROM ueuse
|
||||
LEFT JOIN account ON ueuse.account = account.userid
|
||||
WHERE ueuse.rpuniqid = '' AND account.role != 'ice' {$blocked_accounts['sql']}
|
||||
ORDER BY ueuse.datetime DESC
|
||||
LIMIT :offset, :itemsPerPage";
|
||||
|
||||
$all_stmt = $pdo->prepare($all_sql);
|
||||
foreach ($blocked_accounts['params'] as $ph => $val) {
|
||||
$all_stmt->bindValue($ph, $val, PDO::PARAM_STR);
|
||||
}
|
||||
$all_stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$all_stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT);
|
||||
$all_stmt->execute();
|
||||
|
||||
$all_messages = $all_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
if(empty($all_messages)){
|
||||
$all_messages = [];
|
||||
}elseif(is_sameUserid($userId, $is_login["userid"]) === 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();
|
||||
}
|
||||
|
||||
//------------------------------------------人気なユーズを取得(バズってるやつ)----------------------------------------------
|
||||
$day_count_sql = "SELECT ueuse.*
|
||||
FROM ueuse
|
||||
LEFT JOIN account ON ueuse.account = account.userid
|
||||
WHERE ueuse.datetime >= NOW() - INTERVAL 7 DAY AND ueuse.rpuniqid = '' AND account.role != 'ice'
|
||||
ORDER BY ueuse.datetime DESC
|
||||
LIMIT 1000";
|
||||
$cnt_stmt = $pdo->prepare($day_count_sql);
|
||||
$Before7daysPosts = $cnt_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
// 結果が15件に満たない場合
|
||||
$postCount = count($Before7daysPosts);
|
||||
if($postCount < 15){
|
||||
$get_day = 90;
|
||||
}elseif($postCount > 15 && $postCount < 150){
|
||||
$get_day = 31;
|
||||
}elseif($postCount > 150 && $postCount < 750){
|
||||
$get_day = 7;
|
||||
}elseif($postCount > 750){
|
||||
$get_day = 5;
|
||||
}else{
|
||||
$get_day = 2;
|
||||
}
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){
|
||||
$pageNumber = 1;
|
||||
}
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
|
||||
$get_day = $get_day * (2 ** floor($pageNumber / 3));
|
||||
$messages = array();
|
||||
|
||||
$pop_sql = "SELECT
|
||||
ueuse.*
|
||||
FROM
|
||||
ueuse
|
||||
LEFT JOIN account ON ueuse.account = account.userid
|
||||
WHERE
|
||||
ueuse.datetime >= NOW() - INTERVAL :getday DAY
|
||||
AND
|
||||
ueuse.rpuniqid = ''
|
||||
AND
|
||||
account.role != 'ice'
|
||||
{$blocked_accounts['sql']}
|
||||
ORDER BY
|
||||
ueuse.popularity DESC
|
||||
LIMIT :offset, :itemsPerPage;
|
||||
";
|
||||
|
||||
$pop_stmt = $pdo->prepare($pop_sql);
|
||||
foreach ($blocked_accounts['params'] as $ph => $val) {
|
||||
$pop_stmt->bindValue($ph, $val, PDO::PARAM_STR);
|
||||
}
|
||||
$pop_stmt->bindValue(':getday', $get_day, PDO::PARAM_INT);
|
||||
$pop_stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$pop_stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT);
|
||||
$pop_stmt->execute();
|
||||
|
||||
$pop_messages = $pop_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
if(empty($pop_messages)){
|
||||
$pop_messages = [];
|
||||
}
|
||||
|
||||
//------------------------------------------フォローしているユーザーから取得----------------------------------------------
|
||||
$followList = getFolloweeList($pdo, $userId);
|
||||
|
||||
foreach ($followList as $followUserId) {
|
||||
$flw_sql = "SELECT ueuse.*
|
||||
$blocked_accounts = sqlBlockAccountList('account', $myblocklist);
|
||||
|
||||
//------------------------------------------すべてのユーズを取得----------------------------------------------
|
||||
$all_sql = "SELECT ueuse.*
|
||||
FROM ueuse
|
||||
LEFT JOIN account ON ueuse.account = account.userid
|
||||
WHERE ueuse.rpuniqid = '' AND account.role != 'ice' AND ueuse.account = :follow_account AND ueuse.datetime >= NOW() - INTERVAL :getday DAY {$blocked_accounts['sql']}
|
||||
WHERE ueuse.rpuniqid = '' AND account.role != 'ice' {$blocked_accounts['sql']}
|
||||
ORDER BY ueuse.datetime DESC
|
||||
LIMIT :offset, :itemsPerPage";
|
||||
|
||||
$flw_stmt = $pdo->prepare($flw_sql);
|
||||
$all_stmt = $pdo->prepare($all_sql);
|
||||
foreach ($blocked_accounts['params'] as $ph => $val) {
|
||||
$flw_stmt->bindValue($ph, $val, PDO::PARAM_STR);
|
||||
$all_stmt->bindValue($ph, $val, PDO::PARAM_STR);
|
||||
}
|
||||
$flw_stmt->bindValue(':getday', $get_day, PDO::PARAM_INT);
|
||||
$flw_stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$flw_stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT);
|
||||
$flw_stmt->bindValue(':follow_account', $followUserId, PDO::PARAM_STR);
|
||||
$flw_stmt->execute();
|
||||
$all_stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$all_stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT);
|
||||
$all_stmt->execute();
|
||||
|
||||
while ($row = $flw_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$flw_messages[] = $row;
|
||||
$all_messages = $all_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
if(empty($all_messages)){
|
||||
$all_messages = [];
|
||||
}
|
||||
}
|
||||
if(!(empty($flw_messages))){
|
||||
usort($flw_messages, function($a, $b) {
|
||||
return strtotime($b['datetime']) - strtotime($a['datetime']);
|
||||
});
|
||||
}else{
|
||||
$flw_messages = [];
|
||||
}
|
||||
|
||||
//------------------------------------------いいねやリユーズを頻繁にするような好きっぽそうなユーザーの投稿を取得--------------------------------------
|
||||
$fav_sql = "SELECT ueuse.*,
|
||||
(LENGTH(ueuse.favorite) - LENGTH(REPLACE(ueuse.favorite, ',', '')) - 1) AS favorite_count
|
||||
FROM ueuse
|
||||
WHERE FIND_IN_SET(:userid, ueuse.favorite) > 0
|
||||
ORDER BY ueuse.datetime DESC
|
||||
LIMIT 100
|
||||
";
|
||||
$fav_stmt = $pdo->prepare($fav_sql);
|
||||
$fav_stmt->bindValue(':userid', $userId, PDO::PARAM_STR);
|
||||
$fav_stmt->execute();
|
||||
$fav_ueuse_lists = $fav_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
//------------------------------------------人気なユーズを取得(バズってるやつ)----------------------------------------------
|
||||
$day_count_sql = "SELECT ueuse.*
|
||||
FROM ueuse
|
||||
LEFT JOIN account ON ueuse.account = account.userid
|
||||
WHERE ueuse.datetime >= NOW() - INTERVAL 7 DAY AND ueuse.rpuniqid = '' AND account.role != 'ice'
|
||||
ORDER BY ueuse.datetime DESC
|
||||
LIMIT 1000";
|
||||
$cnt_stmt = $pdo->prepare($day_count_sql);
|
||||
$Before7daysPosts = $cnt_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);
|
||||
// 結果が15件に満たない場合
|
||||
$postCount = count($Before7daysPosts);
|
||||
if($postCount < 15){
|
||||
$get_day = 90;
|
||||
}elseif($postCount > 15 && $postCount < 150){
|
||||
$get_day = 31;
|
||||
}elseif($postCount > 150 && $postCount < 750){
|
||||
$get_day = 7;
|
||||
}elseif($postCount > 750){
|
||||
$get_day = 5;
|
||||
}else{
|
||||
$get_day = 2;
|
||||
}
|
||||
|
||||
$favget_messages = [];
|
||||
$favget_sql = "SELECT ueuse.*
|
||||
$get_day = $get_day * (2 ** floor($pageNumber / 3));
|
||||
|
||||
$pop_sql = "SELECT
|
||||
ueuse.*
|
||||
FROM
|
||||
ueuse
|
||||
LEFT JOIN account ON ueuse.account = account.userid
|
||||
WHERE
|
||||
ueuse.datetime >= NOW() - INTERVAL :getday DAY
|
||||
AND
|
||||
ueuse.rpuniqid = ''
|
||||
AND
|
||||
account.role != 'ice'
|
||||
{$blocked_accounts['sql']}
|
||||
ORDER BY
|
||||
ueuse.popularity DESC
|
||||
LIMIT :offset, :itemsPerPage;
|
||||
";
|
||||
|
||||
$pop_stmt = $pdo->prepare($pop_sql);
|
||||
foreach ($blocked_accounts['params'] as $ph => $val) {
|
||||
$pop_stmt->bindValue($ph, $val, PDO::PARAM_STR);
|
||||
}
|
||||
$pop_stmt->bindValue(':getday', $get_day, PDO::PARAM_INT);
|
||||
$pop_stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$pop_stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT);
|
||||
$pop_stmt->execute();
|
||||
|
||||
$pop_messages = $pop_stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
if(empty($pop_messages)){
|
||||
$pop_messages = [];
|
||||
}
|
||||
|
||||
//------------------------------------------フォローしているユーザーから取得----------------------------------------------
|
||||
$followList = getFolloweeList($pdo, $userId);
|
||||
|
||||
foreach ($followList as $followUserId) {
|
||||
$flw_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 {$blocked_accounts['sql']}
|
||||
WHERE ueuse.rpuniqid = '' AND account.role != 'ice' AND ueuse.account = :follow_account AND ueuse.datetime >= NOW() - INTERVAL :getday DAY {$blocked_accounts['sql']}
|
||||
ORDER BY ueuse.datetime DESC
|
||||
LIMIT :offset, :itemsPerPage";
|
||||
|
||||
$favget_stmt = $pdo->prepare($favget_sql);
|
||||
foreach ($blocked_accounts['params'] as $ph => $val) {
|
||||
$favget_stmt->bindValue($ph, $val, PDO::PARAM_STR);
|
||||
}
|
||||
$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);
|
||||
$flw_stmt = $pdo->prepare($flw_sql);
|
||||
foreach ($blocked_accounts['params'] as $ph => $val) {
|
||||
$flw_stmt->bindValue($ph, $val, PDO::PARAM_STR);
|
||||
}
|
||||
$flw_stmt->bindValue(':getday', $get_day, PDO::PARAM_INT);
|
||||
$flw_stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$flw_stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT);
|
||||
$flw_stmt->bindValue(':follow_account', $followUserId, PDO::PARAM_STR);
|
||||
$flw_stmt->execute();
|
||||
|
||||
foreach ($top_fav_accounts as $favUserId => $count) {
|
||||
$favget_stmt->bindValue(':fav_account', $favUserId, PDO::PARAM_STR);
|
||||
$favget_stmt->execute();
|
||||
$favget_messages = array_merge($favget_messages, $favget_stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
}
|
||||
} else {
|
||||
$favget_messages = [];
|
||||
}
|
||||
|
||||
// 基本的には人気・フォロー中・いいねする事が多いユーザーのユーズでTLを構成するけど全部出きったらLTLと同じにする
|
||||
$messages = array_merge($pop_messages, $flw_messages, $favget_messages);
|
||||
if (empty($messages)) {
|
||||
$messages = $all_messages;
|
||||
} 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に置き換える
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
//adsystem------------------
|
||||
|
||||
$message['ads'] = "false";
|
||||
|
||||
$today = date("Y-m-d H:i:s");
|
||||
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if(!(empty($adsresult))){
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
|
||||
$ueuseItems = array();
|
||||
if(!empty($messages)){
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
while ($row = $flw_stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$flw_messages[] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
if($message['ads'] === "true"){
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
);
|
||||
if(!(empty($flw_messages))){
|
||||
usort($flw_messages, function($a, $b) {
|
||||
return strtotime($b['datetime']) - strtotime($a['datetime']);
|
||||
});
|
||||
}else{
|
||||
$adsystem = null;
|
||||
$flw_messages = [];
|
||||
}
|
||||
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuseItems,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
//------------------------------------------いいねやリユーズを頻繁にするような好きっぽそうなユーザーの投稿を取得--------------------------------------
|
||||
$fav_sql = "SELECT ueuse.*,
|
||||
(LENGTH(ueuse.favorite) - LENGTH(REPLACE(ueuse.favorite, ',', '')) - 1) AS favorite_count
|
||||
FROM ueuse
|
||||
WHERE FIND_IN_SET(:userid, ueuse.favorite) > 0
|
||||
ORDER BY ueuse.datetime DESC
|
||||
LIMIT 100
|
||||
";
|
||||
$fav_stmt = $pdo->prepare($fav_sql);
|
||||
$fav_stmt->bindValue(':userid', $userId, PDO::PARAM_STR);
|
||||
$fav_stmt->execute();
|
||||
$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);
|
||||
|
||||
$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 {$blocked_accounts['sql']}
|
||||
ORDER BY ueuse.datetime DESC
|
||||
LIMIT :offset, :itemsPerPage";
|
||||
|
||||
$favget_stmt = $pdo->prepare($favget_sql);
|
||||
foreach ($blocked_accounts['params'] as $ph => $val) {
|
||||
$favget_stmt->bindValue($ph, $val, PDO::PARAM_STR);
|
||||
}
|
||||
$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();
|
||||
$favget_messages = array_merge($favget_messages, $favget_stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
}
|
||||
} else {
|
||||
$favget_messages = [];
|
||||
}
|
||||
|
||||
// 基本的には人気・フォロー中・いいねする事が多いユーザーのユーズでTLを構成するけど全部出きったらLTLと同じにする
|
||||
$messages = array_merge($pop_messages, $flw_messages, $favget_messages);
|
||||
if (empty($messages)) {
|
||||
$messages = $all_messages;
|
||||
} 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に置き換える
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
//adsystem------------------
|
||||
|
||||
$message['ads'] = "false";
|
||||
|
||||
$today = date("Y-m-d H:i:s");
|
||||
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if(!(empty($adsresult))){
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
|
||||
$ueuseItems = array();
|
||||
if(!empty($messages)){
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
}
|
||||
}
|
||||
|
||||
if($message['ads'] === "true"){
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
);
|
||||
}else{
|
||||
$adsystem = null;
|
||||
}
|
||||
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuseItems,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
|
||||
$pdo = null;
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$pdo = null;
|
||||
}
|
||||
}else{
|
||||
echo json_encode(['success' => false, 'error' => '認証に失敗しました。(AUTH_INVALID)']);
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$item = array(
|
||||
|
||||
+101
-98
@@ -14,118 +14,121 @@ if (safetext(isset($_POST['page'])) && safetext(isset($_POST['userid'])) && safe
|
||||
if ($is_login === false) {
|
||||
echo json_encode(['success' => false, 'error' => 'bad_request']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// データベースに接続
|
||||
try {
|
||||
$option = array(
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
|
||||
);
|
||||
$pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
|
||||
} catch (PDOException $e) {
|
||||
// 接続エラーのときエラー内容を取得する
|
||||
$error_message[] = $e->getMessage();
|
||||
}
|
||||
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){
|
||||
$pageNumber = 1;
|
||||
}
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
|
||||
$blocked_accounts = sqlBlockAccountList('account', $myblocklist);
|
||||
|
||||
$messages = array();
|
||||
|
||||
$sql = "SELECT ueuse.*
|
||||
FROM ueuse
|
||||
LEFT JOIN account ON ueuse.account = account.userid
|
||||
WHERE ueuse.rpuniqid = '' AND account.role != 'ice' {$blocked_accounts['sql']}
|
||||
ORDER BY ueuse.datetime DESC
|
||||
LIMIT :offset, :itemsPerPage";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
|
||||
foreach ($blocked_accounts['params'] as $ph => $val) {
|
||||
$stmt->bindValue($ph, $val, PDO::PARAM_STR);
|
||||
}elseif(is_sameUserid($userId, $is_login["userid"]) === 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();
|
||||
}
|
||||
|
||||
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$message_array = $stmt;
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
while ($row = $message_array->fetch(PDO::FETCH_ASSOC)) {
|
||||
$messages[] = $row;
|
||||
}
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){
|
||||
$pageNumber = 1;
|
||||
}
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
|
||||
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
|
||||
$blocked_accounts = sqlBlockAccountList('account', $myblocklist);
|
||||
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
$messages = array();
|
||||
|
||||
$sql = "SELECT ueuse.*
|
||||
FROM ueuse
|
||||
LEFT JOIN account ON ueuse.account = account.userid
|
||||
WHERE ueuse.rpuniqid = '' AND account.role != 'ice' {$blocked_accounts['sql']}
|
||||
ORDER BY ueuse.datetime DESC
|
||||
LIMIT :offset, :itemsPerPage";
|
||||
|
||||
//adsystem------------------
|
||||
$stmt = $pdo->prepare($sql);
|
||||
|
||||
foreach ($blocked_accounts['params'] as $ph => $val) {
|
||||
$stmt->bindValue($ph, $val, PDO::PARAM_STR);
|
||||
}
|
||||
|
||||
$message['ads'] = "false";
|
||||
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$message_array = $stmt;
|
||||
|
||||
$today = date("Y-m-d H:i:s");
|
||||
while ($row = $message_array->fetch(PDO::FETCH_ASSOC)) {
|
||||
$messages[] = $row;
|
||||
}
|
||||
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if(!(empty($adsresult))){
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
|
||||
|
||||
$ueuseItems = array();
|
||||
if(!empty($messages)){
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
|
||||
//adsystem------------------
|
||||
|
||||
$message['ads'] = "false";
|
||||
|
||||
$today = date("Y-m-d H:i:s");
|
||||
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if(!(empty($adsresult))){
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
|
||||
$ueuseItems = array();
|
||||
if(!empty($messages)){
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($message['ads'] === "true"){
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
if($message['ads'] === "true"){
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
);
|
||||
}else{
|
||||
$adsystem = null;
|
||||
}
|
||||
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuseItems,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
}else{
|
||||
$adsystem = null;
|
||||
}
|
||||
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuseItems,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$pdo = null;
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$pdo = null;
|
||||
}
|
||||
}else{
|
||||
echo json_encode(['success' => false, 'error' => '認証に失敗しました。(AUTH_INVALID)']);
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$item = array(
|
||||
|
||||
+88
-85
@@ -29,115 +29,118 @@ if (safetext(isset($_POST['page'])) && safetext(isset($_POST['userid'])) && safe
|
||||
if ($is_login === false) {
|
||||
echo json_encode(['success' => false, 'error' => 'bad_request']);
|
||||
exit;
|
||||
}
|
||||
}elseif(is_sameUserid($userid, $is_login["userid"]) === true){
|
||||
$myblocklist = getUserData($pdo, $userid)["blocklist"];
|
||||
|
||||
$myblocklist = getUserData($pdo, $userid)["blocklist"];
|
||||
$itemsPerPage = 15; // 1ページあたりの投稿数
|
||||
$pageNumber = safetext(isset($_POST['page'])) ? safetext(intval($_POST['page'])) : 1;
|
||||
if ($pageNumber <= 0 || (!(is_numeric($pageNumber)))) {
|
||||
$pageNumber = 1;
|
||||
}
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
|
||||
$itemsPerPage = 15; // 1ページあたりの投稿数
|
||||
$pageNumber = safetext(isset($_POST['page'])) ? safetext(intval($_POST['page'])) : 1;
|
||||
if ($pageNumber <= 0 || (!(is_numeric($pageNumber)))) {
|
||||
$pageNumber = 1;
|
||||
}
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
$messages = array();
|
||||
|
||||
$messages = array();
|
||||
if (!empty($pdo)) {
|
||||
$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);
|
||||
$messageQuery->execute();
|
||||
$message_array = $messageQuery->fetchAll();
|
||||
|
||||
if (!empty($pdo)) {
|
||||
$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);
|
||||
$messageQuery->execute();
|
||||
$message_array = $messageQuery->fetchAll();
|
||||
// トランザクション開始
|
||||
$pdo->beginTransaction();
|
||||
|
||||
// トランザクション開始
|
||||
$pdo->beginTransaction();
|
||||
// SQL作成
|
||||
$stmt = $pdo->prepare("UPDATE notification SET userchk = 'done' WHERE touserid = :userid;");
|
||||
|
||||
// SQL作成
|
||||
$stmt = $pdo->prepare("UPDATE notification SET userchk = 'done' WHERE touserid = :userid;");
|
||||
$stmt->bindValue(':userid', $userid, PDO::PARAM_STR);
|
||||
|
||||
$stmt->bindValue(':userid', $userid, PDO::PARAM_STR);
|
||||
$res = $stmt->execute();
|
||||
$res = $pdo->commit();
|
||||
|
||||
$res = $stmt->execute();
|
||||
$res = $pdo->commit();
|
||||
|
||||
if (!empty($message_array)) {
|
||||
foreach ($message_array as $value) {
|
||||
$value["servericon"] = safetext($serversettings["serverinfo"]["server_icon"]);
|
||||
if (!(empty($value['fromuserid']))) {
|
||||
if (!($value['fromuserid'] == "uwuzu-fromsys")) {
|
||||
$userQuery = $pdo->prepare("SELECT username,iconname FROM account WHERE userid = :userid");
|
||||
$userQuery->bindValue(':userid', $value['fromuserid']);
|
||||
$userQuery->execute();
|
||||
$user_array = $userQuery->fetch();
|
||||
if (!(empty($user_array))) {
|
||||
$value['fromusericon'] = filter_var($user_array["iconname"], FILTER_VALIDATE_URL) ? $user_array["iconname"] : "../" . $user_array["iconname"];
|
||||
$value['fromusername'] = $user_array["username"];
|
||||
} else {
|
||||
$value['fromusericon'] = "../img/deficon/icon.png";
|
||||
$value['fromusername'] = "でふぉると";
|
||||
}
|
||||
}else{
|
||||
if(!empty($value["servericon"])){
|
||||
$value['fromusericon'] = safetext($value["servericon"]);
|
||||
$value['fromusername'] = "uwuzu";
|
||||
if (!empty($message_array)) {
|
||||
foreach ($message_array as $value) {
|
||||
$value["servericon"] = safetext($serversettings["serverinfo"]["server_icon"]);
|
||||
if (!(empty($value['fromuserid']))) {
|
||||
if (!($value['fromuserid'] == "uwuzu-fromsys")) {
|
||||
$userQuery = $pdo->prepare("SELECT username,iconname FROM account WHERE userid = :userid");
|
||||
$userQuery->bindValue(':userid', $value['fromuserid']);
|
||||
$userQuery->execute();
|
||||
$user_array = $userQuery->fetch();
|
||||
if (!(empty($user_array))) {
|
||||
$value['fromusericon'] = filter_var($user_array["iconname"], FILTER_VALIDATE_URL) ? $user_array["iconname"] : "../" . $user_array["iconname"];
|
||||
$value['fromusername'] = $user_array["username"];
|
||||
} else {
|
||||
$value['fromusericon'] = "../img/deficon/icon.png";
|
||||
$value['fromusername'] = "でふぉると";
|
||||
}
|
||||
}else{
|
||||
$value['fromusericon'] = "../img/uwuzuicon.png";
|
||||
$value['fromusername'] = "uwuzu";
|
||||
if(!empty($value["servericon"])){
|
||||
$value['fromusericon'] = safetext($value["servericon"]);
|
||||
$value['fromusername'] = "uwuzu";
|
||||
}else{
|
||||
$value['fromusericon'] = "../img/uwuzuicon.png";
|
||||
$value['fromusername'] = "uwuzu";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($value["userchk"] === "done"){
|
||||
$value["userchk"] = true;
|
||||
}else{
|
||||
$value["userchk"] = false;
|
||||
}
|
||||
|
||||
$formatted = [
|
||||
"type" => "notification",
|
||||
"datetime" => $value["datetime"],
|
||||
"userid" => $value["fromuserid"],
|
||||
"userdata" => [
|
||||
"userid" => $value["fromuserid"],
|
||||
"username" => $value["fromusername"],
|
||||
"iconurl" => $value['fromusericon'],
|
||||
],
|
||||
"message" => $value["msg"],
|
||||
"url" => $value["url"],
|
||||
"title" => $value["title"],
|
||||
"is_read" => $value["userchk"],
|
||||
];
|
||||
|
||||
if ($formatted !== null) {
|
||||
$notificationItems[] = $formatted;
|
||||
}
|
||||
}
|
||||
|
||||
if($value["userchk"] === "done"){
|
||||
$value["userchk"] = true;
|
||||
}else{
|
||||
$value["userchk"] = false;
|
||||
}
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"notifications" => $notificationItems
|
||||
);
|
||||
|
||||
$formatted = [
|
||||
"type" => "notification",
|
||||
"datetime" => $value["datetime"],
|
||||
"userid" => $value["fromuserid"],
|
||||
"userdata" => [
|
||||
"userid" => $value["fromuserid"],
|
||||
"username" => $value["fromusername"],
|
||||
"iconurl" => $value['fromusericon'],
|
||||
],
|
||||
"message" => $value["msg"],
|
||||
"url" => $value["url"],
|
||||
"title" => $value["title"],
|
||||
"is_read" => $value["userchk"],
|
||||
];
|
||||
|
||||
if ($formatted !== null) {
|
||||
$notificationItems[] = $formatted;
|
||||
}
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"notifications" => null,
|
||||
"error" => "no_notification",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"notifications" => $notificationItems
|
||||
);
|
||||
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
$pdo = null;
|
||||
} else {
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"notifications" => null,
|
||||
"error" => "no_notification",
|
||||
"error" => "bad_request",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
|
||||
$pdo = null;
|
||||
} else {
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"notifications" => null,
|
||||
"error" => "bad_request",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
echo json_encode(['success' => false, 'error' => '認証に失敗しました。(AUTH_INVALID)']);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$item = array(
|
||||
|
||||
+152
-149
@@ -15,156 +15,174 @@ if (safetext(isset($_POST['page'])) && safetext(isset($_POST['userid'])) && safe
|
||||
if ($is_login === false) {
|
||||
echo json_encode(['success' => false, 'error' => 'bad_request']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// データベースに接続
|
||||
try {
|
||||
$option = array(
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
|
||||
);
|
||||
$pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
|
||||
} catch (PDOException $e) {
|
||||
// 接続エラーのときエラー内容を取得する
|
||||
$error_message[] = $e->getMessage();
|
||||
}
|
||||
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){
|
||||
$pageNumber = 1;
|
||||
}elseif(is_sameUserid($userId, $is_login["userid"]) === 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();
|
||||
}
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
|
||||
$messages = array();
|
||||
|
||||
if (!empty($keyword)) {
|
||||
$aduserinfoQuery = $pdo->prepare("SELECT username,userid,loginid,admin,role,sacinfo,blocklist,bookmark FROM account WHERE userid = :userid");
|
||||
$aduserinfoQuery->bindValue(':userid', safetext($userId));
|
||||
$aduserinfoQuery->execute();
|
||||
$res = $aduserinfoQuery->fetch();
|
||||
$myblocklist = safetext($res["blocklist"]);
|
||||
$mybookmark = safetext($res["bookmark"]);
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
$keywordPattern = '/from:@(\w+)\s+(.+)/';
|
||||
if (preg_match($keywordPattern, $keyword, $matches)) {
|
||||
$username = $matches[1];
|
||||
$searchKeyword = $matches[2];
|
||||
|
||||
$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);
|
||||
$messageQuery->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT);
|
||||
$messageQuery->execute();
|
||||
$message_array = $messageQuery->fetchAll();
|
||||
} else {
|
||||
$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);
|
||||
$messageQuery->execute();
|
||||
$message_array = $messageQuery->fetchAll();
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){
|
||||
$pageNumber = 1;
|
||||
}
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
|
||||
$user_keyword = str_replace('@', '', $keyword);
|
||||
$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);
|
||||
$usersQuery->execute();
|
||||
$users_array = $usersQuery->fetchAll();
|
||||
|
||||
$users = array();
|
||||
foreach ($users_array as $row) {
|
||||
$users[] = $row;
|
||||
}
|
||||
|
||||
$messages = array();
|
||||
foreach ($message_array as $row) {
|
||||
$messages[] = $row;
|
||||
}
|
||||
|
||||
if (!empty($keyword)) {
|
||||
$aduserinfoQuery = $pdo->prepare("SELECT username,userid,loginid,admin,role,sacinfo,blocklist,bookmark FROM account WHERE userid = :userid");
|
||||
$aduserinfoQuery->bindValue(':userid', safetext($userId));
|
||||
$aduserinfoQuery->execute();
|
||||
$res = $aduserinfoQuery->fetch();
|
||||
$myblocklist = safetext($res["blocklist"]);
|
||||
$mybookmark = safetext($res["bookmark"]);
|
||||
|
||||
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
//adsystem------------------
|
||||
$keywordPattern = '/from:@(\w+)\s+(.+)/';
|
||||
if (preg_match($keywordPattern, $keyword, $matches)) {
|
||||
$username = $matches[1];
|
||||
$searchKeyword = $matches[2];
|
||||
|
||||
$message['ads'] = "false";
|
||||
|
||||
$today = date("Y-m-d H:i:s");
|
||||
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if(!(empty($adsresult))){
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
$ueuseItems = array();
|
||||
if(!empty($messages)){
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
}
|
||||
$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);
|
||||
$messageQuery->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT);
|
||||
$messageQuery->execute();
|
||||
$message_array = $messageQuery->fetchAll();
|
||||
} else {
|
||||
$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);
|
||||
$messageQuery->execute();
|
||||
$message_array = $messageQuery->fetchAll();
|
||||
}
|
||||
|
||||
if($message['ads'] === "true"){
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
);
|
||||
$user_keyword = str_replace('@', '', $keyword);
|
||||
$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);
|
||||
$usersQuery->execute();
|
||||
$users_array = $usersQuery->fetchAll();
|
||||
|
||||
$users = array();
|
||||
foreach ($users_array as $row) {
|
||||
$users[] = $row;
|
||||
}
|
||||
|
||||
$messages = array();
|
||||
foreach ($message_array as $row) {
|
||||
$messages[] = $row;
|
||||
}
|
||||
|
||||
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
//adsystem------------------
|
||||
|
||||
$message['ads'] = "false";
|
||||
|
||||
$today = date("Y-m-d H:i:s");
|
||||
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if(!(empty($adsresult))){
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
$ueuseItems = array();
|
||||
if(!empty($messages)){
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
}
|
||||
}
|
||||
|
||||
if($message['ads'] === "true"){
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
);
|
||||
}else{
|
||||
$adsystem = null;
|
||||
}
|
||||
}else{
|
||||
$adsystem = null;
|
||||
}
|
||||
}else{
|
||||
$adsystem = null;
|
||||
}
|
||||
|
||||
$userItems = array();
|
||||
if(!empty($users)){
|
||||
foreach ($users as $value) {
|
||||
$followerCount = count(getFollowerList($pdo, $value["userid"]));
|
||||
$followCount = count(getFolloweeList($pdo, $value["userid"]));
|
||||
$userItems = array();
|
||||
if(!empty($users)){
|
||||
foreach ($users as $value) {
|
||||
$followerCount = count(getFollowerList($pdo, $value["userid"]));
|
||||
$followCount = count(getFolloweeList($pdo, $value["userid"]));
|
||||
|
||||
$user = array(
|
||||
"type" => "User",
|
||||
"userid" => $value["userid"],
|
||||
"userdata" => array(
|
||||
$user = array(
|
||||
"type" => "User",
|
||||
"userid" => $value["userid"],
|
||||
"username" => $value["username"],
|
||||
"headurl" => filter_var($value['headname'], FILTER_VALIDATE_URL)
|
||||
? $value['headname']
|
||||
: "../" . $value['headname'],
|
||||
"iconurl" => filter_var($value['iconname'], FILTER_VALIDATE_URL)
|
||||
? $value['iconname']
|
||||
: "../" . $value['iconname'],
|
||||
"role" => $value["role"],
|
||||
"sacinfo" => $value["sacinfo"],
|
||||
"follower_cnt" => $followerCount,
|
||||
"follow_cnt" => $followCount,
|
||||
"datetime" => $value["datetime"],
|
||||
"profile" => $value["profile"],
|
||||
),
|
||||
);
|
||||
"userdata" => array(
|
||||
"userid" => $value["userid"],
|
||||
"username" => $value["username"],
|
||||
"headurl" => filter_var($value['headname'], FILTER_VALIDATE_URL)
|
||||
? $value['headname']
|
||||
: "../" . $value['headname'],
|
||||
"iconurl" => filter_var($value['iconname'], FILTER_VALIDATE_URL)
|
||||
? $value['iconname']
|
||||
: "../" . $value['iconname'],
|
||||
"role" => $value["role"],
|
||||
"sacinfo" => $value["sacinfo"],
|
||||
"follower_cnt" => $followerCount,
|
||||
"follow_cnt" => $followCount,
|
||||
"datetime" => $value["datetime"],
|
||||
"profile" => $value["profile"],
|
||||
),
|
||||
);
|
||||
|
||||
$userItems[] = $user;
|
||||
$userItems[] = $user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$ueuses = array_merge($userItems, $ueuseItems);
|
||||
if (empty($ueuses)) {
|
||||
$ueuses = array_merge($userItems, $ueuseItems);
|
||||
if (empty($ueuses)) {
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuses,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$pdo = null;
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
@@ -172,26 +190,11 @@ if (safetext(isset($_POST['page'])) && safetext(isset($_POST['userid'])) && safe
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuses,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$pdo = null;
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}else{
|
||||
echo json_encode(['success' => false, 'error' => '認証に失敗しました。(AUTH_INVALID)']);
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$item = array(
|
||||
|
||||
+113
-110
@@ -15,134 +15,137 @@ if (safetext(isset($_POST['page'])) && safetext(isset($_POST['userid'])) && safe
|
||||
if ($is_login === false) {
|
||||
echo json_encode(['success' => false, 'error' => 'bad_request']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if(empty($uniqid)){
|
||||
echo json_encode(['success' => false, 'error' => 'no_ueuse']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// データベースに接続
|
||||
try {
|
||||
$option = array(
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
|
||||
);
|
||||
$pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
|
||||
} catch (PDOException $e) {
|
||||
// 接続エラーのときエラー内容を取得する
|
||||
$error_message[] = $e->getMessage();
|
||||
}
|
||||
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){
|
||||
$pageNumber = 1;
|
||||
}elseif(is_sameUserid($userId, $is_login["userid"]) === true){
|
||||
if(empty($uniqid)){
|
||||
echo json_encode(['success' => false, 'error' => 'no_ueuse']);
|
||||
exit;
|
||||
}
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
|
||||
$messages = array();
|
||||
$blocked_accounts = sqlBlockAccountList('account', $myblocklist);
|
||||
|
||||
$messageQuery = $pdo->prepare("SELECT * FROM ueuse WHERE (uniqid = :ueuseid OR rpuniqid = :rpueuseid) {$blocked_accounts['sql']} ORDER BY datetime ASC LIMIT :offset, :itemsPerPage");
|
||||
foreach ($blocked_accounts['params'] as $ph => $val) {
|
||||
$messageQuery->bindValue($ph, $val, PDO::PARAM_STR);
|
||||
// データベースに接続
|
||||
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();
|
||||
}
|
||||
$messageQuery->bindValue(':ueuseid', $uniqid, PDO::PARAM_STR);
|
||||
$messageQuery->bindValue(':rpueuseid', $uniqid, PDO::PARAM_STR);
|
||||
$messageQuery->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$messageQuery->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT);
|
||||
$messageQuery->execute();
|
||||
$message_array = $messageQuery->fetchAll();
|
||||
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){
|
||||
$pageNumber = 1;
|
||||
}
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
|
||||
$messages = array();
|
||||
$blocked_accounts = sqlBlockAccountList('account', $myblocklist);
|
||||
|
||||
$messages = array();
|
||||
$messageQuery = $pdo->prepare("SELECT * FROM ueuse WHERE (uniqid = :ueuseid OR rpuniqid = :rpueuseid) {$blocked_accounts['sql']} ORDER BY datetime ASC LIMIT :offset, :itemsPerPage");
|
||||
foreach ($blocked_accounts['params'] as $ph => $val) {
|
||||
$messageQuery->bindValue($ph, $val, PDO::PARAM_STR);
|
||||
}
|
||||
$messageQuery->bindValue(':ueuseid', $uniqid, PDO::PARAM_STR);
|
||||
$messageQuery->bindValue(':rpueuseid', $uniqid, PDO::PARAM_STR);
|
||||
$messageQuery->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$messageQuery->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT);
|
||||
$messageQuery->execute();
|
||||
$message_array = $messageQuery->fetchAll();
|
||||
|
||||
$messages = array();
|
||||
|
||||
foreach ($message_array as $row) {
|
||||
if(!(empty($row["rpuniqid"]))){
|
||||
if(!($row["rpuniqid"] == $uniqid)){
|
||||
$up_messageQuery = $pdo->prepare("SELECT * FROM ueuse WHERE uniqid = :ueuseid {$blocked_accounts['sql']} ORDER BY datetime ASC LIMIT :offset, :itemsPerPage");
|
||||
foreach ($blocked_accounts['params'] as $ph => $val) {
|
||||
$up_messageQuery->bindValue($ph, $val, PDO::PARAM_STR);
|
||||
}
|
||||
$up_messageQuery->bindValue(':ueuseid', $row["rpuniqid"]);
|
||||
$up_messageQuery->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$up_messageQuery->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT);
|
||||
$up_messageQuery->execute();
|
||||
$up_messageData = $up_messageQuery->fetchAll();
|
||||
if(!(empty($up_messageData))){
|
||||
foreach ($up_messageData as $up_row) {
|
||||
$up_row["up_uniqid"] = $up_row["uniqid"];
|
||||
$messages[] = $up_row;
|
||||
foreach ($message_array as $row) {
|
||||
if(!(empty($row["rpuniqid"]))){
|
||||
if(!($row["rpuniqid"] == $uniqid)){
|
||||
$up_messageQuery = $pdo->prepare("SELECT * FROM ueuse WHERE uniqid = :ueuseid {$blocked_accounts['sql']} ORDER BY datetime ASC LIMIT :offset, :itemsPerPage");
|
||||
foreach ($blocked_accounts['params'] as $ph => $val) {
|
||||
$up_messageQuery->bindValue($ph, $val, PDO::PARAM_STR);
|
||||
}
|
||||
$up_messageQuery->bindValue(':ueuseid', $row["rpuniqid"]);
|
||||
$up_messageQuery->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$up_messageQuery->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT);
|
||||
$up_messageQuery->execute();
|
||||
$up_messageData = $up_messageQuery->fetchAll();
|
||||
if(!(empty($up_messageData))){
|
||||
foreach ($up_messageData as $up_row) {
|
||||
$up_row["up_uniqid"] = $up_row["uniqid"];
|
||||
$messages[] = $up_row;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$messages[] = $row;
|
||||
}
|
||||
$messages[] = $row;
|
||||
}
|
||||
|
||||
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
//adsystem------------------
|
||||
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
//adsystem------------------
|
||||
|
||||
$message['ads'] = "false";
|
||||
$message['ads'] = "false";
|
||||
|
||||
$today = date("Y-m-d H:i:s");
|
||||
$today = date("Y-m-d H:i:s");
|
||||
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if(!(empty($adsresult))){
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if(!(empty($adsresult))){
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
|
||||
$ueuseItems = array();
|
||||
if(!empty($messages)){
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
$ueuseItems = array();
|
||||
if(!empty($messages)){
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($message['ads'] === "true"){
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
if($message['ads'] === "true"){
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
);
|
||||
}else{
|
||||
$adsystem = null;
|
||||
}
|
||||
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuseItems,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
}else{
|
||||
$adsystem = null;
|
||||
}
|
||||
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuseItems,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$pdo = null;
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$pdo = null;
|
||||
}
|
||||
}else{
|
||||
echo json_encode(['success' => false, 'error' => '認証に失敗しました。(AUTH_INVALID)']);
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$item = array(
|
||||
|
||||
+106
-103
@@ -48,119 +48,122 @@ if (safetext(isset($_POST['page'])) && safetext(isset($_POST['userid'])) && safe
|
||||
if ($is_login === false) {
|
||||
echo json_encode(['success' => false, 'error' => 'bad_request']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// データベースに接続
|
||||
try {
|
||||
$option = array(
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
|
||||
);
|
||||
$pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
|
||||
} catch (PDOException $e) {
|
||||
// 接続エラーのときエラー内容を取得する
|
||||
$error_message[] = $e->getMessage();
|
||||
}
|
||||
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){
|
||||
$pageNumber = 1;
|
||||
}
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
|
||||
$messages = array();
|
||||
|
||||
$userQuery = $pdo->prepare("SELECT username, userid, profile, role, follower FROM account WHERE userid = :userid");
|
||||
$userQuery->bindValue(':userid', $uwuzuid);
|
||||
$userQuery->execute();
|
||||
$userData = $userQuery->fetch();
|
||||
$message_array = [];
|
||||
|
||||
$sql = "SELECT ueuse.*
|
||||
FROM ueuse
|
||||
LEFT JOIN account ON ueuse.account = account.userid
|
||||
WHERE FIND_IN_SET(:userid, REPLACE(ueuse.favorite, ' ', '')) > 0
|
||||
AND account.role != 'ice'
|
||||
ORDER BY ueuse.datetime DESC
|
||||
LIMIT :offset, :itemsPerPage";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->bindValue(':userid', $uwuzuid, PDO::PARAM_STR);
|
||||
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$results = $stmt->fetchAll();
|
||||
|
||||
// 結果を追加
|
||||
$message_array = array_merge($message_array, $results);
|
||||
foreach ($message_array as $row) {
|
||||
$messages[] = $row;
|
||||
}elseif(is_sameUserid($userId, $is_login["userid"]) === 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();
|
||||
}
|
||||
|
||||
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
//adsystem------------------
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
$message['ads'] = "false";
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){
|
||||
$pageNumber = 1;
|
||||
}
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
|
||||
$today = date("Y-m-d H:i:s");
|
||||
$messages = array();
|
||||
|
||||
$userQuery = $pdo->prepare("SELECT username, userid, profile, role, follower FROM account WHERE userid = :userid");
|
||||
$userQuery->bindValue(':userid', $uwuzuid);
|
||||
$userQuery->execute();
|
||||
$userData = $userQuery->fetch();
|
||||
$message_array = [];
|
||||
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if(!(empty($adsresult))){
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
$sql = "SELECT ueuse.*
|
||||
FROM ueuse
|
||||
LEFT JOIN account ON ueuse.account = account.userid
|
||||
WHERE FIND_IN_SET(:userid, REPLACE(ueuse.favorite, ' ', '')) > 0
|
||||
AND account.role != 'ice'
|
||||
ORDER BY ueuse.datetime DESC
|
||||
LIMIT :offset, :itemsPerPage";
|
||||
|
||||
$ueuseItems = array();
|
||||
if(!empty($messages)){
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->bindValue(':userid', $uwuzuid, PDO::PARAM_STR);
|
||||
$stmt->bindValue(':offset', $offset, PDO::PARAM_INT);
|
||||
$stmt->bindValue(':itemsPerPage', $itemsPerPage, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
$results = $stmt->fetchAll();
|
||||
|
||||
// 結果を追加
|
||||
$message_array = array_merge($message_array, $results);
|
||||
foreach ($message_array as $row) {
|
||||
$messages[] = $row;
|
||||
}
|
||||
|
||||
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
//adsystem------------------
|
||||
|
||||
$message['ads'] = "false";
|
||||
|
||||
$today = date("Y-m-d H:i:s");
|
||||
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if(!(empty($adsresult))){
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
|
||||
$ueuseItems = array();
|
||||
if(!empty($messages)){
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($message['ads'] === "true"){
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
if($message['ads'] === "true"){
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
);
|
||||
}else{
|
||||
$adsystem = null;
|
||||
}
|
||||
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuseItems,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
}else{
|
||||
$adsystem = null;
|
||||
}
|
||||
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuseItems,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$pdo = null;
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$pdo = null;
|
||||
}
|
||||
}else{
|
||||
echo json_encode(['success' => false, 'error' => '認証に失敗しました。(AUTH_INVALID)']);
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$item = array(
|
||||
|
||||
+103
-100
@@ -48,116 +48,119 @@ if (safetext(isset($_POST['page'])) && safetext(isset($_POST['userid'])) && safe
|
||||
if ($is_login === false) {
|
||||
echo json_encode(['success' => false, 'error' => 'bad_request']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// データベースに接続
|
||||
try {
|
||||
$option = array(
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
|
||||
);
|
||||
$pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
|
||||
} catch (PDOException $e) {
|
||||
// 接続エラーのときエラー内容を取得する
|
||||
$error_message[] = $e->getMessage();
|
||||
}
|
||||
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){
|
||||
$pageNumber = 1;
|
||||
}
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
|
||||
$messages = array();
|
||||
|
||||
$userQuery = $pdo->prepare("SELECT username, userid, profile, role, follower FROM account WHERE userid = :userid");
|
||||
$userQuery->bindValue(':userid', $uwuzuid);
|
||||
$userQuery->execute();
|
||||
$userData = $userQuery->fetch();
|
||||
|
||||
$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
|
||||
(photo4 IS NOT NULL AND photo4 != '' AND photo4 != 'none') OR
|
||||
(video1 IS NOT NULL AND video1 != '' AND video1 != 'none')
|
||||
) 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);
|
||||
$messageQuery->execute();
|
||||
$message_array = $messageQuery->fetchAll();
|
||||
|
||||
$messages = array();
|
||||
foreach ($message_array as $row) {
|
||||
$messages[] = $row;
|
||||
}elseif(is_sameUserid($userId, $is_login["userid"]) === 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();
|
||||
}
|
||||
|
||||
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
//adsystem------------------
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
$message['ads'] = "false";
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if($pageNumber <= 0 || (!(is_numeric($pageNumber)))){
|
||||
$pageNumber = 1;
|
||||
}
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
|
||||
$today = date("Y-m-d H:i:s");
|
||||
$messages = array();
|
||||
|
||||
$userQuery = $pdo->prepare("SELECT username, userid, profile, role, follower FROM account WHERE userid = :userid");
|
||||
$userQuery->bindValue(':userid', $uwuzuid);
|
||||
$userQuery->execute();
|
||||
$userData = $userQuery->fetch();
|
||||
|
||||
$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
|
||||
(photo4 IS NOT NULL AND photo4 != '' AND photo4 != 'none') OR
|
||||
(video1 IS NOT NULL AND video1 != '' AND video1 != 'none')
|
||||
) 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);
|
||||
$messageQuery->execute();
|
||||
$message_array = $messageQuery->fetchAll();
|
||||
|
||||
$messages = array();
|
||||
foreach ($message_array as $row) {
|
||||
$messages[] = $row;
|
||||
}
|
||||
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if(!(empty($adsresult))){
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
//adsystem------------------
|
||||
|
||||
$ueuseItems = array();
|
||||
if(!empty($messages)){
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
$message['ads'] = "false";
|
||||
|
||||
$today = date("Y-m-d H:i:s");
|
||||
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if(!(empty($adsresult))){
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
|
||||
$ueuseItems = array();
|
||||
if(!empty($messages)){
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($message['ads'] === "true"){
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
if($message['ads'] === "true"){
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
);
|
||||
}else{
|
||||
$adsystem = null;
|
||||
}
|
||||
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuseItems,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
}else{
|
||||
$adsystem = null;
|
||||
}
|
||||
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuseItems,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$pdo = null;
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$pdo = null;
|
||||
}
|
||||
}else{
|
||||
echo json_encode(['success' => false, 'error' => '認証に失敗しました。(AUTH_INVALID)']);
|
||||
exit;
|
||||
}
|
||||
}else{
|
||||
$item = array(
|
||||
|
||||
+175
-171
@@ -41,208 +41,212 @@ if (safetext(isset($_POST['page'])) && safetext(isset($_POST['userid'])) && safe
|
||||
if ($is_login === false) {
|
||||
echo json_encode(['success' => false, 'error' => 'bad_request']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// データベースに接続
|
||||
try {
|
||||
$option = array(
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::MYSQL_ATTR_MULTI_STATEMENTS => false
|
||||
);
|
||||
$pdo = new PDO('mysql:charset=utf8mb4;dbname=' . DB_NAME . ';host=' . DB_HOST, DB_USER, DB_PASS, $option);
|
||||
} catch (PDOException $e) {
|
||||
// 接続エラーのときエラー内容を取得する
|
||||
$error_message[] = $e->getMessage();
|
||||
}
|
||||
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if ($pageNumber <= 0 || (!(is_numeric($pageNumber)))) {
|
||||
$pageNumber = 1;
|
||||
}elseif(is_sameUserid($userId, $is_login["userid"]) === 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();
|
||||
}
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
|
||||
$messages = array();
|
||||
if (!empty($pdo)) {
|
||||
$myUserData = getUserData($pdo, $userId);
|
||||
$myblocklist = safetext($myUserData["blocklist"]);
|
||||
$mybookmark = safetext($myUserData["bookmark"]);
|
||||
|
||||
if ($is_local === true) {
|
||||
$userQuery = $pdo->prepare("SELECT username, userid, profile, role, follower FROM account WHERE userid = :userid");
|
||||
$userQuery->bindValue(':userid', $uwuzuid);
|
||||
$userQuery->execute();
|
||||
$userData = $userQuery->fetch();
|
||||
|
||||
$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);
|
||||
$messageQuery->execute();
|
||||
$message_array = $messageQuery->fetchAll();
|
||||
|
||||
foreach ($message_array as $row) {
|
||||
$messages[] = $row;
|
||||
$itemsPerPage = 15; // 1ページあたりのユーズ数
|
||||
$pageNumber = $page;
|
||||
if ($pageNumber <= 0 || (!(is_numeric($pageNumber)))) {
|
||||
$pageNumber = 1;
|
||||
}
|
||||
$offset = ($pageNumber - 1) * $itemsPerPage;
|
||||
|
||||
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
} elseif($userData != null) {
|
||||
$activity_base = GetActivityPubJson($userData['outbox']);
|
||||
$pageUrl = $activity_base['first'] ?? null;
|
||||
$messages = array();
|
||||
|
||||
$pageNumber = max(1, (int)$page); // 1ページ目以上に固定
|
||||
$currentPageData = null;
|
||||
if ($is_local === true) {
|
||||
$userQuery = $pdo->prepare("SELECT username, userid, profile, role, follower FROM account WHERE userid = :userid");
|
||||
$userQuery->bindValue(':userid', $uwuzuid);
|
||||
$userQuery->execute();
|
||||
$userData = $userQuery->fetch();
|
||||
|
||||
for ($i = 1; $i <= $pageNumber; $i++) {
|
||||
if (!$pageUrl) break;
|
||||
$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);
|
||||
$messageQuery->execute();
|
||||
$message_array = $messageQuery->fetchAll();
|
||||
|
||||
$currentPageData = GetActivityPubJson($pageUrl);
|
||||
|
||||
// 目的のページに達していなければ next をたどる
|
||||
if ($i < $pageNumber) {
|
||||
$pageUrl = $currentPageData['next'] ?? null;
|
||||
}
|
||||
}
|
||||
$orderedItems = $currentPageData['orderedItems'] ?? [];
|
||||
|
||||
$createItems = array_filter($orderedItems, function ($item) {
|
||||
return isset($item['type']) && $item['type'] === 'Create';
|
||||
});
|
||||
$createItems = array_values($createItems);
|
||||
|
||||
foreach ($createItems as $item) {
|
||||
// object がURLなら取得
|
||||
$object = $item['object'] ?? null;
|
||||
if (is_string($object)) {
|
||||
$object = GetActivityPubJson($object);
|
||||
foreach ($message_array as $row) {
|
||||
$messages[] = $row;
|
||||
}
|
||||
|
||||
// nullや不正なobjectはスキップ
|
||||
if (!is_array($object)) continue;
|
||||
// ユーザー情報を取得して、$messages内のusernameをuserDataのusernameに置き換える
|
||||
$messages = getDatasUeuse($pdo, $messages);
|
||||
} elseif($userData != null) {
|
||||
$activity_base = GetActivityPubJson($userData['outbox']);
|
||||
$pageUrl = $activity_base['first'] ?? null;
|
||||
|
||||
$contentHtml = $object['content'] ?? '';
|
||||
$withNewlines = preg_replace('/<br\s*\/?>/i', "\n", $contentHtml);
|
||||
$plainContent = strip_tags($withNewlines);
|
||||
$pageNumber = max(1, (int)$page); // 1ページ目以上に固定
|
||||
$currentPageData = null;
|
||||
|
||||
$photos = [];
|
||||
$video = null;
|
||||
for ($i = 1; $i <= $pageNumber; $i++) {
|
||||
if (!$pageUrl) break;
|
||||
|
||||
if (!empty($object['attachment'])) {
|
||||
$attachments = is_array($object['attachment']) ? $object['attachment'] : [$object['attachment']];
|
||||
$currentPageData = GetActivityPubJson($pageUrl);
|
||||
|
||||
foreach ($attachments as $att) {
|
||||
if (!is_array($att)) continue;
|
||||
// 目的のページに達していなければ next をたどる
|
||||
if ($i < $pageNumber) {
|
||||
$pageUrl = $currentPageData['next'] ?? null;
|
||||
}
|
||||
}
|
||||
$orderedItems = $currentPageData['orderedItems'] ?? [];
|
||||
|
||||
$mediaType = $att['mediaType'] ?? '';
|
||||
$url = $att['url'] ?? ($att['href'] ?? null);
|
||||
$createItems = array_filter($orderedItems, function ($item) {
|
||||
return isset($item['type']) && $item['type'] === 'Create';
|
||||
});
|
||||
$createItems = array_values($createItems);
|
||||
|
||||
if (!$url) continue;
|
||||
foreach ($createItems as $item) {
|
||||
// object がURLなら取得
|
||||
$object = $item['object'] ?? null;
|
||||
if (is_string($object)) {
|
||||
$object = GetActivityPubJson($object);
|
||||
}
|
||||
|
||||
// 画像(mediaTypeで判定)
|
||||
if (str_starts_with($mediaType, 'image/')) {
|
||||
if (count($photos) < 4) {
|
||||
$photos[] = $url;
|
||||
// nullや不正なobjectはスキップ
|
||||
if (!is_array($object)) continue;
|
||||
|
||||
$contentHtml = $object['content'] ?? '';
|
||||
$withNewlines = preg_replace('/<br\s*\/?>/i', "\n", $contentHtml);
|
||||
$plainContent = strip_tags($withNewlines);
|
||||
|
||||
$photos = [];
|
||||
$video = null;
|
||||
|
||||
if (!empty($object['attachment'])) {
|
||||
$attachments = is_array($object['attachment']) ? $object['attachment'] : [$object['attachment']];
|
||||
|
||||
foreach ($attachments as $att) {
|
||||
if (!is_array($att)) continue;
|
||||
|
||||
$mediaType = $att['mediaType'] ?? '';
|
||||
$url = $att['url'] ?? ($att['href'] ?? null);
|
||||
|
||||
if (!$url) continue;
|
||||
|
||||
// 画像(mediaTypeで判定)
|
||||
if (str_starts_with($mediaType, 'image/')) {
|
||||
if (count($photos) < 4) {
|
||||
$photos[] = $url;
|
||||
}
|
||||
}
|
||||
|
||||
// 動画(mediaTypeで判定)
|
||||
if (str_starts_with($mediaType, 'video/') && !$video) {
|
||||
$video = $url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 動画(mediaTypeで判定)
|
||||
if (str_starts_with($mediaType, 'video/') && !$video) {
|
||||
$video = $url;
|
||||
}
|
||||
$messages[] = [
|
||||
"rpuniqid" => "",
|
||||
"ruuniqid" => "",
|
||||
"uniqid" => "",
|
||||
"datetime" => date("Y-m-d H:i:s", strtotime($object["published"] ?? "now")),
|
||||
"account" => $userData["userid"] . "@" . $activity_domain,
|
||||
"username" => $userData["username"],
|
||||
"iconname" => $userData["iconname"],
|
||||
"headname" => $userData["headname"] ?? null,
|
||||
"role" => $userData["role"] ?? "user",
|
||||
"sacinfo" => "",
|
||||
"ueuse" => $plainContent,
|
||||
"photo1" => $photos[0] ?? null,
|
||||
"photo2" => $photos[1] ?? null,
|
||||
"photo3" => $photos[2] ?? null,
|
||||
"photo4" => $photos[3] ?? null,
|
||||
"video1" => $video,
|
||||
"nsfw" => $object["sensitive"] ?? false,
|
||||
"favorite" => "",
|
||||
"favorite_count" => 0,
|
||||
"reply_count" => 0,
|
||||
"reuse_count" => 0,
|
||||
"abi" => "",
|
||||
"abidate" => null,
|
||||
"activitypub" => true,
|
||||
];
|
||||
}
|
||||
}else{
|
||||
$message = array();
|
||||
}
|
||||
|
||||
|
||||
//adsystem------------------
|
||||
|
||||
$message['ads'] = "false";
|
||||
|
||||
$today = date("Y-m-d H:i:s");
|
||||
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if (!(empty($adsresult))) {
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
|
||||
$ueuseItems = array();
|
||||
if (!empty($messages)) {
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
}
|
||||
}
|
||||
|
||||
$messages[] = [
|
||||
"rpuniqid" => "",
|
||||
"ruuniqid" => "",
|
||||
"uniqid" => "",
|
||||
"datetime" => date("Y-m-d H:i:s", strtotime($object["published"] ?? "now")),
|
||||
"account" => $userData["userid"] . "@" . $activity_domain,
|
||||
"username" => $userData["username"],
|
||||
"iconname" => $userData["iconname"],
|
||||
"headname" => $userData["headname"] ?? null,
|
||||
"role" => $userData["role"] ?? "user",
|
||||
"sacinfo" => "",
|
||||
"ueuse" => $plainContent,
|
||||
"photo1" => $photos[0] ?? null,
|
||||
"photo2" => $photos[1] ?? null,
|
||||
"photo3" => $photos[2] ?? null,
|
||||
"photo4" => $photos[3] ?? null,
|
||||
"video1" => $video,
|
||||
"nsfw" => $object["sensitive"] ?? false,
|
||||
"favorite" => "",
|
||||
"favorite_count" => 0,
|
||||
"reply_count" => 0,
|
||||
"reuse_count" => 0,
|
||||
"abi" => "",
|
||||
"abidate" => null,
|
||||
"activitypub" => true,
|
||||
];
|
||||
}
|
||||
}else{
|
||||
$message = array();
|
||||
}
|
||||
|
||||
|
||||
//adsystem------------------
|
||||
|
||||
$message['ads'] = "false";
|
||||
|
||||
$today = date("Y-m-d H:i:s");
|
||||
|
||||
$adsQuery = $pdo->prepare("SELECT * FROM ads WHERE start_date < :today AND limit_date > :today ORDER BY rand()");
|
||||
$adsQuery->bindValue(':today', $today);
|
||||
$adsQuery->execute();
|
||||
$adsresult = $adsQuery->fetch();
|
||||
if (!(empty($adsresult))) {
|
||||
$message['ads'] = "true";
|
||||
$message['ads_url'] = $adsresult["url"];
|
||||
$message['ads_img_url'] = $adsresult["image_url"];
|
||||
$message['ads_memo'] = $adsresult["memo"];
|
||||
}
|
||||
//--------------------------
|
||||
|
||||
$ueuseItems = array();
|
||||
if (!empty($messages)) {
|
||||
foreach ($messages as $value) {
|
||||
$formatted = FormatUeuseItem($value, $myblocklist, $mybookmark, $pdo, $userId);
|
||||
if ($formatted !== null) {
|
||||
$ueuseItems[] = $formatted;
|
||||
if ($message['ads'] === "true") {
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
);
|
||||
} else {
|
||||
$adsystem = null;
|
||||
}
|
||||
}
|
||||
|
||||
if ($message['ads'] === "true") {
|
||||
$adsystem = array(
|
||||
"type" => "Ads",
|
||||
"url" => $message['ads_url'],
|
||||
"imgurl" => $message['ads_img_url'],
|
||||
"memo" => $message['ads_memo'],
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuseItems,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$adsystem = null;
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$item = array(
|
||||
"success" => true,
|
||||
"ueuses" => $ueuseItems,
|
||||
"ads" => $adsystem,
|
||||
);
|
||||
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$item = array(
|
||||
"success" => false,
|
||||
"ueuses" => null,
|
||||
"ads" => null,
|
||||
"error" => "no_ueuse",
|
||||
);
|
||||
echo json_encode($item, JSON_UNESCAPED_UNICODE);
|
||||
$pdo = null;
|
||||
}
|
||||
|
||||
$pdo = null;
|
||||
}else{
|
||||
echo json_encode(['success' => false, 'error' => '認証に失敗しました。(AUTH_INVALID)']);
|
||||
exit;
|
||||
}
|
||||
|
||||
} else {
|
||||
$item = array(
|
||||
"success" => false,
|
||||
|
||||
Reference in New Issue
Block a user