Check that imagecreatefromxbm() function exists before trying to display xface.

This commit is contained in:
Retro_Guy 2024-04-03 07:44:58 -07:00
parent 1af6adada9
commit 6b99f5ca47
2 changed files with 40 additions and 27 deletions

View File

@ -29,7 +29,7 @@ php-gnupg
php8.x-sqlite3 (or later version). php8.x-sqlite3 (or later version).
phpmailer is required if email confirmation is to be used. phpmailer is required if email confirmation is to be used.
php-xml to work with RSS feeds php-xml to work with RSS feeds
compface and php-gd for X-Face support compface, php-gd and libgd3 for X-Face support
These are the names for Debian packages. Other distributions should These are the names for Debian packages. Other distributions should
also provide these in some way. also provide these in some way.

View File

@ -23,10 +23,10 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
?> ?>
<?php <?php
function message_parse($rawmessage) function message_parse($rawmessage)
{ {
global $attachment_delete_alternative, $attachment_uudecode, $www_charset; global $attachment_delete_alternative, $attachment_uudecode, $www_charset;
@ -516,41 +516,51 @@ function show_header_short($head, $group, $local_poster = false)
} }
unset($ts); unset($ts);
echo '<div class=np_ob_posted_date>'; echo '<div class=np_ob_posted_date>';
// Copy MID to clipboard (requires js) // Copy MID to clipboard (requires js)
echo '<script>'; echo '<script>';
echo 'function CopyToClipboard(id)'; echo 'function CopyToClipboard(id)';
echo '{'; echo '{';
echo 'var r = document.createRange();'; echo 'var r = document.createRange();';
echo 'r.selectNode(document.getElementById(id));'; echo 'r.selectNode(document.getElementById(id));';
echo 'window.getSelection().removeAllRanges();'; echo 'window.getSelection().removeAllRanges();';
echo 'window.getSelection().addRange(r);'; echo 'window.getSelection().addRange(r);';
echo "document.execCommand('copy');"; echo "document.execCommand('copy');";
echo 'window.getSelection().removeAllRanges();'; echo 'window.getSelection().removeAllRanges();';
echo '}'; echo '}';
echo '</script> '; echo '</script> ';
?> ?>
<p id="<?php echo $head->id; ?>" style="position: absolute; z-index: -9999;"><?php echo htmlspecialchars($head->id); ?></p> <p id="<?php echo $head->id; ?>"
&nbsp;<a href="#" onclick="CopyToClipboard('<?php echo $head->id; ?>');return false;" style="text-decoration: none" title="Copy message-id to clipboard"><i>copy mid</i></a> style="position: absolute; z-index: -9999;"><?php echo htmlspecialchars($head->id); ?></p>
&nbsp;
<a href="#"
onclick="CopyToClipboard('<?php echo $head->id; ?>');return false;"
style="text-decoration: none" title="Copy message-id to clipboard"><i>copy
mid</i></a>
<p id="<?php echo $head->number . 'copy'; ?>" style="position: absolute; z-index: -9999;"><?php echo $sitelink . '/' . $config_name . '/article-flat.php?id=' . $head->number . '&group=' . urlencode($group) . '#' . $head->number; ?></p> <p id="<?php echo $head->number . 'copy'; ?>"
&nbsp;<a href="#" onclick="CopyToClipboard('<?php echo $head->number . 'copy'; ?>');return false;" style="text-decoration: none" title="Copy article link to clipboard"><i>copy link</i></a> style="position: absolute; z-index: -9999;"><?php echo $sitelink . '/' . $config_name . '/article-flat.php?id=' . $head->number . '&group=' . urlencode($group) . '#' . $head->number; ?></p>
&nbsp;
<?php <a href="#"
onclick="CopyToClipboard('<?php echo $head->number . 'copy'; ?>');return false;"
style="text-decoration: none" title="Copy article link to clipboard"><i>copy
link</i></a>
<?php
echo '&nbsp;&nbsp;Newsgroups: '; echo '&nbsp;&nbsp;Newsgroups: ';
$ngroups = preg_replace("/\,|\ /", "\t", $head->newsgroups); $ngroups = preg_replace("/\,|\ /", "\t", $head->newsgroups);
$ngroups = explode("\t", $ngroups); $ngroups = explode("\t", $ngroups);
// echo "&nbsp;"; // echo "&nbsp;";
foreach ($ngroups as $onegroup) { foreach ($ngroups as $onegroup) {
if ($s = get_section_by_group($onegroup)) { if ($s = get_section_by_group($onegroup)) {
echo '<a href="' . $file_thread . '?group=' . urlencode($onegroup) . '" title="Visit ' . $onegroup . '"> ' . $onegroup . " </a>"; echo '<a href="' . $file_thread . '?group=' . urlencode($onegroup) . '" title="Visit ' . $onegroup . '"> ' . $onegroup . " </a>";
} else { } else {
echo " ".$onegroup." "; echo " " . $onegroup . " ";
} }
} }
echo "<br />"; echo "<br />";
if (isset($head->followup) && ($article_show["Followup"]) && ($head->followup != "")) { if (isset($head->followup) && ($article_show["Followup"]) && ($head->followup != "")) {
echo $text_header["followup"] . htmlspecialchars($head->followup) . "<br>\n"; echo $text_header["followup"] . htmlspecialchars($head->followup) . "<br>\n";
} }
@ -585,7 +595,8 @@ function show_header_short($head, $group, $local_poster = false)
echo '</div>'; echo '</div>';
} }
function copy_messageid() { function copy_messageid()
{
$messageid = "THIS IS THE MSGID"; $messageid = "THIS IS THE MSGID";
return $messageid; return $messageid;
} }
@ -781,10 +792,12 @@ function message_show($group, $id, $attachment = 0, $article_data = false, $maxl
$xbmfile = $facefile . '.xbm'; $xbmfile = $facefile . '.xbm';
$uncompface = 'uncompface -X ' . $facefile . ' ' . $xbmfile; $uncompface = 'uncompface -X ' . $facefile . ' ' . $xbmfile;
shell_exec($uncompface); shell_exec($uncompface);
if (($xbm = imagecreatefromxbm($xbmfile)) !== false) { if (function_exists('imagecreatefromxbm')) {
imagepng($xbm, $pngfile); if (($xbm = imagecreatefromxbm($xbmfile)) !== false) {
imagedestroy($xbm); imagepng($xbm, $pngfile);
echo '<img align="right" src="' . $pngfile . '">'; imagedestroy($xbm);
echo '<img align="right" src="' . $pngfile . '">';
}
} }
unlink($facefile); unlink($facefile);
unlink($xbmfile); unlink($xbmfile);