mirror of
https://github.com/Daichimarukana/uwuzu.git
synced 2026-06-04 19:14:41 +00:00
uwuzu version 1.2.11
This commit is contained in:
@@ -116,6 +116,32 @@ $notiData = $notiQuery->fetch(PDO::FETCH_ASSOC);
|
||||
$notificationcount = $notiData['notification_count'];
|
||||
|
||||
//-------------------------------------------
|
||||
function get_mentions_userid($postText) {
|
||||
// @useridを検出する
|
||||
$usernamePattern = '/@(\w+)/';
|
||||
$mentionedUsers = [];
|
||||
|
||||
preg_replace_callback($usernamePattern, function($matches) use (&$mentionedUsers) {
|
||||
$mention_username = $matches[1];
|
||||
|
||||
$dbh = new PDO('mysql:charset=utf8mb4;dbname='.DB_NAME.';host='.DB_HOST, DB_USER, DB_PASS, array(
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
|
||||
));
|
||||
|
||||
$mention_userQuery = $dbh->prepare("SELECT username, userid FROM account WHERE userid = :userid");
|
||||
$mention_userQuery->bindValue(':userid', $mention_username);
|
||||
$mention_userQuery->execute();
|
||||
$mention_userData = $mention_userQuery->fetch();
|
||||
|
||||
if (!empty($mention_userData)) {
|
||||
$mentionedUsers[] = $mention_username;
|
||||
}
|
||||
}, $postText);
|
||||
|
||||
return $mentionedUsers;
|
||||
}
|
||||
|
||||
if( !empty($_POST['btn_submit']) ) {
|
||||
|
||||
@@ -279,6 +305,46 @@ if( !empty($_POST['btn_submit']) ) {
|
||||
// コミット
|
||||
$res = $pdo->commit();
|
||||
|
||||
$mentionedUsers = get_mentions_userid($ueuse);
|
||||
|
||||
foreach ($mentionedUsers as $mentionedUser) {
|
||||
|
||||
$pdo->beginTransaction();
|
||||
|
||||
try {
|
||||
$touserid = $mentionedUser;
|
||||
$datetime = date("Y-m-d H:i:s");
|
||||
$msg = "" . $ueuse . "";
|
||||
$title = "" . $username . "さんにメンションされました!";
|
||||
$url = "/!" . $uniqid . "~" . $userid . "";
|
||||
$userchk = 'none';
|
||||
|
||||
// 通知用SQL作成
|
||||
$stmt = $pdo->prepare("INSERT INTO notification (touserid, msg, url, datetime, userchk, title) VALUES (:touserid, :msg, :url, :datetime, :userchk, :title)");
|
||||
|
||||
|
||||
$stmt->bindParam(':touserid', $touserid, PDO::PARAM_STR);
|
||||
$stmt->bindParam(':msg', $msg, PDO::PARAM_STR);
|
||||
$stmt->bindParam(':url', $url, PDO::PARAM_STR);
|
||||
$stmt->bindParam(':userchk', $userchk, PDO::PARAM_STR);
|
||||
$stmt->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
|
||||
$stmt->bindParam(':datetime', $datetime, PDO::PARAM_STR);
|
||||
|
||||
// SQLクエリの実行
|
||||
$res = $stmt->execute();
|
||||
|
||||
// コミット
|
||||
$res = $pdo->commit();
|
||||
|
||||
} catch(Exception $e) {
|
||||
|
||||
// エラーが発生した時はロールバック
|
||||
$pdo->rollBack();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch(Exception $e) {
|
||||
|
||||
// エラーが発生した時はロールバック
|
||||
@@ -619,6 +685,10 @@ $(document).ready(function() {
|
||||
});
|
||||
});
|
||||
|
||||
// 10秒後に実行
|
||||
setTimeout(() => {
|
||||
console.log("Execution 10sec"); // Execution 10sec
|
||||
}, 10000);
|
||||
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user