//##############################################################################
//# yabbc.js #
//##############################################################################
//# YaBB: Yet another Bulletin Board #
//# Open-Source Community Software for Webmasters #
//# Version: YaBB 2.3.1 #
//# Packaged: January 04, 2009 #
//# Distributed by: http://www.yabbforum.com #
//# ===========================================================================#
//# Copyright (c) 2000-2009 YaBB (www.yabbforum.com) - All Rights Reserved. #
//# Software by: The YaBB Development Team #
//# with assistance from the YaBB community. #
//# Sponsored by: Xnull Internet Media, Inc. - http://www.ximinc.com #
//# Your source for web hosting, web design, and domains. #
//##############################################################################
//YaBB 2.3.1 $Revision: 1.5.2.8.2.4 $
var LivePrevDisplayNames = new Object();
function jsDoTohtml(tohtmlstr) {
tohtmlstr=tohtmlstr.replace(/\&/g, "&");
tohtmlstr=tohtmlstr.replace(/\"/g, """);
tohtmlstr=tohtmlstr.replace(/ /g, " ");
tohtmlstr=tohtmlstr.replace(/\|/g, "|");
tohtmlstr=tohtmlstr.replace(/\/g, ">");
return tohtmlstr
}
function jsDoUbbc(ubbcstr,codestrg,quotstrg,squotstrg,editxt,dspname,scriptul,imagesdir,smilieurl,parsflash,fontmax,fontmin,autolinkurls,month,timeselect,splittxt,dontusetoday,todaytext,yesterdaytext,timetxt1,timetxt2,timetxt3,timetxt4,jssmilieurl,jssmiliecode) {
ubbcstr=ubbcstr.replace(/\r/g, "");
ubbcstr=ubbcstr.replace(/\cM/g, "");
ubbcstr=ubbcstr.replace(/\[([^\]]{0,30})\n([^\]]{0,30})\]/g, '[$1$2]');
ubbcstr=ubbcstr.replace(/\[\/([^\]]{0,30})\n([^\]]{0,30})\]/g, '[/$1$2]');
ubbcstr=ubbcstr.replace(/(\w+:\/\/[^<>\s\n\"\]\[]+)\n([^<>\s\n\"\]\[]+)/g, '$1$2');
ubbcstr=ubbcstr.replace(/\&/g, "&");
ubbcstr=ubbcstr.replace(/\"/g, """);
ubbcstr=ubbcstr.replace(/ /g, " ");
ubbcstr=ubbcstr.replace(/\|/g, "|");
ubbcstr=ubbcstr.replace(/\$/g, "$");
ubbcstr=ubbcstr.replace(/\/g, ">");
ubbcstr=ubbcstr.replace(/\n/g, "
");
ubbcstr=ubbcstr.replace(/\[ch(\d{3,}?)\]/ig, "$1;");
ubbcstr=ubbcstr.replace(/\[code\]/ig, " [code]");
ubbcstr=ubbcstr.replace(/\[\/code\]/ig, " [/code]");
ubbcstr=ubbcstr.replace(/\[quote\]/ig, " [quote]");
ubbcstr=ubbcstr.replace(/\[\/quote\]/ig, " [/quote]");
ubbcstr=ubbcstr.replace(/\[glow\]/ig, " [glow]");
ubbcstr=ubbcstr.replace(/\[\/glow\]/ig, " [/glow]");
function codeConvStr() {
comessage='$1';
codestrg=codestrg.replace(/CODE/g, comessage);
return codestrg;
}
ubbcstr=ubbcstr.replace(/(\[code\]\n*(.+?)\n*\[\/code\])/ig, codeConvStr());
while( a=ubbcstr.match(/\[code\]\n*(.*?)\n*\[\/code\]/i) ) {
var cmessage=a[1];
linepatt = /\
/;
linecount = cmessage.split(linepatt);
if (linecount.length > 20) {
theight = " height: 300px; ";
} else {
theight = " ";
}
if(! cmessage.match(/\&\S*\;/g)) {
cmessage=cmessage.replace(/\;/g, ";"); }
cmessage=cmessage.replace(/\!/g, "!");
cmessage=cmessage.replace(/\(/g, "(");
cmessage=cmessage.replace(/\)/g, ")");
cmessage=cmessage.replace(/\-/g, "-");
cmessage=cmessage.replace(/\./g, ".");
cmessage=cmessage.replace(/\//g, "/");
cmessage=cmessage.replace(/\:/g, ":");
cmessage=cmessage.replace(/\?/g, "?");
cmessage=cmessage.replace(/\[/g, "[");
cmessage=cmessage.replace(/\/\//g, "\");
cmessage=cmessage.replace(/\]/g, "]");
cmessage=cmessage.replace(/\^/g, "^");
cmessage=cmessage.replace(/\&\#91\;highlight\&\#93\;(.*?)\&\#91\;\&\#47\;highlight\&\#93\;/ig, "$1");
cmessage=cmessage.replace(/\ \ \ /ig, "\t");
cmessage=cmessage.replace(/\ /ig, " ");
cmessage=cmessage.replace(/\n/ig, "[code_br]");
cmessage = "
"+cmessage+"[code_br][code_br]
";
ubbcstr=ubbcstr.replace(/\[code\]\n*(.*?)\n*\[\/code\]/i, cmessage);
}
if (!document.postmodify.ns.checked) {
ubbcstr=ubbcstr.replace(/\[smilie=(\S+\.)(gif|jpg|png|bmp)\]/g, "");
ubbcstr=ubbcstr.replace(/\[smiley=(\S+\.)(gif|jpg|png|bmp)\]/g, "");
ubbcstr=ubbcstr.replace(/(\W|^)\;\)/g, "$1");
ubbcstr=ubbcstr.replace(/(\W|^)\;\-\)/g, "$1");
ubbcstr=ubbcstr.replace(/(\W|^)\;D/g, "$1");
ubbcstr=ubbcstr.replace(/\:\'\(/g, "");
ubbcstr=ubbcstr.replace(/\:\-\//g, "");
ubbcstr=ubbcstr.replace(/\:\-X/g, "");
ubbcstr=ubbcstr.replace(/\:\-\[/g, "");
ubbcstr=ubbcstr.replace(/\:\-\*/g, "");
ubbcstr=ubbcstr.replace(/\>\;\:\(/g, "");
ubbcstr=ubbcstr.replace(/\:\:\)/g, "");
ubbcstr=ubbcstr.replace(/\:P/g, "");
ubbcstr=ubbcstr.replace(/\:\)/g, "");
ubbcstr=ubbcstr.replace(/\:\-\)/g, "");
ubbcstr=ubbcstr.replace(/\:D/g, "");
ubbcstr=ubbcstr.replace(/\:\-\(/g, "");
ubbcstr=ubbcstr.replace(/\:\(/g, "");
ubbcstr=ubbcstr.replace(/\:o/g, "");
ubbcstr=ubbcstr.replace(/8\-\)/g, "");
ubbcstr=ubbcstr.replace(/\:\-\?/g, "");
ubbcstr=ubbcstr.replace(/\^_\^/g, "");
ubbcstr=ubbcstr.replace(/\:thumb\:/g, "");
ubbcstr=ubbcstr.replace(/\>\;\:\-D/g, "");
for(var i=0; i");
}
}
ubbcstr=ubbcstr.replace(/\[([^\]]{0,30})\n([^\]]{0,30})\]/g, '[$1$2]');
ubbcstr=ubbcstr.replace(/\[\/([^\]]{0,30})\n([^\]]{0,30})\]/g, '[/$1$2]');
ubbcstr=ubbcstr.replace(/(\w+:\/\/[^<>\s\n\"\]\[]+)\n([^<>\s\n\"\]\[]+)/g, '$1\n$2');
ubbcstr=ubbcstr.replace(/\[b\](.+?)\[\/b\]/ig, "$1");
ubbcstr=ubbcstr.replace(/\[i\](.+?)\[\/i\]/ig, "$1");
ubbcstr=ubbcstr.replace(/\[u\](.+?)\[\/u\]/ig, "$1");
ubbcstr=ubbcstr.replace(/\[s\](.+?)\[\/s\]/ig, "$1");
ubbcstr=ubbcstr.replace(/\[move\](.+?)\[\/move\]/ig, "");
ubbcstr=ubbcstr.replace(/\[offtopic\](.+?)\[\/offtopic\]/ig, "");
ubbcstr=ubbcstr.replace(/\[spoiler\](.*?)\[\/spoiler\]/ig, "");
ubbcstr=ubbcstr.replace(/\[spoiler=([A-Za-z0-9# -,.]+)\](.*?)\[\/spoiler\]/ig, "");
ubbcstr=ubbcstr.replace(/\[color=(.+?)\](.+?)\[\/color\]/ig, "$2");
ubbcstr=ubbcstr.replace(/\[black\](.*?)\[\/black\]/ig, "$1");
ubbcstr=ubbcstr.replace(/\[white\](.*?)\[\/white\]/ig, "$1");
ubbcstr=ubbcstr.replace(/\[red\](.*?)\[\/red\]/ig, "$1");
ubbcstr=ubbcstr.replace(/\[green\](.*?)\[\/green\]/ig, "$1");
ubbcstr=ubbcstr.replace(/\[blue\](.*?)\[\/blue\]/ig, "$1");
function ltTen(number)
{
if (number < 10) number = '0' + number;
return number;
}
while ( c=ubbcstr.match(/\[timestamp=([\d]{9,10})\]/i) ) {
var tsdate=c[1];
tsdate=tsdate * 1000;
var tdate = new Date(tsdate);
var tyear = tdate.getYear();
var tsmonth = tdate.getMonth();
var tsday = tdate.getDate();
var daytxt = '';
if (!dontusetoday) {
var today = new Date();
var ytday = today.getTime();
ytday -= 86400000;
var yyday = new Date(ytday);
var ayear = today.getYear();
var amonth = today.getMonth();
var aday = today.getDate();
var yyear = yyday.getYear();
var ymonth = yyday.getMonth();
var yday = yyday.getDate();
if (tsday == aday && tsmonth == amonth && tyear == ayear) {
daytxt = "\" + todaytext + "\<\/b\> " + splittxt + ' ';
}
else if(tsday == yday && tsmonth == ymonth && tyear == yyear) {
daytxt = "\" + yesterdaytext + "\<\/b\> " + splittxt + ' ';
}
}
var tday = ltTen(tdate.getDate());
var tmonth = ltTen(tdate.getMonth()+1);
var tlmonth = month[tdate.getMonth()];
var tyear = tyear % 100;
var tlyear = tyear;
tyear = ltTen(tyear);
tlyear += (tlyear < 38) ? 2000 : 1900;
var thours = ltTen(tdate.getHours());
var tshours = tdate.getHours();
var ampm = 'am';
if (tshours > 11) ampm = 'pm';
if (tshours == 0) tshours = 12;
if (tshours > 12) tshours -= 12;
var tminutes = ltTen(tdate.getMinutes());
var tseconds = ltTen(tdate.getSeconds());
var tstr;
if (!daytxt) {
if(timeselect == 1) { daytxt = tmonth + '/' + tday + '/' + tyear + ' ' + splittxt + ' '; }
else if(timeselect == 2) { daytxt = tday + '.' + tmonth + '.' + tyear + ' ' + splittxt + ' '; }
else if(timeselect == 3) { daytxt = tday + '.' + tmonth + '.' + tlyear + ' ' + splittxt + ' '; }
else if(timeselect == 4) {
tsday += "\" + timetxt4 + "\<\/sup\>";
if (tsday > 10 && tsday < 20) {
tsday += "\" + timetxt4 + "\<\/sup\>";
}
else if (tsday % 10 == 1) {
tsday += "\" + timetxt1 + "\<\/sup\>";
}
else if (tsday % 10 == 2) {
tsday += "\" + timetxt2 + "\<\/sup\>";
}
else if (tsday % 10 == 3) {
tsday += "\" + timetxt3 + "\<\/sup\>";
}
daytxt = tlmonth + ' ' + tsday + ', ' + tlyear + ', ';
}
else if(timeselect == 5) { daytxt = tmonth + '/' + tday + '/' + tyear + ' ' + splittxt + ' '; }
else if(timeselect == 6) { daytxt = tday + '. ' + tlmonth + ' ' + tlyear + ' ' + splittxt + ' '; }
else if(timeselect == 7) { daytxt = tmonth + '/' + tday + '/' + tyear + ' ' + splittxt + ' '; }
}
if(timeselect == 1) { tstr = daytxt + thours + ':' + tminutes + ':' + tseconds; }
else if(timeselect == 2) { tstr = daytxt + thours + ':' + tminutes + ':' + tseconds; }
else if(timeselect == 3) { tstr = daytxt + thours + ':' + tminutes + ':' + tseconds; }
else if(timeselect == 4) { tstr = daytxt + tshours + ':' + tminutes + ampm; }
else if(timeselect == 5) { tstr = daytxt + tshours + ':' + tminutes + ampm; }
else if(timeselect == 6) { tstr = daytxt + thours + ':' + tminutes; }
else if(timeselect == 7) { tstr = daytxt + thours + ':' + tminutes + ':' + tseconds; }
ubbcstr=ubbcstr.replace(/\[timestamp=[\d]{9,10}\]/i, tstr);
}
ubbcstr=ubbcstr.replace(/\[highlight\](.*?)\[\/highlight\]/ig, "$1");
ubbcstr=ubbcstr.replace(/\[font=(.+?)\](.+?)\[\/font\]/ig, "$2");
function fontConvSize(tsize, ttext) {
var csize = parseInt(tsize);
if(csize < fontmin) csize = fontmin;
else if(csize > fontmax) csize = fontmax;
var resized = '' + ttext + '';
ubbcstr=ubbcstr.replace(/\[size=(\d+)\](.+?)\[\/size\]/i, resized);
}
while(fontsize=ubbcstr.match(/\[size=(\d+)\](.+?)\[\/size\]/i)) { fontConvSize(fontsize[1], fontsize[2]); }
ubbcstr=ubbcstr.replace(/\[yabbimg\](.+?)\[\/yabbimg\]/ig, '');
ubbcstr=ubbcstr.replace(/\[img\][\s*\t*\n*(\ \;)*(\ \;)*]*(https\:\/\/)(.+?)[\s*\t*\n*(\ \;)*(\ \;)*]*\[\/img\]/ig, '');
ubbcstr=ubbcstr.replace(/\[img\][\s*\t*\n*(\ \;)*(\ \;)*]*(http\:\/\/)*(.+?)[\s*\t*\n*(\ \;)*(\ \;)*]*\[\/img\]/ig, '');
function restrictimage(w,h,s) {
var maximgwidth = 400;
var maximgheight = 500;
if (w > maximgwidth) w = maximgwidth;
if (h > maximgheight) h = maximgheight;
var imgrest = '';
ubbcstr=ubbcstr.replace(/\[img width=(\d+) height=(\d+)\][\s*\t*\n*(\ \;)*(\ \;)*]*(http\:\/\/)*(.+?)[\s*\t*\n*(\ \;)*(\ \;)*]*\[\/img\]/i, imgrest);
}
while(picr=ubbcstr.match(/\[img width=(\d+) height=(\d+)\][\s*\t*\n*(\ \;)*(\ \;)*]*(http\:\/\/)*(.+?)[\s*\t*\n*(\ \;)*(\ \;)*]*\[\/img\]/i)) { restrictimage(picr[1],picr[2],'http://$4') }
ubbcstr=ubbcstr.replace(/\[tt\](.*?)\[\/tt\]/ig, "$1");
ubbcstr=ubbcstr.replace(/\[left\](.+?)\[\/left\]/ig, "$1
");
ubbcstr=ubbcstr.replace(/\[center\](.+?)\[\/center\]/ig, "$1");
ubbcstr=ubbcstr.replace(/\[right\](.+?)\[\/right\]/ig, "$1
");
ubbcstr=ubbcstr.replace(/\[sub\](.+?)\[\/sub\]/ig, "$1");
ubbcstr=ubbcstr.replace(/\[sup\](.+?)\[\/sup\]/ig, "$1");
ubbcstr=ubbcstr.replace(/\[fixed\](.+?)\[\/fixed\]/ig, "$1");
ubbcstr=ubbcstr.replace(/\[hr\]\n/ig, "
");
ubbcstr=ubbcstr.replace(/\[hr\]/ig, "
");
ubbcstr=ubbcstr.replace(/\[br\]/ig, "\n");
ubbcstr=ubbcstr.replace(/\[url\]\s*www\.(\S+?)\s*\[\/url\]/ig, "www.$1");
ubbcstr=ubbcstr.replace(/\[url=\s*(\S\w+\:\/\/\S+?)\s*\](.+?)\[\/url\]/ig, "$2");
ubbcstr=ubbcstr.replace(/\[url=\s*(\S+?)\](.+?)\s*\[\/url\]/ig, "$2");
ubbcstr=ubbcstr.replace(/\[url\]\s*(\S+?)\s*\[\/url\]/ig, "$1");
ubbcstr=ubbcstr.replace(/\[link\]\s*www\.(\S+?)\s*\[\/link\]/ig, "www.$1");
ubbcstr=ubbcstr.replace(/\[link=\s*(\S\w+\:\/\/\S+?)\s*\](.+?)\[\/link\]/ig, "$2");
ubbcstr=ubbcstr.replace(/\[link=\s*(\S+?)\](.+?)\s*\[\/link\]/ig, "$2");
ubbcstr=ubbcstr.replace(/\[link\]\s*(\S+?)\s*\[\/link\]/ig, "$1");
ubbcstr=ubbcstr.replace(/\[email\]\s*(\S+?\@\S+?)\s*\[\/email\]/ig, "$1");
ubbcstr=ubbcstr.replace(/\[email=\s*(\S+?\@\S+?)\](.*?)\[\/email\]/ig, "$2");
ubbcstr=ubbcstr.replace(/\[news\](\S+?)\[\/news\]/ig, '$1');
ubbcstr=ubbcstr.replace(/\[gopher\](\S+?)\[\/gopher\]/ig, '$1');
ubbcstr=ubbcstr.replace(/\[ftp\](\S+?)\[\/ftp\]/ig, '$1');
function squoteConv(nosqmessage, sqauthor, sqlink, sqdate, sqmessage) {
if ( !sqauthor || !sqlink || !sqdate ) stquotstrg = squotstrg;
else stquotstrg = quotstrg;
sqmessage=sqmessage.replace(/([\S]{80})/g, "$1
");
if ( sqauthor ) {
sqmessage=sqmessage.replace(/\/me\s+(.*?)(\
|$)(.*?)/ig, "* " + sqauthor + " $1$2$3");
} else {
sqmessage=sqmessage.replace(/\/me\s+(.*?)(\
|$)(.*?)/ig, "* " + dspname + " $1$2$3");
}
if (LivePrevDisplayNames[sqauthor]) sqauthor = LivePrevDisplayNames[sqauthor];
else sqauthor = post_txt_807;
stquotstrg=stquotstrg.replace(/AUTHOR/g, sqauthor);
stquotstrg=stquotstrg.replace(/QUOTELINK/g, scriptul+'?num='+sqlink+'" target="_blank');
stquotstrg=stquotstrg.replace(/DATE/g, sqdate);
stquotstrg=stquotstrg.replace(/QUOTE/g, sqmessage);
ubbcstr=ubbcstr.replace(/\[quote(\s+author=(.*?)\s+link=(.*?)\s+date=(.*?)\s*)?\]\n*(.+?)\n*\[\/quote\]/i, nosqmessage + stquotstrg);
}
function nstsquoteConv(nsqmessage) {
c=nsqmessage.match(/(.*)\[quote(\s+author=(.*?)\s+link=(.*?)\s+date=(.*?)\s*)?\]\n*(.+?)\n*\[\/quote\]/i);
squoteConv(c[1], c[3], c[4], c[5], c[6]);
}
while ( d=ubbcstr.match(/(\[quote(\s+author=(.*?)\s+link=(.*?)\s+date=(.*?)\s*)?\]\n*(.+?)\n*\[\/quote\])/i) ) {
nstsquoteConv(d[1]);
}
ubbcstr=ubbcstr.replace(/\/me\s+(.*?)(\
|$)/ig, "* " + dspname + " $1
");
function wrapstr(wraptext) {
wraptext=wraptext.replace(/([\S]{80})/g, "$1\n");
ubbcstr=ubbcstr.replace(/\[edit\]\n*(.+?)\n*\[\/edit\]/i, "" + editxt + ":
" + wraptext + "
");
}
while(longstrg=ubbcstr.match(/\[edit\](.+?)\[\/edit\]/i)) { wrapstr(longstrg[1]); }
ubbcstr=ubbcstr.replace(/\[\*\]/ig, "");
ubbcstr=ubbcstr.replace(/\[olist\]/ig, "");
ubbcstr=ubbcstr.replace(/\[\/olist\]/ig, "
");
ubbcstr=ubbcstr.replace(/\<\/li\>\/ig, "");
ubbcstr=ubbcstr.replace(/\\<\/li\>/ig, "");
ubbcstr=ubbcstr.replace(/\[\*\]/ig, "- ");
ubbcstr=ubbcstr.replace(/\[list\]/ig, "
");
ubbcstr=ubbcstr.replace(/\[\/list\]/ig, "
");
ubbcstr=ubbcstr.replace(/\<\/li\>\/ig, "");
ubbcstr=ubbcstr.replace(/\\<\/li\>/ig, "");
ubbcstr=ubbcstr.replace(/\[list\]/ig, "");
ubbcstr=ubbcstr.replace(/\[list (.+?)\]/ig, "");
ubbcstr=ubbcstr.replace(/\[\*\]/ig, "- ");
ubbcstr=ubbcstr.replace(/\[\/list\]/ig, "
");
function jsdopre(prestrg) {
prestrg=prestrg.replace(/\
/g, "\n");
ubbcstr=ubbcstr.replace(/\[pre\](.+?)\[\/pre\]/i, "
"+prestrg+"
");
}
while ( prestr=ubbcstr.match(/\[pre\](.+?)\[\/pre\]/i) ) { jsdopre(prestr[1]) }
while(fw=ubbcstr.match(/\[flash\=(\S+?),(\S+?)](\S+?)\[\/flash\]/)) {
if(parsflash == 1) {
var fwidth = fw[1];
var fheight = fw[2];
if (fwidth > 500) { fwidth = 500; }
if (fheight > 500) { fheight = 500; }
ubbcstr=ubbcstr.replace(/\[flash\=(\S+?),(\S+?)\](\S+?)\[\/flash\]/, '');
}
else {
ubbcstr=ubbcstr.replace(/\[flash\=(\S+?),(\S+?)\](\S+?)\[\/flash\]/, "Flash location ($1 x $2): $3");
}
}
if( ubbcstr.match(/\[table\](?:.*?)\[\/table\]/i) ) {
while( ubbcstr.match(/\