From 08f879a5b96e44679d9a5991deebdeb5e3466ae3 Mon Sep 17 00:00:00 2001 From: NekoCH <96158157+ex-hentai@users.noreply.github.com> Date: Wed, 17 Apr 2024 13:56:24 +0800 Subject: [PATCH 1/2] support more bbcode tags audio/video/hide/hr/strikethrough --- include/functions.php | 41 ++++++++++++++++++++++++++++++++++++--- lang/chs/lang_tags.php | 22 ++++++++++++++++++++- lang/en/lang_tags.php | 22 ++++++++++++++++++++- public/styles/nexus.css | 8 ++++++++ public/tags.php | 43 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 131 insertions(+), 5 deletions(-) diff --git a/include/functions.php b/include/functions.php index d11edfcf..c3c5a4a0 100644 --- a/include/functions.php +++ b/include/functions.php @@ -283,6 +283,20 @@ function formatYoutube($src, $width = '', $height = ''): string )); } +function formatVideo($src, $width, $height) { + if (!$width) { + $width = 560; + } + if (!$height) { + $height = 315; + } + return addTempCode(""); +} + +function formatAudio($src) { + return addTempCode(""); +} + function formatSpoiler($content, $title = '', $defaultCollapsed = true): string { global $lang_functions; @@ -301,6 +315,11 @@ function formatSpoiler($content, $title = '', $defaultCollapsed = true): string return addTempCode($HTML); } +function formatHidden($content): string +{ + return addTempCode(sprintf('%s', $content)); +} + function formatTextAlign($text, $align): string { return addTempCode(sprintf('
%s
', $align, $text)); @@ -346,8 +365,8 @@ function format_comment($text, $strip_html = true, $xssclean = false, $newtab = // Linebreaks $s = nl2br($s); - $originalBbTagArray = array('[siteurl]', '[site]','[*]', '[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[pre]', '[/pre]', '[/color]', '[/font]', '[/size]', " "); - $replaceXhtmlTagArray = array(get_protocol_prefix().get_setting('basic.BASEURL'), get_setting('basic.SITENAME'), 'list', '', '', '', '', '', '', '
', '
', '', '', '', '  '); + $originalBbTagArray = array('[siteurl]', '[site]','[*]', '[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[s]', '[/s]', '[pre]', '[/pre]', '[/color]', '[/font]', '[/size]', '[hr]', " "); + $replaceXhtmlTagArray = array(get_protocol_prefix().get_setting('basic.BASEURL'), get_setting('basic.SITENAME'), '• ', '', '', '', '', '', '', '', '', '
', '
', '', '', '', '
', '  '); $s = str_replace($originalBbTagArray, $replaceXhtmlTagArray, $s); $originalBbTagArray = array("/\[font=([^\[\(&\\;]+?)\]/is", "/\[color=([#0-9a-z]{1,15})\]/is", "/\[color=([a-z]+)\]/is", "/\[size=([1-7])\]/is"); @@ -397,6 +416,17 @@ function format_comment($text, $strip_html = true, $xssclean = false, $newtab = $s = preg_replace_callback("/\[youtube(\,([1-9][0-9]*)\,([1-9][0-9]*))?\]((http|https):\/\/[^\s'\"<>]+)\[\/youtube\]/i", function ($matches) { return formatYoutube($matches[4], $matches[2], $matches[3]); }, $s); + } + if (str_contains($s, "[video")) { + $s = preg_replace_callback("/\[video(\,([1-9][0-9]*)\,([1-9][0-9]*))?\]((http|https):\/\/[^\s'\"<>]+)\[\/video\]/i", function ($matches) { + return formatVideo($matches[4], $matches[2], $matches[3]); + }, $s); + } + if (str_contains($s, "[audio")) { + $s = preg_replace_callback("/\[audio\]((http|https):\/\/[^\s'\"<>]+)\[\/audio\]/i", function ($matches) { + return formatAudio($matches[1]); + }, $s); + } // [url=http://www.example.com]Text[/url] @@ -433,6 +463,11 @@ function format_comment($text, $strip_html = true, $xssclean = false, $newtab = return formatTextAlign($matches[1], 'right'); }, $s); + // [hide]Hidden text[/hide] + $s = preg_replace_callback("/\[hide\](.*)\[\/hide\]/isU", function ($matches) { + return formatHidden($matches[1]); + }, $s); + $s = format_urls($s, $newtab); // Quotes @@ -5557,7 +5592,7 @@ function strip_all_tags($text) { //替换掉无参数标签 $bbTags = [ - '[*]', '[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[pre]', '[/pre]', '[quote]', '[/quote]', + '[*]', '[b]', '[/b]', '[i]', '[/i]', '[u]', '[/u]', '[s]', '[/s]', '[pre]', '[/pre]', '[quote]', '[/quote]', '[/color]', '[/font]', '[/size]', '[/url]', '[/youtube]', '[/spoiler]', ]; $text = str_replace($bbTags, '', $text); diff --git a/lang/chs/lang_tags.php b/lang/chs/lang_tags.php index 34e47912..e069550b 100644 --- a/lang/chs/lang_tags.php +++ b/lang/chs/lang_tags.php @@ -22,6 +22,14 @@ $lang_tags = array 'text_underline_description' => "在文字下加划线", 'text_underline_syntax' => "[u]文字[/u]", 'text_underline_example' => "[u]这是下划线[/u]", + 'text_strikethrough' => "删除线", + 'text_strikethrough_description' => "为文字添加删除线", + 'text_strikethrough_syntax' => "[s]文字[/s]", + 'text_strikethrough_example' => "[s]这是删除线[/s]", + 'text_hide' => '隐藏', + 'text_hide_description' => '使文字隐藏', + 'text_hide_syntax' => '[hide]文字[/hide]', + 'text_hide_example' => '[hide]I tried so hard and got so far[/hide]', 'text_color_one' => "颜色 (方式1)", 'text_color_one_description' => "改变文字颜色", 'text_color_one_syntax' => "[color=Color]文字[/color]", @@ -114,7 +122,15 @@ $lang_tags = array 'text_youtube' => "YouTube", 'text_youtube_description' => "在页面内插入YouTube网站的在线视频", 'text_youtube_syntax' => "[youtube,width,height]YouTube视频的URL[/youtube]", - 'text_youtube_example' => "[youtube,560,315]https://www.youtube.com/watch?v=DWDL3VTCcCg&ab_channel=ESPNMMA[/youtube]", + 'text_youtube_example' => "[youtube,560,315]https://www.youtube.com/watch?v=dQw4w9WgXcQ[/youtube]", + 'text_video' => "视频", + 'text_video_description' => "在页面内插入HTML5视频播放器", + 'text_video_syntax' => "[video,width,height]视频的URL[/video]", + 'text_video_example' => "[video]https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm[/video]", + 'text_audio' => "音频", + 'text_audio_description' => "在页面内插入HTML5音频播放器", + 'text_audio_syntax' => "[audio]音频的URL[/audio]", + 'text_audio_example' => "[audio]https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3[/audio]", 'text_youku' => "优酷", 'text_youku_description' => "在页面内插入优酷网的在线视频", 'text_youku_syntax' => "[youku]优酷网视频的URL[/youku]", @@ -132,6 +148,10 @@ $lang_tags = array 'text_spoiler_description' => '在页面插入可展开/收缩的内容', 'text_spoiler_syntax' => '[spoiler=标题]这是被折叠的内容[/spoiler]', 'text_spoiler_example' => '[spoiler=英雄最后的结局怎么样了?]英雄最后死掉了![/spoiler]', + 'text_hr' => '水平线', + 'text_hr_description' => '在页面内插入水平线', + 'text_hr_syntax' => '[hr]', + 'text_hr_example' => 'Never gonna give you up[hr]Never gonna let you down', 'text_left' => '靠左对齐', 'text_left_description' => '在页面插入靠左对齐的内容', diff --git a/lang/en/lang_tags.php b/lang/en/lang_tags.php index 87badc73..7c0aa00e 100644 --- a/lang/en/lang_tags.php +++ b/lang/en/lang_tags.php @@ -22,6 +22,14 @@ $lang_tags = array 'text_underline_description' => "Makes the enclosed text underlined.", 'text_underline_syntax' => "[u]Text[/u]", 'text_underline_example' => "[u]This is underlined text.[/u]", + 'text_strikethrough' => "Strikethrough", + 'text_strikethrough_description' => "Makes the enclosed text strikethrough.", + 'text_strikethrough_syntax' => "[s]Text[/s]", + 'text_strikethrough_example' => "[s]This is strikethrough text.[/s]", + 'text_hide' => 'Hidden', + 'text_hide_description' => 'Makes the enclosed text hidden', + 'text_hide_syntax' => '[hide]Text[/hide]', + 'text_hide_example' => '[hide]I tried so hard and got so far[/hide]', 'text_color_one' => "Color (alt. 1)", 'text_color_one_description' => "Changes the color of the enclosed text.", 'text_color_one_syntax' => "[color=Color]Text[/color]", @@ -114,7 +122,15 @@ $lang_tags = array 'text_youtube' => "YouTube", 'text_youtube_description' => "Insert YouTube online video in webpages", 'text_youtube_syntax' => "[youtube,width,height]Video URL on YouTube[/youtube]", - 'text_youtube_example' => "[youtube,560,315]https://www.youtube.com/watch?v=DWDL3VTCcCg&ab_channel=ESPNMMA[/youtube]", + 'text_youtube_example' => "[youtube,560,315]https://www.youtube.com/watch?v=dQw4w9WgXcQ[/youtube]", + 'text_video' => "Video", + 'text_video_description' => "Insert HTML5 video player", + 'text_video_syntax' => "[video,width,height]Video URL[/video]", + 'text_video_example' => "[video]https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm[/video]", + 'text_audio' => "Audio", + 'text_audio_description' => "Insert HTML5 audio player", + 'text_audio_syntax' => "[audio]Audio URL[/audio]", + 'text_audio_example' => "[audio]https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3[/audio]", 'text_youku' => "YouKu", 'text_youku_description' => "Insert YouKu online video in webpages", 'text_youku_syntax' => "[youku]Video URL on YouKu[/youku]", @@ -132,6 +148,10 @@ $lang_tags = array 'text_spoiler_description' => 'Insert expandable/collapsible content on the page', 'text_spoiler_syntax' => '[spoiler=title]This is the folded content[/spoiler]', 'text_spoiler_example' => '[spoiler=What happened to the final ending of the hero?]The hero died last![/spoiler]', + 'text_hr' => 'Horizontal rule', + 'text_hr_description' => 'Insert horizontal rule content on the page', + 'text_hr_syntax' => '[hr]', + 'text_hr_example' => 'Never gonna give you up[hr]Never gonna let you down', 'text_left' => 'Text align left', 'text_left_description' => 'Insert left-justified content on the page', diff --git a/public/styles/nexus.css b/public/styles/nexus.css index f5590989..be62367b 100644 --- a/public/styles/nexus.css +++ b/public/styles/nexus.css @@ -96,3 +96,11 @@ img.hitandrun { .form-control-row input[type=checkbox] { vertical-align: sub; } + +.hidden-text { + filter: blur(.5em); + transition: filter .15s ease-in-out; +} +.hidden-text:hover { + filter: blur(0); +} diff --git a/public/tags.php b/public/tags.php index e8d7cd2e..c4aaf6db 100644 --- a/public/tags.php +++ b/public/tags.php @@ -59,6 +59,22 @@ insert_tag( "" ); +insert_tag( + $lang_tags['text_strikethrough'], + $lang_tags['text_strikethrough_description'], + $lang_tags['text_strikethrough_syntax'], + $lang_tags['text_strikethrough_example'], + "" +); + +insert_tag( + $lang_tags['text_hide'], + $lang_tags['text_hide_description'], + $lang_tags['text_hide_syntax'], + $lang_tags['text_hide_example'], + "" +); + insert_tag( $lang_tags['text_color_one'], $lang_tags['text_color_one_description'], @@ -252,6 +268,24 @@ insert_tag( $lang_tags['text_youtube_example'], "" ); + + +insert_tag( + $lang_tags['text_video'], + $lang_tags['text_video_description'], + $lang_tags['text_video_syntax'], + $lang_tags['text_video_example'], + "" +); + + +insert_tag( + $lang_tags['text_audio'], + $lang_tags['text_audio_description'], + $lang_tags['text_audio_syntax'], + $lang_tags['text_audio_example'], + "" +); /* insert_tag( $lang_tags['text_youku'], @@ -286,6 +320,15 @@ insert_tag( "" ); + +insert_tag( + $lang_tags['text_hr'], + $lang_tags['text_hr_description'], + $lang_tags['text_hr_syntax'], + $lang_tags['text_hr_example'], + "" +); + end_frame(); end_main_frame(); stdfoot(); From 7376bbba8c344ff70678870a3f4ebc3cd66d699e Mon Sep 17 00:00:00 2001 From: NekoCH <96158157+ex-hentai@users.noreply.github.com> Date: Fri, 14 Jul 2023 19:12:05 +0800 Subject: [PATCH 2/2] hide passkey and ip addresses --- include/functions.php | 4 ++++ public/usercp.php | 6 +++--- public/userdetails.php | 7 +++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/functions.php b/include/functions.php index c3c5a4a0..796e155b 100644 --- a/include/functions.php +++ b/include/functions.php @@ -6516,4 +6516,8 @@ function can_view_post($uid, $post) return true; } +function hide_text($text) { + return '' . $text . ''; +} + ?> diff --git a/public/usercp.php b/public/usercp.php index 80886565..1fa6e008 100644 --- a/public/usercp.php +++ b/public/usercp.php @@ -992,14 +992,14 @@ tr_small($lang_usercp['row_email_address'], $CURUSER['email'], 1); $seedBoxIcon = (new \App\Repositories\SeedBoxRepository())->renderIcon($CURUSER['ip'], $CURUSER['id']); if ($enablelocation_tweak == 'yes'){ list($loc_pub, $loc_mod) = get_ip_location($CURUSER["ip"]); - tr_small($lang_usercp['row_ip_location'], $CURUSER["ip"]." [" . $loc_pub . "]$seedBoxIcon", 1); + tr_small($lang_usercp['row_ip_location'], hide_text($CURUSER["ip"])." [" . $loc_pub . "]$seedBoxIcon", 1); } else{ - tr_small($lang_usercp['row_ip_location'], $CURUSER["ip"] . $seedBoxIcon, 1); + tr_small($lang_usercp['row_ip_location'], hide_text($CURUSER["ip"]) . $seedBoxIcon, 1); } if ($CURUSER["avatar"]) tr_small($lang_usercp['row_avatar'], "", 1); -tr_small($lang_usercp['row_passkey'], $CURUSER["passkey"], 1); +tr_small($lang_usercp['row_passkey'], hide_text($CURUSER["passkey"]), 1); if (get_setting('security.login_type') == 'passkey' && get_setting('security.login_secret_deadline') > date('Y-m-d H:i:s')) { tr_small($lang_usercp['row_passkey_login_url'], sprintf('%s/%s/%s', getSchemeAndHttpHost(), get_setting('security.login_secret'), $CURUSER['passkey']), 1); } diff --git a/public/userdetails.php b/public/userdetails.php index 499141f5..51273ca2 100644 --- a/public/userdetails.php +++ b/public/userdetails.php @@ -235,7 +235,8 @@ if (user_can('userprofile') || $user["id"] == $CURUSER["id"]) $locationinfo = "[" . $loc_pub . "]"; } else $locationinfo = ""; - tr_small($lang_userdetails['row_ip_address'], $user['ip'].$locationinfo.$seedBoxIcon, 1); + $ip = $user["id"] == $CURUSER["id"] ? hide_text($user['ip']) : $user['ip']; + tr_small($lang_userdetails['row_ip_address'], $ip.$locationinfo.$seedBoxIcon, 1); } $clientselect = ''; $res = sql_query("SELECT peer_id, agent, ipv4, ipv6, port FROM peers WHERE userid = {$user['id']} GROUP BY agent, ipv4, ipv6, port") or sqlerr(); @@ -247,7 +248,9 @@ if (mysql_num_rows($res) > 0) $clientselect .= ""; $clientselect .= sprintf('%s', get_agent($arr['peer_id'], $arr['agent'])); if (user_can('userprofile') || $user["id"] == $CURUSER["id"]) { - $clientselect .= sprintf('%s%s%s', $arr['ipv4'].$seedBoxRep->renderIcon($arr['ipv4'], $user['id']), $arr['ipv6'].$seedBoxRep->renderIcon($arr['ipv6'], $user['id']), $arr['port']); + $v4 = $user["id"] == $CURUSER["id"] ? hide_text($arr['ipv4']) : $arr['ipv4']; + $v6 = $user["id"] == $CURUSER["id"] ? hide_text($arr['ipv6']) : $arr['ipv6']; + $clientselect .= sprintf('%s%s%s', $v4.$seedBoxRep->renderIcon($arr['ipv4'], $user['id']), $v6.$seedBoxRep->renderIcon($arr['ipv6'], $user['id']), $arr['port']); } else { $clientselect .= sprintf('%s%s%s', '---', '---', '---'); }