###############################################################################
# PostBox.pm #
# $Date: 01.09.2026 $ #
###############################################################################
# YaBB: Yet another Bulletin Board #
# Open-Source Community Software for Webmasters #
# Version: YaBBForum 3.1 #
# Packaged: 01 Sep, 2026 #
# Distributed by: https://yabbforum.nz #
# =========================================================================== #
# Copyright (c) 2000-2026 YaBB (yabbforum.nz) - All Rights Reserved. #
# Software by: The YaBB Development Team #
# with assistance from the YaBB community. #
###############################################################################
#use warnings;
#no warnings qw(uninitialized once redefine);
use CGI::Carp qw(fatalsToBrowser);
our $VERSION = '3.1';
$postboxpmver = 'YaBBForum 3.1';
if ( $action eq 'detailedversion' ) { return 1; }
get_micon();
#InstantMessage.pm and Post.pl use the same code for the posting box - why have two copies? #
sub postbox {
my %boxlist1 = (
'a' => "url.png|hyperlink()|$post_txt{'257'}",
'b' => "ftp.png|ftp()|$post_txt{'434'}",
'c' => "img.png|image()|$post_txt{'435'}",
'd' => "email2.png|emai1()|$post_txt{'258'}",
'e' => "media.png|flash()|$post_txt{'433'}",
'f' => "table.png|table()|$post_txt{'436'}",
'g' => "tr.png|trow()|$post_txt{'449'}",
'h' => "td.png|tcol()|$post_txt{'437'}",
'i' => "hr.png|hr()|$post_txt{'531'}",
'j' => "tele.png|teletype()|$post_txt{'440'}",
'k' => "code.png|selcodelang()|$post_txt{'259'}",
'l' => "quote2.png|quote()|$post_txt{'260'}",
'm' => "edit.png|edit()|$post_txt{'603'}",
'n' => "sup.png|superscript()|$post_txt{'447'}",
'o' => "sub.png|subscript()|$post_txt{'448'}",
'p' => "list.png|bulletset()|$post_txt{'261'}",
'q' => "me.png|me()|$post_txt{'604'}",
'r' => "move.png|move()|$post_txt{'439'}",
's' => "timestamp.png|timestamp($date)|$post_txt{'245'}",
't' => "noparse.png|noparse()|$post_txt{'noparse'}",
);
my %textdecor = (
'a' => "bold.png|bold()|$post_txt{'253'}",
'b' => "italicize.png|italicize()|$post_txt{'254'}",
'c' => "underline.png|underline()|$post_txt{'255'}",
'd' => "strike.png|strike()|$post_txt{'441'}",
'e' => "highlight.png|highlight()|$post_txt{'246'}",
);
my %txtalgn = (
'a' => "pre.png|pre()|$post_txt{'444'}",
'b' => "left.png|left()|$post_txt{'445'}",
'c' => "center.png|center()|$post_txt{'256'}",
'd' => "right.png|right()|$post_txt{'446'}",
);
my %mods = ();
## Mod Hook for UBBC ##
( $mods, $mods_w ) = ubbc_modlist(%mods);
( $boxlist1, $boxlist1_w ) = ubbc_boxlist(%boxlist1);
( $textdecor, $textdecor_w ) = ubbc_boxlist(%textdecor);
( $txtalgn, $txtalgn_w ) = ubbc_boxlist(%txtalgn);
$fntcolor_w = 68;
$font_w = $boxlist1_w - ( $textdecor_w + $txtalgn_w + $fntcolor_w + 25 );
$ubbc_box_w = $boxlist1_w + $mods_w;
$box = qq~
$mods
$boxlist1
~;
return $box;
}
sub postbox2 {
if ( !${ $uid . $username }{'postlayout'} ) {
$pheight = 130;
$pwidth = 448;
$textsize = 10;
}
else {
( $pheight, $pwidth, $textsize, $col_row ) =
split /\|/xsm, ${ $uid . $username }{'postlayout'};
}
$col_row ||= 0;
$textsize ||= 10;
$pheight ||= 130;
$pwidth ||= 448;
if ( $textsize < 6 ) { $textsize = 6; }
if ( $textsize > 16 ) { $textsize = 16; }
if ( $pheight > 400 ) { $pheight = 400; }
if ( $pheight < 130 ) { $pheight = 130; }
if ( $pwidth > 600 ) { $pwidth = 600; }
if ( $pwidth < 448 ) { $pwidth = 448; }
$mtextsize = $textsize . 'pt';
$mheight = $pheight . 'px';
$mwidth = $pwidth . 'px';
$dheight = ( $pheight + 12 ) . 'px';
$dwidth = ( $pwidth + 12 ) . 'px';
$jsdragwpos = $pwidth - 448;
$dragwpos = ( $pwidth - 448 ) . 'px';
$jsdraghpos = $pheight - 130;
$draghpos = ( $pheight - 130 ) . 'px';
if ( $INFO{'edit_cal_even'} ) { $message = q~{yabb calevent}~; }
$box = qq~
~;
if (!$replyguest) { $box .=
qq~
~;
}
$box .= qq~
~;
if ($action ne 'imsend' ) { $box .='
'; }
return $box;
}
sub postbox3 {
$box = qq~
~;
return $box;
}
sub smilies_list {
%smiley_bar = (
'a' => "smiley.gif|smiley()|$post_txt{'287'}",
'b' => "wink.gif|wink()|$post_txt{'292'}",
'c' => "cheesy.gif|cheesy()|$post_txt{'289'}",
'd' => "grin.gif|grin()|$post_txt{'293'}",
'e' => "angry.gif|angry()|$post_txt{'288'}",
'f' => "sad.gif|sad()|$post_txt{'291'}",
'g' => "shocked.gif|shocked()|$post_txt{'294'}",
'h' => "cool.gif|cool()|$post_txt{'295'}",
'i' => "huh.gif|huh()|$post_txt{'296'}",
'j' => "rolleyes.gif|rolleyes()|$post_txt{'450'}",
'k' => "tongue.gif|tongue()|$post_txt{'451'}",
'l' => "embarassed.gif|embarassed()|$post_txt{'526'}",
'm' => "lipsrsealed.gif|lipsrsealed()|$post_txt{'527'}",
'n' => "undecided.gif|undecided()|$post_txt{'528'}",
'o' => "kiss.gif|kiss()|$post_txt{'529'}",
'p' => "cry.gif|cry()|$post_txt{'530'}",
);
my $hand = q~class='bottom cursor' style='margin:1px;'~;
my $smilies_list = q{};
for my $i ( sort keys %smiley_bar ) {
my ($img, $click, $alt) = split /[|]/xsm, $smiley_bar{$i};
$smilies_list .= qq~
\n~;
}
$smilies_list .= $moresmilieslist;
return $smilies_list;
}
sub attach {
# File Attachment's Browse Box Code
$mfn = $mfn || $FORM{'oldattach'};
my @files = split /,/xsm, $mfn;
$yymain .= qq~
$fatxt{'80'}
~;
$allowattach ||= 0;
if ( $allowattach > 1 ) {
$yymain .= qq~
~;
}
$yymain .= qq~
|
$filetype_info $filesize_info |
| ~;
my $startcount;
for my $y ( 1 .. $allowattach ) {
if ( ( $action eq 'modify' || $action eq 'modify2' )
&& $files[ $y - 1 ] ne q{}
&& -e "$uploaddir/$files[$y-1]" )
{
$startcount++;
$yymain .= qq~
$fatxt{'6'} $y:
~;
}
else {
$yymain .= qq~
1 ? q~ style="visibility:hidden; height:0px"~ : q{} )
. qq~>$fatxt{'6'} $y:
1 ? q~ style="visibility:hidden; height:0px"~ : q{} )
. qq~>\n X ~;
}
}
if ( !$startcount ) { $startcount = 1; }
if ( $allowattach > 1 ) {
$yymain .= qq~
~;
}
$yymain .= q~
|
~;
return;
}
sub speedpost {
$speedpost = qq~
var postdelay = $min_post_speed*1000;
document.postmodify.$post.value = '$post_txt{"delay"}';
document.postmodify.$post.disabled = true;
document.postmodify.$post.style.cursor = 'default';
var delay = window.setInterval('releasepost()',postdelay);
function releasepost() {
document.postmodify.$post.value = '$submittxt';
document.postmodify.$post.disabled = false;
document.postmodify.$post.style.cursor = 'pointer';
window.clearInterval(delay);
}
~;
return $speedpost;
}
sub my_check_prev {
$checkallcaps ||= 0;
$x = qq~
~;
return $x;
}
sub my_liveprev {
$x =
qq~var noalert = true, gralert = false, rdalert = false, clalert = false;
var cntsec = 0;
function tick() {
cntsec++;
var timerID = setTimeout("tick()",1000);
}
var autoprev = false;
post_txt_807 = "$post_txt{'807'}";
function enabPrev() {
if ( autoprev === false ) {
autoprev = true;~;
if ( $my_ajxcall eq 'ajximmessage' ) {
$x .= q~document.getElementById("SaveInfo").style.display = "block";
document.getElementById("saveframe").style.display = "block";~;
}
else {
$x .= q~document.getElementById("savetable").style.display = "block";~;
}
$x .= qq~
document.images.prevwin.alt = "$npf_txt{'02'}";
document.images.prevwin.title = "$npf_txt{'02'}";
document.images.prevwin.src="$imagesdir/$cat_col";
autoPreview();
}
else {
autoprev = false;
ubbstr = '';~;
if ( $my_ajxcall eq 'ajximmessage' ) {
$x .= q~document.getElementById("SaveInfo").style.display = "none";
document.getElementById("saveframe").style.display = "none";~;
}
else {
$x .= q~document.getElementById("savetable").style.display = "none";~;
}
$x .= qq~
document.postmodify.message.focus();
document.images.prevwin.alt = "$npf_txt{'01'}";
document.images.prevwin.title = "$npf_txt{'01'}";
document.images.prevwin.src="$defaultimagesdir/$cat_exp";
}
}
function calcCharLeft() {
var clipped = false;
var maxLength = $MaxMessLen;
if (document.postmodify.message.value.length > maxLength) {
document.postmodify.message.value = document.postmodify.message.value.substring(0,maxLength);
var charleft = 0;
clipped = true;
} else {
charleft = maxLength - document.postmodify.message.value.length;
}
document.postmodify.msgCL.value = charleft;
if (charleft >= 100 && noalert) { noalert = false; gralert = true; rdalert = true; clalert = true; document.images.chrwarn.src="$chrwarn{'g1'}"; }
if (charleft < 100 && charleft >= 50 && gralert) { noalert = true; gralert = false; rdalert = true; clalert = true; document.images.chrwarn.src="$chrwarn{'g0'}"; }
if (charleft < 50 && charleft > 0 && rdalert) { noalert = true; gralert = true; rdalert = false; clalert = true; document.images.chrwarn.src="$chrwarn{'r0'}"; }
if (charleft === 0 && clalert) { noalert = true; gralert = true; rdalert = true; clalert = false; document.images.chrwarn.src="$chrwarn{'r1'}"; }
return clipped;
}
function autoPreview() {
calcCharLeft();
if(autoprev) {
var url = '$scripturl?action=$my_ajxcall';
try {
if (typeof( new XMLHttpRequest() ) == 'object') {
pstHttp = new XMLHttpRequest();
} else if (typeof( new ActiveXObject("Msxml2.XMLHTTP") ) == 'object') {
pstHttp = new ActiveXObject("Msxml2.XMLHTTP");
} else if (typeof( new ActiveXObject("Microsoft.XMLHTTP") ) == 'object') {
pstHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
} catch (e) { }
if (pstHttp == null) return;
pstHttp.onreadystatechange = function() {
if(pstHttp.readyState == 4) {
if(pstHttp.status == 200 || window.location.href.indexOf("http") == -1) {~;
if ( $my_ajxcall eq 'ajximmessage' ) {
$x .= q~
document.getElementById("saveframe").innerHTML = pstHttp.responseText;
sh_highlightDocument();
if (/post_liveimg_resize_1/i.test(pstHttp.responseText)) LivePrevImgResize();~;
}
else {
$x .= q~ tmpmess = pstHttp.responseText.split("|");~;
if ( $my_ajxcall eq 'ajxmessage' ) {
$x .= q~
document.getElementById("savesubj").innerHTML = tmpmess[0];
document.getElementById("savemess").innerHTML = tmpmess[1];~;
if ($iamguest) {
$x .= q~
document.getElementById("savename").innerHTML = tmpmess[2];~;
}
}
elsif ( $my_ajxcall eq 'ajxcal' ) {
$x .= q~
document.getElementById("savemess").innerHTML = tmpmess[0];~;
if ($iamguest) {
$x .= q~
document.getElementById("savename").innerHTML = tmpmess[1];~;
}
$x .= q~
document.getElementById("cdate").innerHTML = tmpmess[2];
document.getElementById("ev_title").innerHTML = tmpmess[3];
document.getElementById("ev_private").innerHTML = tmpmess[4];~;
}
$x .= q~
sh_highlightDocument();
if (/post_liveimg_resize_1/i.test(pstHttp.responseText)) LivePrevImgResize();
checkLivepreview();
~;
}
$x .= q~
}
}
};
var nscheck = 0;
var isprev = 1;
if(document.getElementById("ns").checked) nscheck = 1;~;
if ( $my_ajxcall ne 'ajxcal' ) {
$x .= q~
var subjvalue = encodeURIComponent(document.getElementById("subject").value);~;
}
$x .= q~
var messvalue = encodeURIComponent(document.getElementById("message").value);
var sessvalue = encodeURIComponent(document.postmodify.formsession.value);
~;
if ($iamguest) {
$x .= q~
var namevalue = encodeURIComponent(document.getElementById("name").value);
~;
}
else {
$x .= q~
var namevalue = "";
~;
}
if ( $my_ajxcall eq 'ajxmessage' ) {
$x .= qq~
var tmusername = encodeURIComponent('$displayname');
sessvalue = encodeURIComponent(document.postmodify.formsession.value);
var parameters = "subject="+subjvalue+"&message="+messvalue+"&musername="+tmusername+"&nschecked="+nscheck+"&formsession="+sessvalue+"&guestname="+namevalue+"&isprev="+isprev;
pstHttp.open("POST", url, true);
pstHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
pstHttp.send(parameters);~;
}
elsif ( $my_ajxcall eq 'ajxcal' ) {
$x .= qq~
var calmonvalue = encodeURIComponent(document.postmodify.selmon.options[document.postmodify.selmon.selectedIndex].value);
var caldayvalue = encodeURIComponent(document.postmodify.selday.options[document.postmodify.selday.selectedIndex].value);
var calyearvalue = encodeURIComponent(document.postmodify.selyear.options[document.postmodify.selyear.selectedIndex].value);
var cal_icon_txt = encodeURIComponent(document.postmodify.calicon.options[document.postmodify.calicon.selectedIndex].value);
var cal_type = encodeURIComponent(document.postmodify.caltype.options[document.postmodify.caltype.selectedIndex].value);
var tmusername = encodeURIComponent('$displayname');
var parameters = "&message="+messvalue+"&musername="+tmusername+"&nschecked="+nscheck+"&formsession="+sessvalue+"&guestname="+namevalue+"&cal_mon="+calmonvalue+"&cal_day="+caldayvalue+"&cal_year="+calyearvalue+"&icon_txt="+cal_icon_txt+"&cal_type="+cal_type+"&isprev="+isprev;
pstHttp.open("POST", url, true);
pstHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
pstHttp.send(parameters);~;
}
elsif ( $my_ajxcall eq 'ajximmessage' ) {
$x .= q~
var iconvalue = encodeURIComponent(document.getElementById("iconholder").value);
var parameters = "message="+messvalue+"&icon="+iconvalue+"&subject="+subjvalue+"&nschecked="+nscheck+"&formsession="+sessvalue+"&isprev="+isprev;
pstHttp.open("POST", url, true);
pstHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
pstHttp.send(parameters);~;
}
$x .= qq~
}
}
function LivePrevImgResize() {
var maxwidth = $max_post_img_width;
var maxheight = $max_post_img_height;
var fix_size = $fix_post_img_size;
noimgdir = '$imagesdir';
noimgtitle = '$maintxt{'171'}';
var liveimg_resize_names = new Array ();
var zi = 0;
var imgsavail = document.getElementById("savemess").getElementsByTagName("img");
for (i=0; i maxwidth) {
tmpheight = tmpheight * maxwidth / tmpwidth;
tmpwidth = maxwidth;
}
if (maxheight !== 0 && tmpheight > maxheight) {
tmpwidth = tmpwidth * maxheight / tmpheight;
tmpheight = maxheight;
}
document.images[tmp_image_name].width = tmpwidth;
document.images[tmp_image_name].height = tmpheight;
document.images[tmp_image_name].style.display = 'inline';
}
if (tmp_array.length > 0 && resize_time < 350) {
liveimg_resize_names = tmp_array;
if (resize_time == 290) {
for (var i = 0; i < liveimg_resize_names.length; i++) {
var tmp_image_name = liveimg_resize_names[i];
document.images[tmp_image_name].src = noimgdir + "/noimg.gif";
document.images[tmp_image_name].title = noimgtitle;
}
}
setTimeout("resize_time++; resize_images();", 100);
}
}
tick();
~;
return $x;
}
sub ubbc_boxlist {
my %list = @_;
my $hand = q~class='vtop cursor' style='height:22px; width:23px;' onmouseover='contextTip(event, this.alt);' onmouseout='contextTip(event, this.alt);' oncontextmenu='if(!showcontexthelp(this.src, this.alt)) return false;'~;
my $boxlist = q{};
my $w = 0;
for my $i ( sort keys %list ) {
my ($img, $click, $alt) = split /[|]/xsm, $list{$i};
$boxlist .= qq~
\n~;
$w++
}
$boxlist_w = $w * 24;
return ($boxlist, $boxlist_w);
}
sub ubbc_modlist {
my %list = @_;
my $hand = q~class='vtop cursor' style='height:22px; width:23px;' onmouseover='contextTip(event, this.alt);' onmouseout='contextTip(event, this.alt);' oncontextmenu='if(!showcontexthelp(this.src, this.alt)) return false;'~;
my $boxlist = q{};
my $w = 0;
for my $i ( sort keys %list ) {
my ($img, $click, $alt) = split /[|]/xsm, $list{$i};
$boxlist .= qq~
\n~;
$w++
}
my $mod_w = 0;
if ( $w % 2 == 0 ) {
$mod_w = $w/2;
}
else {
$mod_w = 1 + int $w/2;
}
$boxlist_w = $mod_w * 24;
return ($boxlist, $boxlist_w);
}
1;