1
0
mirror of https://github.com/Daichimarukana/uwuzu.git synced 2026-06-04 19:14:41 +00:00

uwuzu v1.3.4 new_planet

This commit is contained in:
Daichimarukana
2024-03-26 22:48:57 +09:00
parent e0b3b93414
commit ea4ca882da
92 changed files with 3192 additions and 1567 deletions
+14 -35
View File
@@ -179,41 +179,19 @@ $notiData = $notiQuery->fetch(PDO::FETCH_ASSOC);
$notificationcount = $notiData['notification_count'];
//------------------通知--------------
function replaceURLsWithLinks_forNotice($postText) {
$postText = str_replace(''', '\'', $postText);
function replaceURLsWithLinks_forNotice($postText, $maxLength = 48) {
$pattern = '/(https:\/\/[\w!?\/+\-_~;.,*&@#$%()+|https:\/\/[ぁ-んァ-ヶ一-龠々\w\-\/?=&%.]+)/';
$convertedText = preg_replace_callback($pattern, function($matches) use ($maxLength) {
$link = $matches[0];
if (mb_strlen($link) > $maxLength) {
$truncatedLink = mb_substr($link, 0, $maxLength).'…';
return '<a href="'.$link.'">'.$truncatedLink.'</a>';
} else {
return '<a href="'.$link.'">'.$link.'</a>';
}
}, $postText);
// URLを正規表現を使って検出
$pattern = '/(https:\/\/[^\s<>\[\]\'"]+)/'; // 改良された正規表現
preg_match_all($pattern, $postText, $matches);
// 検出したURLごとに処理を行う
foreach ($matches[0] as $url) {
// ドメイン部分を抽出
$parsedUrl = parse_url($url);
if (!isset($parsedUrl['path'])) {
$parsedUrl['path'] = '';
}
if (!isset($parsedUrl['query'])) {
$parsedUrl['query'] = '';
}
$nochk_domain = $parsedUrl['host'].$parsedUrl['path'].$parsedUrl['query'];
if(strlen($nochk_domain) > 47){
$domain = mb_substr($nochk_domain, 0, 48, "UTF-8")."...";
}else{
$domain = $nochk_domain;
}
// 不要な文字を削除してaタグを生成
$urlWithoutSpaces = preg_replace('/\s+/', '', $url);
$link = "<a href='$urlWithoutSpaces' target='_blank' title='$urlWithoutSpaces'>$domain</a>";
// URLをドメインのみを表示するaタグで置き換え
$postText = preg_replace('/' . preg_quote($url, '/') . '/', $link, $postText);
}
return $postText;
return $convertedText;
}
$sql = "SELECT title, note, account, datetime FROM notice ORDER BY datetime DESC";
@@ -237,7 +215,7 @@ $pdo = null;
<html lang="ja">
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script src="../js/jquery-min.js"></script>
<script src="../js/unsupported.js"></script>
<script src="../js/console_notice.js"></script>
<meta name="viewport" content="width=device-width,initial-scale=1">
@@ -284,6 +262,7 @@ $pdo = null;
<?php require('../require/rightbox.php');?>
<?php require('../require/botbox.php');?>
<?php require('../require/noscript_modal.php');?>
</body>