############################################################################### # PostBox.pm # # $Date$ ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Community Software for Webmasters # # Version: YaBB 2.5.4 # # Packaged: July 1, 2013 # # Distributed by: http://www.yabbforum.com # # =========================================================================== # # Copyright (c) 2000-2013 YaBB (www.yabbforum.com) - 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 = '2.5.4'; $postboxpmver = 'YaBB 2.5.4 $Revision$'; if ( defined $actions && $action eq 'detailedversion' ) { return 1; } #InstantMessage.pm and Post.pl use the same code for the posting box - why have two copies? # sub postbox { $box = qq~
                       
~; 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; if ( !$textsize || $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~
resize_wb
resize_hb







$npf_txt{'03'} $MaxMessLen $npf_txt{'03a'}
$post_txt{'textsize'} pt
~; return $box; } sub postbox3 { $box = qq~ ~; return $box; } sub googiea { $googiea = qq~ ~; return $googiea; } sub googie { my ($userdefaultlang) = @_; $googie = qq~ ~; return $googie; } sub smilies_list { $smilies_list = qq~ HAND = 'class="bottom cursor"'; document.write("$post_txt{ "); document.write("$post_txt{ "); document.write("$post_txt{ "); document.write("$post_txt{ "); document.write("$post_txt{ "); document.write("$post_txt{ "); document.write("$post_txt{ "); document.write("$post_txt{ "); document.write("$post_txt{ "); document.write("$post_txt{ "); document.write("$post_txt{ "); document.write("$post_txt{ "); document.write("$post_txt{ "); document.write("$post_txt{ "); document.write("$post_txt{ "); document.write("$post_txt{ "); ~; return $smilies_list; } sub attach { # File Attachment's Browse Box Code $mfn = $mfn || $FORM{'oldattach'}; my @files = split /,/xsm, $mfn; $yymain .= qq~ $fatxt{'80'} ~; if ( $allowattach > 1 ) { $yymain .= qq~ $fatxt{'80a'} ~; } $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:
X
 $fatxt{'40'}: $files[$y-1]
~; } 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 ( $is_preview == 1 && $CGI_query->upload("file$y") ) { $is_preview = 2; } } if ( !$startcount ) { $startcount = 1; } if ( $allowattach > 1 ) { $yymain .= qq~ ~; } $yymain .= q~ ~; if ( $is_preview == 2 ) { $is_preview = 1; $yymain .= qq~
$fatxt{'7'}

~; } 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 { $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="$defaultimagesdir/$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="$defaultimagesdir/$chrwarn_g1"; } if (charleft < 100 && charleft >= 50 && gralert) { noalert = true; gralert = false; rdalert = true; clalert = true; document.images.chrwarn.src="$defaultimagesdir/$chrwarn_g0"; } if (charleft < 50 && charleft > 0 && rdalert) { noalert = true; gralert = true; rdalert = false; clalert = true; document.images.chrwarn.src="$defaultimagesdir/$chrwarn_r0" } if (charleft === 0 && clalert) { noalert = true; gralert = true; rdalert = true; clalert = false; document.images.chrwarn.src="$defaultimagesdir/$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; 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; 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; 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; 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; } 1;