############################################################################### # Printpage.pl # ############################################################################### # YaBB: Yet another Bulletin Board # # Open-Source Community Software for Webmasters # # Version: YaBB 3.0 Beta # # Packaged: October 05, 2010 # # Distributed by: http://www.yabbforum.com # # =========================================================================== # # Copyright (c) 2000-2010 YaBB (www.yabbforum.com) - All Rights Reserved. # # Software by: The YaBB Development Team # # with assistance from the YaBB community. # ############################################################################### $printpageplver = 'YaBB 3.0 Beta $Revision: 328 $'; if ($action eq 'detailedversion') { return 1; } sub Print_IM { my (@threads,$boxtitle,$type); if ($INFO{'caller'} == 1) { @threads = &read_DBorFILE(0,'',$memberdir,$username,'msg'); $boxtitle = $maintxt{'316'}; $type = $maintxt{'318'}; } elsif ($INFO{'caller'} == 2) { @threads = &read_DBorFILE(0,'',$memberdir,$username,'outbox'); $boxtitle = $maintxt{'320'}; $type = $maintxt{'324'}; } else { @threads = &read_DBorFILE(0,'',$memberdir,$username,'imstore'); $boxtitle = $load_imtxt{'46'}; $type = "$maintxt{'318'}/$maintxt{'324'}"; } ### Lets output all that info. ### $output = qq~ $mbname - $maintxt{'668'}
$mbname
$scripturl
$load_imtxt{'71'} $boxtitle $maintxt{'30'} $date

~; # Split the threads up so we can print them. foreach $thread (@threads) { ($threadposter, $threadtitle, $threaddate, $threadpost, undef) = split(/\|/, $thread); &do_print; $output .= qq~
$maintxt{'70'}: $threadtitle
$type $threadposter $maintxt{'30'} $threaddate
$threadpost

~; } $output .= qq~
$yycopyright
~; &image_resize; &print_output_header; &print_HTML_output_and_finish; } sub Print { $num = $INFO{'num'}; # Determine category $curcat = ${$uid.$currentboard}{'cat'}; &MessageTotals("load", $num); my $ishidden; if (${$num}{'threadstatus'} =~ /h/i) { $ishidden = 1; } if ($ishidden && !$staff) { &fatal_error("no_access"); } # Figure out the name of the category &get_forum_master; ($cat, $catperms) = split(/\|/, $catinfo{"$curcat"}); ($boardname, $boardperms, $boardview) = split(/\|/, $board{"$currentboard"}); &ToChars($boardname); &LoadCensorList; # Lets open up the thread file itself unless (ref($thread_arrayref{$num})) { &donoopen if !(@{$thread_arrayref{$num}} = &read_DBorFILE(1,'',$datadir,$num,'txt')); } &ToChars($cat); $cat =~ s/\n//g; ($messagetitle, $poster_realname, undef, $date, $poster_username) = split(/\|/, ${$thread_arrayref{$num}}[0]); if (&checkfor_DBorFILE("$memberdir/$poster_username.vars")) { &LoadUser($poster_username); $poster_realname = ${$uid.$poster_username}{'realname'}; } $startedby = $poster_realname; $startedon = timeformat($date, 1); &ToChars($messagetitle); ($messagetitle, undef) = &Split_Splice_Move($messagetitle,0); ### Lets output all that info. ### $output = qq~ $mbname - $maintxt{'668'}
$mbname
$scripturl
$cat >> $boardname >> $messagetitle
$scripturl?num=$num

$maintxt{'195'} $startedby $maintxt{'30'} $startedon

~; &LoadLanguage('FA'); # Split the threads up so we can print them. foreach $thread (@{$thread_arrayref{$num}}) { ($threadtitle, $threadposter_realname, undef, $threaddate, $threadposter_username, undef, undef, undef, $threadpost, undef, undef, undef, $attachments) = split(/\|/, $thread); if (&checkfor_DBorFILE("$memberdir/$threadposter_username.vars")) { &LoadUser($threadposter_username); $threadposter_realname = ${$uid.$threadposter_username}{'realname'}; } ($threadtitle, undef) = &Split_Splice_Move($threadtitle,0); ($threadpost, undef) = &Split_Splice_Move($threadpost,$num); &do_print; $output .= qq~
$maintxt{'196'}: $threadtitle
$maintxt{'197'} $threadposter_realname $maintxt{'30'} $threaddate
$threadpost~; chomp $attachments; if ($attachments) { # store all downloadcounts in variable if (!%attach_count) { my ($atfile,$atcount); foreach (&read_DBorFILE(1,'',$vardir,'attachments','txt')) { (undef, undef, undef, undef, undef, undef, undef, $atfile, $atcount) =split(/\|/, $_); $attach_count{$atfile} = $atcount; } $attach_count{'no_attachments'} = 1 if !%attach_count; } my $attachment = ''; my $showattach = ''; foreach (split(/,/, $attachments)) { $_ =~ /\.(.+?)$/; my $ext = lc($1); unless (exists $attach_gif{$ext}) { $attach_gif{$ext} = ($ext && -e "$forumstylesdir/$useimages/$ext.gif") ? "$ext.gif" : "paperclip.gif"; } my $filesize = -s "$uploaddir/$_"; if ($filesize) { if ($_ =~ /\.(bmp|jpe|jpg|jpeg|gif|png)$/i && $amdisplaypics == 1) { $imagecount++; $showattach .= qq~
$_ (~ . int($filesize / 1024) . qq~ KB | $attach_count{$_} )
\n~; } else { $attachment .= qq~
$scripturl?action=downloadfile;file=$_ (~ . int($filesize / 1024) . qq~ KB | $attach_count{$_} )
~; } } else { $attachment .= qq~
$_ ($fatxt{'1'}~ . (exists $attach_count{$_} ? qq~ | $attach_count{$_} ~ : '') . qq~)
~; } } if ($showattach && $attachment) { $attachment =~ s/
/
/g; } $output .= qq~
$attachment $showattach~; } $output .= qq~

