1
0
mirror of https://github.com/Daichimarukana/uwuzu.git synced 2026-06-05 03:24:41 +00:00

uwuzu version 1.2.26

This commit is contained in:
Daichimarukana
2023-11-15 22:07:23 +09:00
parent 884f8043a3
commit c51582a221
42 changed files with 1534 additions and 162 deletions
+25 -1
View File
@@ -18,6 +18,30 @@
for( $i=0;$i<$cnt;$i++ ){
$uwuzuinfo[$i] = ($softwaredata[$i]);
}
function replaceURLsWithLinks_forRightbox($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'] = '';
}
$domain = $parsedUrl['host'].(strlen($parsedUrl['path']) > 24 ? substr($parsedUrl['path'], 0, 24) . '...' : $parsedUrl['path']);
// 不要な文字を削除して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;
}
?>
<div class="noticearea">
<h1>お知らせ</h1>
@@ -32,7 +56,7 @@
<?php foreach ($notices as $value) {?>
<div class="noticebox">
<h4><?php echo $value['title'];?></h4>
<p><?php echo nl2br($value['note']);?></p>
<p><?php echo replaceURLsWithLinks_forRightbox(nl2br($value['note']));?></p>
<div class="makeup"><p>編集者 : <a href="/@<?php echo $value['account'];?>">@<?php echo $value['account'];?></a></p></div>
<div class="time"><p><?php echo date('Y年m月d日 H:i', strtotime($value['datetime']));?></p></div>
</div>