Add override to display short view of headers in messages.

This commit is contained in:
Retro_Guy 2023-09-18 05:07:20 -07:00
parent 2676176737
commit 37a55abb9a
7 changed files with 183 additions and 87 deletions

View File

@ -226,6 +226,10 @@
font-size: 0.9em;
}
.np_header_button_checkbox {
transform: scale(0.8);
}
.np_header_button_link:hover {
color: var(--color-section-background);
background: var(--color-section-link);

View File

@ -226,6 +226,10 @@
font-size: 0.9em;
}
.np_header_button_checkbox {
transform: scale(0.8);
}
.np_header_button_link:hover {
color: var(--color-section-background);
background: var(--color-section-link);

View File

@ -226,6 +226,10 @@
font-size: 0.9em;
}
.np_header_button_checkbox {
transform: scale(0.8);
}
.np_header_button_link:hover {
color: var(--color-section-background);
background: var(--color-section-link);

View File

@ -226,6 +226,10 @@
font-size: 0.9em;
}
.np_header_button_checkbox {
transform: scale(0.8);
}
.np_header_button_link:hover {
color: var(--color-section-background);
background: var(--color-section-link);

View File

@ -226,6 +226,10 @@
font-size: 0.9em;
}
.np_header_button_checkbox {
transform: scale(0.8);
}
.np_header_button_link:hover {
color: var(--color-section-background);
background: var(--color-section-link);

View File

@ -356,7 +356,130 @@ function message_thread($id, $group, $thread, $highlightids = false)
* $group: the name of the newsgroup, is needed for the links to post.php3
* and the header.
*/
function show_header($head, $group, $local_poster = false)
{
global $article_show, $text_header, $file_article, $attachment_show;
global $file_attachment, $anonym_address, $CONFIG, $OVERRIDES;
if($OVERRIDES['short_headers'] == true) {
show_header_short($head, $group, $local_poster);
return;
}
if (isset($_COOKIE['tzo'])) {
$offset = $_COOKIE['tzo'];
} else {
$offset = intval($CONFIG['timezone']);
}
echo '<div class="np_article_header">';
if ($article_show["Subject"])
echo $text_header["subject"] . htmlspecialchars($head->subject) . "<br>";
if ($article_show["From"]) {
echo $text_header["from"];
if ($head->from == $anonym_address) {
// this is the anonymous address, so only show the name
echo htmlspecialchars($head->name);
} else {
if ($article_show["From_link"])
echo '<a href="mailto:' . htmlspecialchars($head->from) . '">';
if (isset($article_show["From_rewrite"]))
echo preg_replace('/{$article_show["From_rewrite"][0]}/', $article_show["From_rewrite"][1], htmlspecialchars($head->from));
$before_at = explode('@', $head->from);
$namelen = strlen($before_at[0]);
if ($namelen > 3) {
$endname = $namelen - 3;
if ($endname > 8)
$endname = 8;
if ($endname < 3)
$endname ++;
if ($endname < 3)
$endname ++;
} else {
$endname = $namelen;
}
if ($article_show["From_link"])
echo '</a>';
echo '<span class="visited">';
if ($local_poster) {
echo '<i>';
}
if ($head->name != "") {
echo create_name_link($head->name, $head->from);
} else {
if (isset($CONFIG['hide_email']) && $CONFIG['hide_email'] == true) {
echo truncate_email($head->from);
} else {
echo htmlspecialchars($head->from);
}
}
if ($local_poster) {
echo '</i>';
}
echo '</span>';
}
echo "<br>";
}
if ($article_show["Newsgroups"])
echo $text_header["newsgroups"] . htmlspecialchars(str_replace(',', ', ', $head->newsgroups)) . "<br>\n";
if (isset($head->followup) && ($article_show["Followup"]) && ($head->followup != ""))
echo $text_header["followup"] . htmlspecialchars($head->followup) . "<br>\n";
if ((isset($head->organization)) && ($article_show["Organization"]) && ($head->organization != ""))
echo $text_header["organization"] . html_parse(htmlspecialchars($head->organization)) . "<br>\n";
if ($article_show["Date"]) {
$ts = new DateTime(date($text_header["date_format"], $head->date), new DateTimeZone('UTC'));
$ts->add(DateInterval::createFromDateString($offset . ' minutes'));
if ($offset != 0) {
echo $text_header["date"] . $ts->format('D, j M Y H:i') . "<br>\n";
} else {
echo $text_header["date"] . $ts->format($text_header["date_format"]) . "<br>\n";
}
unset($ts);
}
// echo $text_header["date"].date($text_header["date_format"],$head->date)."<br>\n";
if ($article_show["Message-ID"]) {
echo ' ' . $text_header["message-id"] . htmlspecialchars($head->id) . "<br>\n";
}
if (($article_show["References"]) && (isset($head->references[0]))) {
echo $text_header["references"];
for ($i = 0; $i <= count($head->references) - 1; $i ++) {
$ref = $head->references[$i];
echo ' ' . '<a href="' . $file_article . '?group=' . urlencode($group) . '&id=' . urlencode($ref) . '">' . ($i + 1) . '</a>';
}
echo "<br>";
}
if (isset($head->user_agent)) {
if ((isset($article_show["User-Agent"])) && ($article_show["User-Agent"])) {
echo $text_header["user-agent"] . htmlspecialchars($head->user_agent) . "<br>\n";
} else {
echo "<!-- User-Agent: " . htmlspecialchars($head->user_agent) . " -->\n";
}
}
if ((isset($attachment_show)) && ($attachment_show == true) && (isset($head->content_type[1]))) {
echo $text_header["attachments"];
for ($i = 1; $i < count($head->content_type); $i ++) {
if (! strcmp($head->content_type[$i], "text/html")) {
$contype = "HTML Version";
} else {
$contype = $head->content_type_name[$i];
}
echo '<a href="' . $file_attachment . '?group=' . urlencode($group) . '&' . 'id=' . urlencode($head->number) . '&' . 'attachment=' . $i . '">' . $contype . '</a> (' . $head->content_type[$i] . ')';
if ($i < count($head->content_type) - 1)
echo ', ';
}
}
if ($article_show["trigger_headers"]) {
echo '<div>';
echo '<input type="checkbox" id="trigger_headers">';
echo '<div class="display_headers_on">' . display_full_headers($head->number, $group, $head->name, $head->from) . '</div>';
echo ' View all headers' . "<br>\n";
echo '</div>';
}
echo '</div>';
}
function show_header_short($head, $group, $local_poster = false)
{
global $article_show, $text_header, $file_article, $attachment_show;
global $file_attachment, $anonym_address, $CONFIG;
@ -366,90 +489,31 @@ function show_header($head, $group, $local_poster = false)
$offset = intval($CONFIG['timezone']);
}
echo '<div class="np_article_header">';
if ($article_show["Subject"])
echo $text_header["subject"] . htmlspecialchars($head->subject) . "<br>";
if ($article_show["From"]) {
echo $text_header["from"];
if ($head->from == $anonym_address) {
// this is the anonymous address, so only show the name
echo htmlspecialchars($head->name);
echo '<b>';
if ($article_show["Subject"]) {
echo htmlspecialchars($head->subject) . "<br>";
}
echo '</b>';
$poster = address_decode($head->from, "nowhere");
if ($head->name != "") {
$displayname = create_name_link($head->name, $head->from);
} else {
if (isset($CONFIG['hide_email']) && $CONFIG['hide_email'] == true) {
$displayname = truncate_email($head->from);
} else {
if ($article_show["From_link"])
echo '<a href="mailto:' . htmlspecialchars($head->from) . '">';
if (isset($article_show["From_rewrite"]))
echo preg_replace('/{$article_show["From_rewrite"][0]}/', $article_show["From_rewrite"][1], htmlspecialchars($head->from));
$before_at = explode('@', $head->from);
$namelen = strlen($before_at[0]);
if ($namelen > 3) {
$endname = $namelen - 3;
if ($endname > 8)
$endname = 8;
if ($endname < 3)
$endname ++;
if ($endname < 3)
$endname ++;
} else {
$endname = $namelen;
}
if ($article_show["From_link"])
echo '</a>';
echo '<span class="visited">';
if ($local_poster) {
echo '<i>';
}
if ($head->name != "") {
echo create_name_link($head->name, $head->from);
} else {
if (isset($CONFIG['hide_email']) && $CONFIG['hide_email'] == true) {
echo truncate_email($head->from);
} else {
echo htmlspecialchars($head->from);
}
}
if ($local_poster) {
echo '</i>';
}
echo '</span>';
}
echo "<br>";
}
if ($article_show["Newsgroups"])
echo $text_header["newsgroups"] . htmlspecialchars(str_replace(',', ', ', $head->newsgroups)) . "<br>\n";
if (isset($head->followup) && ($article_show["Followup"]) && ($head->followup != ""))
echo $text_header["followup"] . htmlspecialchars($head->followup) . "<br>\n";
if ((isset($head->organization)) && ($article_show["Organization"]) && ($head->organization != ""))
echo $text_header["organization"] . html_parse(htmlspecialchars($head->organization)) . "<br>\n";
if ($article_show["Date"]) {
$ts = new DateTime(date($text_header["date_format"], $head->date), new DateTimeZone('UTC'));
$ts->add(DateInterval::createFromDateString($offset . ' minutes'));
if ($offset != 0) {
echo $text_header["date"] . $ts->format('D, j M Y H:i') . "<br>\n";
} else {
echo $text_header["date"] . $ts->format($text_header["date_format"]) . "<br>\n";
}
unset($ts);
}
// echo $text_header["date"].date($text_header["date_format"],$head->date)."<br>\n";
if ($article_show["Message-ID"]) {
echo ' ' . $text_header["message-id"] . htmlspecialchars($head->id) . "<br>\n";
}
if (($article_show["References"]) && (isset($head->references[0]))) {
echo $text_header["references"];
for ($i = 0; $i <= count($head->references) - 1; $i ++) {
$ref = $head->references[$i];
echo ' ' . '<a href="' . $file_article . '?group=' . urlencode($group) . '&id=' . urlencode($ref) . '">' . ($i + 1) . '</a>';
}
echo "<br>";
}
if (isset($head->user_agent)) {
if ((isset($article_show["User-Agent"])) && ($article_show["User-Agent"])) {
echo $text_header["user-agent"] . htmlspecialchars($head->user_agent) . "<br>\n";
} else {
echo "<!-- User-Agent: " . htmlspecialchars($head->user_agent) . " -->\n";
$displayname = htmlspecialchars($head->from);
}
}
$ts = new DateTime(date($text_header["date_format"], $head->date), new DateTimeZone('UTC'));
$ts->add(DateInterval::createFromDateString($offset . ' minutes'));
if ($offset != 0) {
$displaydate = $ts->format('D, j M Y H:i') . "<br>\n";
} else {
$displaydate = $ts->format($text_header["date_format"]) . "<br>\n";
}
unset($ts);
if ((isset($attachment_show)) && ($attachment_show == true) && (isset($head->content_type[1]))) {
echo '<div class=np_ob_posted_date>';
echo $text_header["attachments"];
for ($i = 1; $i < count($head->content_type); $i ++) {
if (! strcmp($head->content_type[$i], "text/html")) {
@ -461,14 +525,20 @@ function show_header($head, $group, $local_poster = false)
if ($i < count($head->content_type) - 1)
echo ', ';
}
}
if ($article_show["trigger_headers"]) {
echo '<div>';
echo '<input type="checkbox" id="trigger_headers">';
echo '<div class="display_headers_on">' . display_full_headers($head->number, $group, $head->name, $head->from) . '</div>';
echo ' View all headers' . "<br>\n";
echo '</div>';
}
if ($article_show["trigger_headers"]) {
echo '<div class=np_ob_posted_date>';
echo '<input type="checkbox" class="np_header_button_checkbox" id="trigger_headers" title="Show headers">';
echo '<div class="display_headers_on">' . display_full_headers($head->number, $group, $head->name, $head->from) . '</div>';
if($local_poster) {
echo "&nbsp;by: <i>".$displayname."</i> - ".$displaydate;
} else {
echo "&nbsp;by: ".$displayname." - ".$displaydate;
}
echo '</div>';
}
echo '</p>';
echo '</div>';
}

View File

@ -5,6 +5,12 @@ return [
// spoolnews.php
'maxarticles_per_run' => 100,
'maxfirstrequest' => 100
'maxfirstrequest' => 100,
// Display short view of headers (only subject, name, date)
'short_headers' => false,
// Just leave this here to avoid comma errors
'comma' => true
];
?>