~; } $output .= qq~
$yycopyright
~; &image_resize; &print_output_header; &print_HTML_output_and_finish; } sub sizefont { # limit minimum and maximum font pitch as CSS does not restrict it at all. my ($tsize, $ttext) = @_; if (!$fontsizemax) { $fontsizemax = 72; } if (!$fontsizemin) { $fontsizemin = 6; } if ($tsize < $fontsizemin) { $tsize = $fontsizemin; } elsif ($tsize > $fontsizemax) { $tsize = $fontsizemax; } my $resized = qq~$ttext~; return $resized; } { my %killhash = ( ';' => ';', '!' => '!', '(' => '(', ')' => ')', '-' => '-', '.' => '.', '/' => '/', ':' => ':', '?' => '?', '[' => '[', '\\' => '\', ']' => ']', '^' => '^'); sub codemsg { my $code = $_[0]; if ($code !~ /&\S*;/) { $code =~ s/;/;/g; } $code =~ s~([\(\)\-\:\\\/\?\!\]\[\.\^])~$killhash{$1}~g; $_ = qq~
Code:
CODE
~; $_ =~ s~CODE~$code~g; return $_; } } sub donoopen { print qq~Content-Type: text/html\r\n\r\n $maintxt{'199'}
$maintxt{'199'}
~; exit; } sub do_print { $threadpost =~ s~
~\n~ig; $threadpost =~ s~\[highlight(.*?)\](.*?)\[/highlight\]~$2~isg; $threadpost =~ s~\[code\]\n*(.+?)\n*\[/code\]~
Code:
$1
~isg; $threadpost =~ s~\[code\s*(.+?)\]\n*(.+?)\n*\[/code\]~
Code ($1):
$2
~isg; $threadpost =~ s~\[([^\]]{0,30})\n([^\]]{0,30})\]~\[$1$2\]~g; $threadpost =~ s~\[/([^\]]{0,30})\n([^\]]{0,30})\]~\[/$1$2\]~g; $threadpost =~ s~(\w+://[^<>\s\n\"\]\[]+)\n([^<>\s\n\"\]\[]+)~$1\n$2~g; $threadpost =~ s~\[b\](.*?)\[/b\]~$1~isg; $threadpost =~ s~\[i\](.*?)\[/i\]~$1~isg; $threadpost =~ s~\[u\](.*?)\[/u\]~$1~isg; $threadpost =~ s~\[s\](.*?)\[/s\]~$1~isg; $threadpost =~ s~\[move\](.*?)\[/move\]~$1~isg; $threadpost =~ s~\[glow(.*?)\](.*?)\[/glow\]~&elimnests($2)~eisg; $threadpost =~ s~\[shadow(.*?)\](.*?)\[/shadow\]~&elimnests($2)~eisg; $threadpost =~ s~\[shadow=(\S+?),(.+?),(.+?)\](.+?)\[/shadow\]~$4~eisg; $threadpost =~ s~\[glow=(\S+?),(.+?),(.+?)\](.+?)\[/glow\]~$4~eisg; $threadpost =~ s~\[color=([\w#]+)\](.*?)\[/color\]~$2~isg; $threadpost =~ s~\[black\](.*?)\[/black\]~$1~isg; $threadpost =~ s~\[white\](.*?)\[/white\]~$1~isg; $threadpost =~ s~\[red\](.*?)\[/red\]~$1~isg; $threadpost =~ s~\[green\](.*?)\[/green\]~$1~isg; $threadpost =~ s~\[blue\](.*?)\[/blue\]~$1~isg; $threadpost =~ s~\[font=(.+?)\](.+?)\[/font\]~$2~isg; while ($threadpost =~ s~\[size=(.+?)\](.+?)\[/size\]~&sizefont($1,$2)~eisg) { } $threadpost =~ s~\[quote\s+author=(.*?)\s+link=(.*?)\].*\/me\s+(.*?)\[\/quote\]~\[quote author=$1 link=$2\]* $1 $3\[/quote\]~isg; $threadpost =~ s~\[quote(.*?)\].*\/me\s+(.*?)\[\/quote\]~\[quote$1\]* Me $2\[/quote\]~isg; $threadpost =~ s~\/me\s+(.*)~* $displayname $1~ig; # Images in message $threadpost =~ s~\[img(.*?)\](.*?)\[/img\]~ &imagemsg($1,$2) ~eisg; sub imagemsg { # out of YaBBC.pl -> sub imagemsg { my($attribut,$url) = @_; # use or kill urls $url =~ s~\[url\](.*?)\[/url\]~$1~ig; $url =~ s~\[link\](.*?)\[/link\]~$1~ig; $url =~ s~\[url\s*=\s*(.*?)\s*.*?\].*?\[/url\]~$1~ig; $url =~ s~\[link\s*=\s*(.*?)\s*.*?\].*?\[/link\]~$1~ig; $url =~ s~\[url.*?/url\]~~ig; $url =~ s~\[link.*?/link\]~~ig; my $char_160 = chr(160); $url =~ s/(\s| |$char_160)+//g; if ($url !~ /^http.+?\.(gif|jpg|jpeg|png|bmp)$/i) {return ' ' . $url;} my %parameter; &FromHTML($attribut); $attribut =~ s/(\s|$char_160)+/ /g; foreach (split(/ +/, $attribut)) { my ($key, $value) = split(/=/, $_); $value =~ s/["']//g; $parameter{$key} = $value; } $parameter{'name'} = 'post_img_resize' if $parameter{'name'} ne 'signat_img_resize'; &ToHTML($parameter{'alt'}); $parameter{'align'} =~ s~[^a-z]~~ig; $parameter{'width'} =~ s~\D~~g; $parameter{'height'} =~ s~\D~~g; if ($parameter{'align'}) { $parameter{'align'} = qq~ align="$parameter{'align'}"~; } if ($parameter{'width'}) { $parameter{'width'} = qq~ width="$parameter{'width'}"~; } if ($parameter{'height'}) { $parameter{'height'} = qq~ height="$parameter{'height'}"~; } $imagecount++; qq~ ~; } $threadpost =~ s~\[tt\](.*?)\[/tt\]~$1~isg; $threadpost =~ s~\[left\](.*?)\[/left\]~
$1
~isg; $threadpost =~ s~\[center\](.*?)\[/center\]~
$1
~isg; $threadpost =~ s~\[right\](.*?)\[/right\]~
$1
~isg; $threadpost =~ s~\[justify\](.*?)\[/justify\]~
$1
~isg; $threadpost =~ s~\[sub\](.*?)\[/sub\]~$1~isg; $threadpost =~ s~\[sup\](.*?)\[/sup\]~$1~isg; $threadpost =~ s~\[fixed\](.*?)\[/fixed\]~$1~isg; $threadpost =~ s~\[\[~\{\{~g; $threadpost =~ s~\]\]~\}\}~g; $threadpost =~ s~\|~\|~g; $threadpost =~ s~\[hr\]\n~
~g; $threadpost =~ s~\[hr\]~
~g; $threadpost =~ s~\[br\]~\n~ig; $threadpost =~ s~\[flash\](.*?)\[/flash\]~\[media\]$1\[/media\]~isg; sub format_url { my ($txtfirst, $txturl) = @_; my $lasttxt = ""; if ($txturl =~ m~(.*?)(\.|\.\)|\)\.|\!|\!\)|\)\!|\,|\)\,|\)|\;|\"\;|\"\;\.|\.\"\;|\"\;\,|\,\"\;|\"\;\;|\<\/)\Z~) { $txturl = $1; $lasttxt = $2; } my $realurl = $txturl; $txturl =~ s~(\[highlight\]|\[\/highlight\]|\[edit\]|\[\/edit\])~~ig; $txturl =~ s~\[~[~g; $txturl =~ s~\]~]~g; $txturl =~ s~\<.+?\>~~ig; my $formaturl = qq~$txtfirst\[url\=$txturl\]$realurl\[\/url\]$lasttxt~; return $formaturl; } sub format_url2 { my ($txturl, $txtlink) = @_; $txturl =~ s~(\[highlight\]|\[\/highlight\]|\[edit\]|\[\/edit\])~~ig; $txturl =~ s~\<.+?\>~~ig; my $formaturl = qq~\[url\=$txturl\]$txtlink\[\/url\]~; return $formaturl; } sub format_url3 { my $txturl = $_[0]; my $txtlink = $txturl; $txturl =~ s~(\[highlight\]|\[\/highlight\]|\[edit\]|\[\/edit\])~~ig; $txturl =~ s~\[~[~g; $txturl =~ s~\]~]~g; $txturl =~ s~\<.+?\>~~ig; my $formaturl = qq~\[url\=$txturl\]$txtlink\[\/url\]~; return $formaturl; } $threadpost =~ s~\[url=\s*(.+?)\s*\]\s*(.+?)\s*\[/url\]~&format_url2($1, $2)~eisg; $threadpost =~ s~\[url\]\s*(\S+?)\s*\[/url\]~&format_url3($1)~eisg; if ($autolinkurls) { $threadpost =~ s~\[url\]\s*([^\[]+)\s*\[/url\]~[url]$1\[/url]~g; $threadpost =~ s~\[link\]\s*([^\[]+)\s*\[/link\]~[link]$1\[/link]~g; $threadpost =~ s~\[news\](\S+?)\[/news\]~$1~isg; $threadpost =~ s~\[gopher\](\S+?)\[/gopher\]~$1~isg; $threadpost =~ s~">~">~g; #" $threadpost =~ s~(\[\*\])~ $1~g; $threadpost =~ s~(\[\/list\])~ $1~g; $threadpost =~ s~(\[\/td\])~ $1~g; $threadpost =~ s~(\[\/td\])~ $1~g; $threadpost =~ s~\\S+?\<\/\S+?\>)]+?)\.(?:[\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\[\]\x80-\xFF]{1,})+?)~&format_url($1,$2)~eisg; $threadpost =~ s~([^\"\=\[\]/\:\.(\://\w+)]|[\n\b]|\"\;|\[quote.*?\]|\[edit\]|\[highlight\]|\[\*\]|\[td\]|\A|\()\\*(www\.[^\.](?:[\w\~\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\[\](?:\<\S+?\>\S+?\<\/\S+?\>)]+?)\.(?:[\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%\(\)\[\]\x80-\xFF]{1,})+?)~&format_url($1,$2)~eisg; $threadpost =~ s~\$2~isg; $threadpost =~ s~\[url=\s*(.+?)\]\s*(.+?)\s*\[/url\]~$2~isg; $threadpost =~ s~\[link\]\s*www\.\s*(.+?)\s*\[/link\]~www.$1~isg; $threadpost =~ s~\[link=\s*(\w+\://.+?)\](.+?)\s*\[/link\]~$2~isg; $threadpost =~ s~\[link=\s*(.+?)\]\s*(.+?)\s*\[/link\]~$2~isg; $threadpost =~ s~\[link\]\s*(.+?)\s*\[/link\]~$1~isg; $threadpost =~ s~\[ftp\]\s*(.+?)\s*\[/ftp\]~$1~isg; } else { $threadpost =~ s~\[url=\s*(\S\w+\://\S+?)\s*\](.+?)\[/url\]~$2~isg; $threadpost =~ s~\[url=\s*(\S+?)\](.+?)\s*\[/url\]~$2~isg; $threadpost =~ s~\[link\]\s*www\.(\S+?)\s*\[/link\]~www.$1~isg; $threadpost =~ s~\[link=\s*(\S\w+\://\S+?)\s*\](.+?)\[/link\]~$2~isg; $threadpost =~ s~\[link=\s*(\S+?)\](.+?)\s*\[/link\]~$2~isg; $threadpost =~ s~\[link\]\s*(\S+?)\s*\[/link\]~$1~isg; $threadpost =~ s~\[ftp\]\s*(ftp://)?(.+?)\s*\[/ftp\]~$1$2~isg; } $threadpost =~ s~(dereferer\;url\=http\:\/\/.*?)#(\S+?\")~$1;anch=$2~isg; if ($guest_media_disallowed && $iamguest) { my $oops = qq~$maintxt{'40'}  $maintxt{'41'} $img{'login'}~; if ($regtype) { $oops .= qq~ $maintxt{'42'} $img{'register'}~; } $threadpost =~ s~~[oops]~g; $threadpost =~ s~\[media\].*?\[/media\]~[oops]~isg; $threadpost =~ s~\[oops\]~$oops~g; } $threadpost =~ s~\[media\](.*?)\[/media\]~$1~isg; $threadpost =~ s~\[email\]\s*(\S+?\@\S+?)\s*\[/email\]~$1~isg; $threadpost =~ s~\[email=\s*(\S+?\@\S+?)\]\s*(.*?)\s*\[/email\]~$2 ($1)~isg; $threadpost =~ s~\[news\](.+?)\[/news\]~$1~isg; $threadpost =~ s~\[gopher\](.+?)\[/gopher\]~$1~isg; $threadpost =~ s~\[ftp\](.+?)\[/ftp\]~$1~isg; while ($threadpost =~ /\[quote\s+author=(.*?)\slink=.*?\s+date=(.*?)\s*\]\n*.*?\n*\[\/quote\]/is) { my $author = $1; my $date = &timeformat($2, 1); if ($author) { # out of YaBBC.pl -> sub quotemsg { &ToChars($author); if (!&checkfor_DBorFILE("$memberdir/$author.vars")) { # if the file is there it is an unencrypted user ID $author = &decloak($author); # if not, decrypt it and see if it is a regged user if (!&checkfor_DBorFILE("$memberdir/$author.vars")) { # if still not found probably the author is a screen name $testauthor = &MemberIndex("who_is", "$author"); # check if this name exists in the memberlist if ($testauthor ne ""){ # if it is, load the user id returned $author = $testauthor; &LoadUser($author); $author = ${$uid.$author}{'realname'}; # set final author var to the current users screen name } else { $author = &decloak($author); # if all fails it is a non existing real name so decode and asign as screenname } } else { &LoadUser($author); # after encoding the user ID was found and loaded, setting the current real name $author = ${$uid.$author}{'realname'}; } } else { &LoadUser($author); # it was an old style user id which could be loaded and screen name set to final author $author = ${$uid.$author}{'realname'}; } } $threadpost =~ s~\[quote\s+author=.*?link=.*?\s+date=.*?\s*\]\n*(.*?)\n*\[/quote\]~
$author $maintxt{'30a'} $date
:
$1
~is; } $threadpost =~ s~\[quote\]\n*(.+?)\n*\[/quote\]~
$maintxt{'31'}:
$1
~isg; $threadpost =~ s~\[list\]~~isg; $threadpost =~ s~\[pre\](.+?)\[/pre\]~'
' . dopre($1) . '
'~iseg; $threadpost =~ s~\[flash=(\S+?),(\S+?)\](\S+?)\[/flash\]~$3~isg; $threadpost =~ s~\{\{~\[~g; $threadpost =~ s~\}\}~\]~g; if ($threadpost =~ m~\[table\]~i) { $threadpost =~ s~\n{0,1}\[table\]\n*(.+?)\n*\[/table\]\n{0,1}~$1
~isg; while ($threadpost =~ s~\(.*?)\n*\[tr\]\n*(.*?)\n*\[/tr\]\n*(.*?)\~$1$2$3
~is) { } while ($threadpost =~ s~\(.*?)\n*\[td\]\n{0,1}(.*?)\n{0,1}\[/td\]\n*(.*?)\~$1$2$3~is) { } } $threadpost =~ s~\[\&table(.*?)\]~~g; $threadpost =~ s~\[/\&table\]~~g; $threadpost =~ s~\n~
~ig; ### Censor it ### $threadtitle = &Censor($threadtitle); $threadpost = &Censor($threadpost); &ToChars($threadtitle); &ToChars($threadpost); $threaddate = timeformat($threaddate, 1); } 1;