Tetra-WebBBS Debugger 6.10

Contents of /home/zoetecnocampoco/public_html/cgi-bin/bbs/lib/webbbs_admin.pl

    1- #<<<
    2- #######################################
    3- #    ---  Tetra-WebBBS  --- 
    4- # By:             tetrabb.com
    5- # Version:        6.10
    6- # Last modified:  2009-11-01
    7- # Copyright (c)   2006-2009
    8- # Website:        http://tetrabb.com
    9- # For more details see license.txt
   10- #
   11- # Core script:    webbbs_admin.pl
   12- # Authors:        Rainer Libowski
   13- #                 Tarty
   14- # Derived from code by Darryl Burgdorf
   15- #######################################
   16- #>>>
   17- 
   18- %main::dispatch_old_admin = (
   19- 
   20- 'index' => sub { &startup_admin_index; },
   21- 
   22- 'post'   => sub { require 'webbbs_post.pl'; &PostAdminMessage(@_); },
   23- 'edit'   => sub { &startup_admin;           &PostEditForm; },
   24- 'delete' => sub { &startup_admin;           &AdminDelete; },
   25- 
   26- 'checkdb' => sub { &startup_admin; &CheckDB; },
   27- 'delete'  => sub { &startup_admin; &AdminDelete; },
   28- 
   29- 'moderate'    => sub { &startup_admin;           &ApprovePost; },
   30- 'approvelist' => sub { require 'webbbs_post.pl'; &approve_list; },
   31- 
   32- 'rebuild' => sub { require 'webbbs_rebuild.pl'; &Rebuild_Database; },
   33- 
   34- 'resetpass' => sub { &ResetPassword; },
   35- 
   36- 'topstats'   => sub { require 'webbbs_stats.pl'; &TopStats; },
   37- 'msgstats'   => sub { require 'webbbs_stats.pl'; &TopStats; },
   38- 'topicstats' => sub { require 'webbbs_stats.pl'; &TopStats; },
   39- 'trafficstats' => sub { &startup_admin; require 'webbbs_stats.pl'; &TrafficStats; },
   40- 
   41- );
   42- 
   43- sub WebBBSAdmin {
   44- $version = $main::VERSION;
   45- if ($printbenchmark) {
   46- use Benchmark;
   47- $t0 = new Benchmark;
   48- }
   49- 
   50- $main::tbb->load_admin_modules();
   51- 
   52- $private_list = $TopNPosters = $ArchiveOnly = 0;
   53- $LockRemoteUser = $ShowPosterIP = 0;
   54- $BlindEmail     = 0;
   55- $RequireProfile = $RequireEmail = $RequireProfileEmail = 0;
   56- $AdminRun = 1;
   57- $DisplayProfileEmail = $DisplayEmail = $DisplayIPs = 1;
   58- if ( $DisplayViews == 2 ) {
   59- $DisplayViews = 1;
   60- }
   61- $AllowURLs          = $AllowPics         = $AllowUserPicsUpload = 1;
   62- $AllowUserDeletion  = $AllowEmailNotices = $AllowPreview        = 1;
   63- $AllowUserPrefs     = $AllowNewThreads   = $AllowResponses      = 1;
   64- $AllowRemoveNew     = $ListProfiles      = 1;
   65- $SearchFriendlyURLs = $SFU_subject       = $SFU_redirects       = 0;
   66- 
   67- $ReparentNoRestrict = 1;
   68- 
   69- &TBB::dispatch($main::tbb);
   70- 
   71- require 'webbbs_share.pl';
   72- 
   73- $UseFrames = $AllowFramesChoice = '';
   74- $BBSFrame = "_parent";
   75- $WelcomePage = "";
   76- 
   77- &parse_basic();
   78- umask(0111);
   79- ( $SSIvirtual, $SSIfile, $PseudoQS ) = (&FindSpecifics);
   80- unless ( $ENV{'QUERY_STRING'} ) {
   81- $ENV{'QUERY_STRING'} = $PseudoQS;
   82- $ENV{'QUERY_STRING'} =~ s/\//=/g;
   83- $ENV{'QUERY_STRING'} =~ s/^=*//g;
   84- }
   85- if ( $ARGV[0] && !( $ENV{'QUERY_STRING'} ) ) {
   86- $ENV{'QUERY_STRING'} = $ARGV[0];
   87- $SkipHF = 1;
   88- }
   89- 
   90- if ( $main::tbb->{'get'}->{'page'} ) {
   91- $thispage = $main::tbb->{'get'}->{'page'};
   92- }
   93- 
   94- if ( defined $dispatch_old_admin{ $tbb->{'get'}->{'md'} } ) {
   95- $dispatch_old_admin{ $tbb->{'get'}->{'md'} }->();
   96- return;
   97- }
   98- 
   99- elsif ( defined $dispatch_old_public{ $tbb->{'get'}->{'md'} } ) {
  100- $dispatch_old_public{ $tbb->{'get'}->{'md'} }->();
  101- return;
  102- }
  103- 
  104- $tbb->send_error_plain( "9910", "9912", 'locwadm_1000' );
  105- exit;
  106- } ## end sub WebBBSAdmin
  107- 
  108- sub startup_admin {
  109- require 'webbbs_share.pl';
  110- &Parse_Form;
  111- &Initialize_Data;
  112- unless ($shortboardname) { $shortboardname = $boardname; }
  113- } ## end sub startup_admin
  114- 
  115- sub startup_admin_index {
  116- &Parse_Form;
  117- $index_run = 1;
  118- &Initialize_Data;
  119- unless ($shortboardname) { $shortboardname = $boardname; }
  120- 
  121- &CountDBMRead;
  122- 
  123- @messages = ();
  124- if ( $FORM{'ListType'} =~ /UBB/ ) {
  125- foreach $message (@sortedmessages) {
  126- &FindStart($message);
  127- }
  128- }
  129- elsif ( $FORM{'ListType'} =~ /Alpha/ ) {
  130- foreach $message (@sortedmessages) {
  131- $sortsubject{$message} = $MessageList{$message};
  132- $sortsubject{$message} =~ s/^[^\|]*\|([^\|]*).*/$1/;
  133- $sortsubject{$message} =~ s/^$text{'1513'} //;
  134- $sortsubject{$message} =~ s/&pipe;/\|/g;
  135- $sortsubject{$message} =~ tr/A-Z/a-z/;
  136- }
  137- }
  138- require 'webbbs_index.pl';
  139- &DisplayIndex;
  140- } ## end sub startup_admin_index
  141- 
  142- sub CheckDB {
  143- @sortedmessages = ( sort { $a <=> $b } keys %MessageList );
  144- $DBTotal        = @sortedmessages;
  145- $DBFirst        = $sortedmessages[0];
  146- $DBLast         = $sortedmessages[ @sortedmessages - 1 ];
  147- $PhysTotal      = 0;
  148- $PhysFirst      = 1000000000;
  149- $PhysLast       = 0;
  150- opendir( MESSAGES, $dir );
  151- @messagedir = readdir(MESSAGES);
  152- closedir(MESSAGES);
  153- @messagecount = ();
  154- 
  155- foreach $message (@messagedir) {
  156- next if ( $message =~ /^\./ );
  157- if (    ( -d "$dir/$message" )
  158-      && ( $message =~ /^bbs\d+/ ) )
  159- {
  160- opendir( COUNT, "$dir/$message" );
  161- push( @messagecount, readdir(COUNT) );
  162- closedir(COUNT);
  163- }
  164- elsif ( $message =~ /^\d+$/ ) { push( @messagecount, "$message" ); }
  165- }
  166- foreach $message (@messagecount) {
  167- next if ( ( $message =~ /\.tmp$/ ) || ( $message == 0 ) );
  168- $PhysTotal++;
  169- if ( $message > $PhysLast )  { $PhysLast  = $message; }
  170- if ( $message < $PhysFirst ) { $PhysFirst = $message; }
  171- }
  172- 
  173- if ( !$main::tbb->{'conf'}->{'search'}->{'enable'} ) {
  174- $SearchTotal = 0;
  175- $SearchFirst = 1000000000;
  176- $SearchLast  = 0;
  177- open( SEARCH, "$dir/searchterms.idx" );
  178- while (<SEARCH>) {
  179- if (/^(\d+) /) {
  180- $message = $1;
  181- $SearchTotal++;
  182- if ( $message > $SearchLast )  { $SearchLast  = $message; }
  183- if ( $message < $SearchFirst ) { $SearchFirst = $message; }
  184- }
  185- }
  186- close(SEARCH);
  187- }
  188- else {
  189- $SearchTotal = $SearchFirst = $SearchLast = '(PRO search)';
  190- }
  191- &Header( $text{'8002'}, $MessageHeaderFile );
  192- my %subnav_args = ();
  193- &Header2( undef, 'maintenance', \%subnav_args );
  194- 
  195- print "<h3>$text{'8002'}\n<br>$text{'8002.1'} $boardname</h3>\n", "</div>\n", "<p>$text{'8009'}</p>\n", "<div id=\"misc_dbcheck\">\n", "<table CELLPADDING='6'><tr>\n", "<th>$boardname</th><th>$text{'8003'}</th>", "<th>$text{'8004'}</th><th>$text{'8005'}</th>\n</tr><tr>\n", "<td>$text{'8006'}</td><td>$PhysFirst</td>", "<td>$PhysLast</td><td>$PhysTotal</td>\n</tr><tr>\n", "<td>$text{'8007'}</td><td>$DBFirst</td>", "<td>$DBLast</td><td>$DBTotal</td>\n</tr><tr>\n",
  196-     "<td>$text{'8008'}</td><td>$SearchFirst</td>", "<td>$SearchLast</td><td>$SearchTotal</td>\n</tr>\n", "</table>\n", "<p class='ac bold'><a href=\"$adminurl$BBSquery", 'md', $QS2, "rebuild\"$BBStargettop>$text{'8001'}</a></p>\n", "</div>\n";
  197- 
  198- if ( $PRO::VERSION && ($main::portalid) ) {
  199- $BBSquery =~ s/bid=\d+;?//g;
  200- my @hiddens = split( ';', $BBSquery );
  201- my $hidden = '';
  202- for (@hiddens) {
  203- my ( $name, $val ) = split( '=', $_ );
  204- next unless ( $name && $value );
  205- $hidden = "<input type='hidden' name='$name' value='$value'>\n";
  206- }
  207- 
  208- my @forums = @{ $tbb->{'pro'}->get_forumlist( 'list' => $main::portalid ) };
  209- 
  210- my $options = '';
  211- $options .= "<option value=''>" . $text{'8002.3'} . "</option>\n" . "<option value=''>" . $text{'8002.4'} . "</option>\n";
  212- for my $forum (@forums) {
  213- $forum = $forum->{'basics'};
  214- $options .= "<option value='" . $forum->{'board_id'} . "'>" . $forum->{'boardname'} . "</option>\n";
  215- }
  216- print "<div id='select_brd' class='ac bold' style='margin:20px 0px;'>\n", "<form method='get' action='", $adminurl, "'>\n", "<input type='hidden' name='md' value='checkdb'>\n", $hidden, $text{'8002.2'}, " <select name='bid'>\n", $options, "</select>\n", " <INPUT TYPE='SUBMIT' class='button' NAME=\"submit\" VALUE=\"$text{'8002.5'}\">\n",
  217- 
  218-     "</form>\n", "</div>\n";
  219- }
  220- &Footer( $MessageFooterFile, "credits" );
  221- } ## end sub CheckDB
  222- 
  223- sub approve_list {
  224- my @ids = split( /\s+|\0+/, $tbb->{'post'}->{'id'} );
  225- my @new_ids = ();
  226- while ( my $id = shift @ids ) {
  227- my $new_id = &PostAdminMessage($id);
  228- push( @new_ids, $new_id );
  229- }
  230- my %data = ();
  231- if ( $tbb->{'post'}->{'action'} =~ /mv_default/ ) {
  232- $data{'output'} = "<p class='ac'>$text{'12118'}</p>\n";
  233- }
  234- else {
  235- $data{'output'} = "<p class='ac'>$text{'12128'}</p>\n";
  236- }
  237- 
  238- $tbb->{'conf'}->{'main'}->{'BottomNavbarNoPrint'} = 1;
  239- my $sub_navbar = '';
  240- if ( $tbb->{'post'}->{'src'} ne 'default' ) {
  241- $sub_navbar = 'parking';
  242- }
  243- $tbb->{'conf'}->{'main'}->{'BottomNavbarNoPrint'} = 1;
  244- $tbb->send_output_nontemplate( 'template'    => 'master',
  245-                                'data'        => \%data,
  246-                                'sub_navbar'  => $sub_navbar, 'subnav_args' => undef,
  247-                                'refresh_url' => 'auto',
  248- );
  249- exit;
  250- } ## end sub approve_list
  251- 
  252- sub ApprovePost {
  253- my $startup = 0;
  254- require 'webbbs_share.pl';
  255- my $get = $tbb->{'get'};
  256- $messagenumber = $get->{'id'};
  257- my $display_only = 0;
  258- if ( $get->{'md'} eq 'parkread' ) { $display_only = 1; }
  259- 
  260- if ( $NaughtyWordsFile && ( !$display_only ) ) {
  261- open( NAUGHTY, "$NaughtyWordsFile" );
  262- @naughtywords = <NAUGHTY>;
  263- chomp(@naughtywords);
  264- close(NAUGHTY);
  265- }
  266- $SpellCheckerMeta = 1;
  267- 
  268- my $href = $tbb->{'db'}->{'db_main'}->getpath_message( $messagenumber, $get->{'src'}, $get->{'srcid'} );
  269- my $file = $href->{'file'};
  270- open( FILE, "$file" )
  271-     || &Error( "9100", "9101" );
  272- @message = <FILE>;
  273- close(FILE);
  274- $subject = $poster = $email = $date = $ipaddress = $previous = $image_url = $linkname = $linkurl = "";
  275- foreach $line (@message) {
  276- if ( $line =~ /^SUBJECT>(.*)/i ) { $subject = &flag_naughty($1); }
  277- elsif ( $line =~ /^ADMIN>/i )          { next; }
  278- elsif ( $line =~ /^POSTER>(.*)/i )     { $poster = &flag_naughty($1); }
  279- elsif ( $line =~ /^EMAIL>(.*)/i )      { $email = &flag_naughty($1); }
  280- elsif ( $line =~ /^DATE>(.*)/i )       { $date = $1; }
  281- elsif ( $line =~ /^EMAILNOTICES>/i )   { next; }
  282- elsif ( $line =~ /^IP_ADDRESS>(.*)/i ) { $ipaddress = &flag_ip($1); }
  283- elsif ( $line =~ /^<!--(.*)-->/i )     { $remoteuser = $1; }
  284- elsif ( $line =~ /^PASSWORD>/i )       { next; }
  285- elsif ( $line =~ /^PREVIOUS>(.*)/i )   { $previous = $1; }
  286- elsif ( $line =~ /^NEXT>/i )           { next; }
  287- elsif ( $line =~ /^IMAGE>(.*)/i ) {
  288- ( $image_url, undef ) = &find_pics_location( $1, 'UserPics' );
  289- }
  290- elsif ( $line =~ /^LINKNAME>(.*)/i ) {
  291- $linkname = &flag_naughty($1);
  292- }
  293- elsif ( $line =~ /^LINKURL>(.*)/i ) { $linkurl = $1; }
  294- elsif ( !$startup ) {
  295- $startup = 1;
  296- $title   = $subject;
  297- $title =~ s/<([^>]|\n)*(>|$)/ /g;
  298- &Header( $title, $MessageHeaderFile );
  299- 
  300- my %subnav_args = ();
  301- &Header2( undef, 'parking', \%subnav_args );
  302- if ($printboardname) {
  303- print "<h2>$boardname</h2>\n";
  304- }
  305- if ( $get->{'md'} eq 'moderate' ) {
  306- print "<h3>", $text{'12100'}, "</h3>\n";
  307- print $cust{'glob_header_e'}, "</div>\n";
  308- print "<p class='ac'>", $text{'12110'}, "</p>\n";
  309- }
  310- else {
  311- print "<h3>", $text{'12210'}, ' "', $parking_folders{ $get->{'srcid'} }->[0], "\"</h3>\n";
  312- print $cust{'glob_header_e'}, "</div>\n";
  313- }
  314- print "<div id='app_msg'>\n";
  315- unless ($SingleMsgWrapNoUse) { print "<div id=\"msg_wrap\">\n"; }
  316- print "<div class='msg_headln'>\n", $cust{'msg_headln_s'};
  317- 
  318- $verified_ref = $tbb->{'db'}->verify_exists_data( 'type' => 'profile',
  319-                                                   'id'   => $poster, );
  320- if ($verified_ref) {
  321- print $tbb->{'tbb_html_admin'}->get_manage_items_HTML( 'type'             => 'profile',
  322-                                                        'id'               => $verified_ref->{'id'},
  323-                                                        'div_id'           => 'qprofile',
  324-                                                        'first_item_title' => $poster,
  325-                                                        'first_item_value' => 'profile',
  326- );
  327- }
  328- 
  329- print $subject, $cust{'msg_headln_e'}, "</div>\n";
  330- print "<div class=\"msg_userln\">\n";
  331- print $text{'1000'}, "<span class='msg_poster'>", $poster, "</span>";
  332- 
  333- if ( $remoteuser && ( $remoteuser ne $poster ) ) {
  334- print " <span class=\"msg_remote\">(REMOTE_USER = $remoteuser)</span>";
  335- }
  336- if ($email) {
  337- $mailsubject = $subject;
  338- if (%SmileyCode) {
  339- foreach $key ( keys %SmileyCode ) {
  340- $key2 = $SmileyCode{$key};
  341- $key2        =~ s/([\[\]\(\)\\\*\+\?\\\|])/\\$1/g;
  342- $mailsubject =~ s/$key2/$key/g;
  343- }
  344- }
  345- $mailsubject =~ s/"/'/g;
  346- $mailsubject =~ s/<[^>]*?>//gi;
  347- print " <span class=\"msg_email\">";
  348- print "<<a href=\"mailto:$email?subject=$mailsubject\">";
  349- print "$email</a>></span>";
  350- }
  351- if ( $DisplayIPs && $ipaddress ) {
  352- print " <span class=\"msg_ip\">($ipaddress)</span>";
  353- }
  354- print "<br>\n", "$text{'1001'} <span class=\"msg_date\">", &PrintDate($date), "</span></div>\n";
  355- if ( $MessageList{$previous} > 0 ) {
  356- $pdate = $psub = $pposter = "";
  357- ( $pdate, $psub, $pposter, undef ) = split( /\|/, $MessageList{$previous} );
  358- $psub    =~ s/&pipe;/\|/g;
  359- $pposter =~ s/&pipe;/\|/g;
  360- print "<div class=\"msg_prev\">\n$text{'1002'} ", "<span class=\"msg_subject\">", "<a href=\"$adminurl$BBSquery", 'md' . $QS2 . "read" . $QS1 . 'id' . "$QS2" . "$previous\"$BBStarget>", "$psub</a> ($pposter)</span></div>\n";
  361- }
  362- print "<div class='msg_text'>\n$MessageOpenCode\n";
  363- print &flag_naughty($line);
  364- }
  365- else { print &flag_naughty($line); }
  366- }
  367- print "$MessageCloseCode</div>\n";
  368- if ($image_url) {
  369- my $image = $image_url;
  370- $image =~ s/.*\/([^\/])/$1/gi;
  371- if ( -e "$UserPicsDir/$image" ) {
  372- $image_url = "$UserPicsURL/$image";
  373- }
  374- print "<div class=\"msg_image\">\n$cust{'msg_image_s'}";
  375- print "<IMG SRC=\"$image_url\" ALT=\"\">$cust{'msg_image_e'}</div>\n";
  376- }
  377- if ($linkurl) {
  378- print "<div class=\"msg_link\">\n$cust{'msg_link_s'}";
  379- print "<span class=\"em\"><a href=\"$linkurl\" ";
  380- print "target=\"_blank\">";
  381- print "$linkname</a></span>$cust{'msg_link_e'}</div>\n";
  382- }
  383- 
  384- my $cfg = $tbb->{'conf'}->{'main'};
  385- 
  386- my $QS1 = $cfg->{'QS1'};
  387- my $QS2 = $cfg->{'QS2'};
  388- my $url = $cfg->{'cgiurl'} . $cfg->{'BBSquery'};
  389- 
  390- if ( $get->{'md'} eq 'moderate' ) {
  391- my $approve_icon_url = $cfg->{'html_basedir'} . '/icons/ok.png';
  392- my $delete_icon_url  = $cfg->{'html_basedir'} . '/icons/delete.png';
  393- my $edit_icon_url    = $cfg->{'html_basedir'} . '/icons/page_white_edit.png';
  394- my $dest_url         = $url . 'md' . $QS2 . 'manage' . $QS1 . 'tp' . $QS2 . 'moderate' . $QS1 . 'src' . $QS2 . 'moderate' . $QS1 . 'id' . $QS2 . $messagenumber . $QS1 . 'action' . $QS2;
  395- 
  396- print "<div class='adm_navbar2'>\n"
  397-     . $tbb->{'tbb_html_admin'}->get_manage_items_HTML( 'type'     => 'modconfirm',
  398-                                                        'id'       => $messagenumber,
  399-                                                        'div_id'   => 'qmsg',
  400-                                                        'source'   => 'moderate',
  401-                                                        'sourceid' => '',
  402-     )
  403-     . "<span id='ic_$item->{'id'}' class='ic_item'>\n"
  404-     . "<a class='icon' href='"
  405-     . $dest_url
  406-     . "approve'><img alt='' title='$text{'12021'}' src='$approve_icon_url'></a>"
  407-     . "<a class='icon' href='"
  408-     . $dest_url
  409-     . "delete'><img alt='' title='$text{'12022'}' src='$delete_icon_url'></a>"
  410-     . "<a class='icon' href='javascript:BaseTBB.toggle_me(\"app_msg\",\"\",\"app_edit\",\"\");'><img alt='' title='$text{'12023'}' src='$edit_icon_url'></a>"
  411-     . "</span>\n"
  412-     . "<div class='clearall'></div>\n"
  413-     . "</div>\n";
  414- }
  415- else {
  416- print "<div class='adm_navbar2'>\n"
  417-     . $tbb->{'tbb_html_admin'}->get_manage_items_HTML( 'type'     => 'parklist',
  418-                                                        'id'       => $messagenumber,
  419-                                                        'div_id'   => 'qmsg',
  420-                                                        'source'   => $get->{'src'},
  421-                                                        'sourceid' => $get->{'srcid'},
  422-     )
  423-     . "<div class='clearall'></div>\n"
  424-     . "</div>\n";
  425- 
  426- }
  427- unless ($SingleMsgWrapNoUse) {
  428- print $cust{'msg_wrap_e'} . "</div>\n";
  429- }
  430- print "</div>\n";
  431- print "<div id='app_edit' style='display:none;'>\n";
  432- 
  433- if ( !$display_only ) {
  434- $text{'1504'} = $text{'12123'};
  435- &Print_EditForm( $messagenumber, 1 );
  436- }
  437- print "</div>\n";
  438- &Footer( $MessageFooterFile, "credits" );
  439- } ## end sub ApprovePost
  440- 
  441- sub DisplayMessageAdmin {
  442- print "<div class='adm_navbar2'>\n"
  443-     . $tbb->{'tbb_html_admin'}->get_manage_items_HTML( 'type'   => 'message',
  444-                                                        'id'     => $messagenumber,
  445-                                                        'div_id' => 'qmsg',
  446-     )
  447-     . "<div class='clearall'></div>\n"
  448-     . "</div>\n";
  449- unless ($SingleMsgWrapNoUse) {
  450- print $cust{'msg_wrap_e'} . "</div>\n";
  451- }
  452- unless ( ( $previous == 0 ) && ( $next == 0 ) ) {
  453- $DeleteSelect = 1;
  454- $ToBeDeleted  = "";
  455- print "<div id=\"msg_respons\">\n";
  456- print "<a id='Responses' name='Responses'></a>\n";
  457- @responses = split( / /, $next );
  458- $responsecount = 0;
  459- print "<h3>$text{'1005'}</h3>\n";
  460- print "<FORM METHOD='POST' ACTION=\"$adminurl$BBSquery", 'md', $QS2, "manage\"$BBStarget>\n";
  461- print "<$ul_dl>";
  462- &FindStart($messagenumber);
  463- &ThreadList($threadstart);
  464- print "</$ul_dl>\n" . "<div class='adm_navbar3'>\n"
  465-     . $tbb->{'tbb_html_admin'}->get_manage_items_HTML( 'type'        => 'selected_messages',
  466-                                                        'id'          => undef,
  467-                                                        'div_id'      => 'qthread',
  468-                                                        'no_form_tag' => 1,
  469-     )
  470-     . "<span id='selall' style='display:inline;'><a href='javascript:AdminTBB.select_all(\"delete\");'>$text{'00930'}</a></span>\n"
  471-     . "<span id='unselall' style='display:none;'><a href='javascript:AdminTBB.unselect_all(\"delete\");'>$text{'00931'}</a></span>\n"
  472-     . "<div class='clearall'></div>\n"
  473-     . "</div>\n"
  474-     . "</form>\n"
  475-     . "</div>\n";
  476- }
  477- } ## end sub DisplayMessageAdmin
  478- 
  479- sub AdminDelete {
  480- require 'webbbs_share.pl';
  481- 
  482- if ( $tbb->{'post'}->{'id'} ) {
  483- $FORM{'delete'} = $tbb->{'post'}->{'id'};
  484- }
  485- @messages = split( /\s+/, $FORM{'delete'} );
  486- if ( $ArchiveDir
  487-      && ( $tbb->{'post'}->{'action'} eq 'mv_archive' ) )
  488- {
  489- &Archive;
  490- }
  491- 
  492- my $move_only = 0;
  493- if ( $tbb->{'post'}->{'action'} =~ /^mv_park/ ) {
  494- $move_only = 1;
  495- }
  496- 
  497- my $dest = my $destid = '';
  498- ( undef, $dest, $destid ) = split( /_/, $tbb->{'post'}->{'action'} );
  499- foreach $message (@messages) {
  500- $subdir = "bbs" . int( $message / 1000 );
  501- my $sourcefile = "$dir/$subdir/$message";
  502- my $msgdata    = $read5x->read_message($sourcefile);
  503- my ($image_location);
  504- ( undef, $image_location ) = &find_pics_location( $msgdata->{'image_url'}, 'UserPics' );
  505- 
  506- my $is_temp = ( $FORM{'delete'} =~ /tmp/i ) ? 1 : 0;
  507- 
  508- if ($PRO::VERSION) {
  509- &PRO::cb_message_delete_2( 'tbb'     => $main::tbb,
  510-                            'msg_num' => $message,
  511-                            'is_temp' => $is_temp, 'board_id' => $main::tbb->{'conf'}->{'board_id'},
  512- );
  513- }
  514- 
  515- if ($move_only) {
  516- my $dest_ref = $tbb->{'db'}->{'db_main'}->getpath_message( $message, $dest, $destid );
  517- $tbb->{'db'}->{'db_main'}->make_dir( $dest_ref->{'folder'} );
  518- rename( $sourcefile, $dest_ref->{'file'} );
  519- }
  520- else {
  521- unlink "$dir/$subdir/$message";
  522- unlink $image_location;
  523- }
  524- 
  525- delete( $MessageList{$message} );
  526- if ( $CountList{$message} ) { delete( $CountList{$message} ); }
  527- rmdir "$dir/$subdir";
  528- }
  529- if ( !$main::tbb->{'conf'}->{'search'}->{'enable'} ) {
  530- open( SEARCH, "$dir/searchterms.idx" );
  531- &LockOpen( NEWSEARCH, "$dir/newsearchterms.idx" );
  532- while (<SEARCH>) {
  533- if (/^(\d+) /) {
  534- $message = $1;
  535- $subdir  = "bbs" . int( $message / 1000 );
  536- if ( -e "$dir/$subdir/$message" ) {
  537- print NEWSEARCH "$_";
  538- }
  539- }
  540- }
  541- close(SEARCH);
  542- if ( $ENV{'OS'} =~ /win/i ) {
  543- &LockClose( NEWSEARCH, "$dir/newsearchterms.idx" );
  544- }
  545- else {
  546- &LockOpen( SEARCH, "$dir/searchterms.idx" );
  547- }
  548- rename( "$dir/newsearchterms.idx", "$dir/searchterms.idx" );
  549- unless ( $ENV{'OS'} =~ /win/i ) {
  550- &LockClose( NEWSEARCH, "$dir/newsearchterms.idx" );
  551- &LockClose( SEARCH,    "$dir/searchterms.idx" );
  552- }
  553- }
  554- 
  555- if ($PRO::VERSION) {
  556- &PRO::cb_message_delete_3( 'tbb'         => $main::tbb,
  557-                            'board_id'    => $main::tbb->{'conf'}->{'board_id'},
  558-                            'tied_db_ref' => \%MessageList,
  559- );
  560- }
  561- 
  562- &MessageDBM_close();
  563- &CountDBM_close();
  564- 
  565- my %data = ();
  566- 
  567- if ($move_only) {
  568- $data{'subtitle'} = $text{'12156'};
  569- $data{'output'}   = "<p class='ac'>" . $text{'12158'} . " \"" . $parking_folders{$destid}->[0] . "\"</p>\n";
  570- 
  571- }
  572- else {
  573- $data{'subtitle'} = $text{'0212'};
  574- $data{'output'}   = "<p class='ac'>$text{'0200'}</p>\n";
  575- 
  576- }
  577- my $sub_navbar = '';
  578- if ( $tbb->{'post'}->{'src'} ne 'default' ) {
  579- $sub_navbar = 'parking';
  580- }
  581- 
  582- $tbb->{'conf'}->{'main'}->{'BottomNavbarNoPrint'} = 1;
  583- $tbb->send_output_nontemplate( 'template'    => 'master',
  584-                                'data'        => \%data,
  585-                                'sub_navbar'  => $sub_navbar, 'subnav_args' => undef,
  586-                                'refresh_url' => 'auto',
  587- );
  588- exit;
  589- } ## end sub AdminDelete
  590- 
  591- sub Archive {
  592- &LockOpen( DBLOCK, "$ArchiveDir/messagelist.lock" );
  593- if ( $DBMType == 1 ) {
  594- tie( %ArcMessageList, 'AnyDBM_File', "$ArchiveDir/messagelist", O_RDWR | O_CREAT, 0666, $DB_HASH )
  595-     || print "(Error!) ";
  596- }
  597- elsif ( $DBMType == 2 ) {
  598- dbmopen( %ArcMessageList, "$ArchiveDir/messagelist", 0666 )
  599-     || print "(Error!) ";
  600- }
  601- else {
  602- tie( %ArcMessageList, 'AnyDBM_File', "$ArchiveDir/messagelist", O_RDWR | O_CREAT, 0666 )
  603-     || print "(Error!) ";
  604- }
  605- &LockOpen( COUNTLOCK, "$ArchiveDir/countlist.lock" );
  606- if ( $DBMType == 1 ) {
  607- tie( %ArcCountList, 'AnyDBM_File', "$ArchiveDir/countlist", O_RDWR | O_CREAT, 0666, $DB_HASH )
  608-     || print "(Error!) ";
  609- }
  610- elsif ( $DBMType == 2 ) {
  611- dbmopen( %ArcCountList, "$ArchiveDir/countlist", 0666 )
  612-     || print "(Error!) ";
  613- }
  614- else {
  615- tie( %ArcCountList, 'AnyDBM_File', "$ArchiveDir/countlist", O_RDWR | O_CREAT, 0666 )
  616-     || print "(Error!) ";
  617- }
  618- %ToMove = ();
  619- foreach $message (@messages) {
  620- if ($PRO::VERSION) {
  621- &PRO::cb_message_move_1( 'tbb'           => $main::tbb,
  622-                          'msg_num'       => $message,
  623-                          'board_id'      => $main::tbb->{'conf'}->{'board_id'},
  624-                          'dest_msg_num'  => $message,
  625-                          'dest_board_id' => $main::tbb->{'conf'}->{'archive_board_id'},
  626- );
  627- }
  628- $subdir = "bbs" . int( $message / 1000 );
  629- $ToMove{$message} = 1;
  630- unless ( -d "$ArchiveDir/$subdir" ) {
  631- mkdir( "$ArchiveDir/$subdir", 0777 );
  632- chmod 0777, "$ArchiveDir/$subdir";
  633- }
  634- rename( "$dir/$subdir/$message", "$ArchiveDir/$subdir/$message" );
  635- $ArcMessageList{$message} = $MessageList{$message};
  636- $ArcCountList{$message}   = $CountList{$message};
  637- delete( $MessageList{$message} );
  638- delete( $CountList{$message} );
  639- rmdir "$dir/$subdir";
  640- 
  641- }
  642- if (    ( $FORM{'delete'} !~ /tmp/ )
  643-      && ( !$main::tbb->{'conf'}->{'search'}->{'enable'} ) )
  644- {
  645- open( SEARCH, "$dir/searchterms.idx" );
  646- &LockOpen( NEWSEARCH, "$dir/newsearchterms.idx" );
  647- &LockOpen( ARCSEARCH, "$ArchiveDir/searchterms.idx", "a" );
  648- while (<SEARCH>) {
  649- if (/^(\d+) /) {
  650- $message = $1;
  651- if ( $ToMove{$1} ) {
  652- print ARCSEARCH "$_";
  653- }
  654- else {
  655- $subdir = "bbs" . int( $message / 1000 );
  656- if ( -e "$dir/$subdir/$message" ) {
  657- print NEWSEARCH "$_";
  658- }
  659- }
  660- }
  661- }
  662- &LockClose( ARCSEARCH, "$ArchiveDir/searchterms.idx" );
  663- close(SEARCH);
  664- if ( $ENV{'OS'} =~ /win/i ) {
  665- &LockClose( NEWSEARCH, "$dir/newsearchterms.idx" );
  666- }
  667- else {
  668- &LockOpen( SEARCH, "$dir/searchterms.idx" );
  669- }
  670- rename( "$dir/newsearchterms.idx", "$dir/searchterms.idx" );
  671- unless ( $ENV{'OS'} =~ /win/i ) {
  672- &LockClose( NEWSEARCH, "$dir/newsearchterms.idx" );
  673- &LockClose( SEARCH,    "$dir/searchterms.idx" );
  674- }
  675- }
  676- 
  677- if ($PRO::VERSION) {
  678- &PRO::cb_message_move_3( 'tbb'         => $main::tbb,
  679-                          'tied_db_ref' => \%MessageList, );
  680- }
  681- 
  682- if   ( $DBMType == 2 ) { dbmclose(%ArcMessageList); }
  683- else                   { untie %ArcMessageList; }
  684- &LockClose( DBLOCK, "$ArchiveDir/messagelist.lock" );
  685- if   ( $DBMType == 2 ) { dbmclose(%ArcCountList); }
  686- else                   { untie %ArcCountList; }
  687- &LockClose( COUNTLOCK, "$ArchiveDir/countlist.lock" );
  688- &Header( $text{'0312'}, $MessageHeaderFile, "refresh" );
  689- &Header2("refresh");
  690- print "<h3>$text{'0312'}</h3>\n</div>\n";
  691- print "<p class=\"center\">$text{'0300'}</p>\n";
  692- &Footer( $MessageFooterFile, "return", "refresh" );
  693- } ## end sub Archive
  694- 
  695- sub ResetPassword {
  696- &Parse_Form;
  697- 
  698- if (    ( $FORM{'oldpassword'} eq "NoPasswordYet" )
  699-      && ( -e $password_file ) )
  700- {
  701- $tbb->send_error_plain( "9600", "9601" );
  702- exit;
  703- }
  704- elsif ( -e $password_file ) {
  705- my $result = $tbb->{'db_admin'}->verify_password_admin( 'password' => $FORM{'oldpassword'} );
  706- if ( !$result ) {
  707- $tbb->send_error_plain( "9600", "9601" );
  708- exit;
  709- }
  710- }
  711- unless ( $FORM{'passad'} && ( $FORM{'passad'} eq $FORM{'passad2'} ) ) {
  712- $tbb->send_error_plain( "9602", "9603" );
  713- exit;
  714- }
  715- $newpassword = crypt( $FORM{'passad'}, "aa" );
  716- open( PASSWORD, ">$password_file" );
  717- print PASSWORD "$newpassword";
  718- close(PASSWORD);
  719- my %data = ();
  720- 
  721- if ( $FORM{'oldpassword'} eq "NoPasswordYet" ) {
  722- $data{'subtitle'} = $tbb->{'conf'}->{'text'}->{'11125.1'};
  723- $data{'output'}   = "<div class='ac tbbcol_4' style='margin: 10px 15%; width: auto;'>\n" . "<style>\n #proceed { display: block; margin-top:8px; padding: 8px 0px; background-color: #ccccff;}\n " . "#proceed a {text-decoration:none; background-color: #eee; border: 2px outset #bbb; color: black; margin: 5px; padding: 3px 8px;}\n" . "</style>\n"
  724- 
  725-     . "<p>" . $tbb->{'conf'}->{'text'}->{'11126.1'} . "</p>\n" . "<div id='proceed'><a href ='" . $tbb->{'conf'}->{'main'}->{'cgiurl'} . "'>" . $tbb->{'conf'}->{'text'}->{'00200'} . "</a></div>\n" . "</div>\n";
  726- $tbb->{'conf'}->{'main'}->{'TopNavbarNoPrint'}    = 1;
  727- $tbb->{'conf'}->{'main'}->{'BottomNavbarNoPrint'} = 1;
  728- 
  729- }
  730- else {
  731- $data{'subtitle'} = $tbb->{'conf'}->{'text'}->{'11125'};
  732- $data{'output'}   = "<div class='ac'>\n" . "<p>" . $tbb->{'conf'}->{'text'}->{'11126'} . "</p>\n" . "</div>\n";
  733- }
  734- $tbb->send_output_nontemplate( 'template'    => 'master',
  735-                                'data'        => \%data,
  736-                                'sub_navbar'  => undef,
  737-                                'subnav_args' => undef,
  738- );
  739- exit;
  740- } ## end sub ResetPassword
  741- 
  742- sub PostEditForm {
  743- if ( $tbb->{'post'}->{'id'} ) {
  744- $messagenumber = int( $tbb->{'post'}->{'id'} );
  745- }
  746- elsif ( $tbb->{'get'}->{'id'} ) {
  747- $messagenumber = int( $tbb->{'get'}->{'id'} );
  748- }
  749- $SpellCheckerMeta = 1;
  750- &Header( $text{'1504'}, $MessageHeaderFile );
  751- ( $navbar_top, $navbar_bottom ) =
  752-     $main::tbb->{'tbb_html'}->get_navbar_HTML( 'sub_navbar'  => '',
  753-                                                'subnav_args' => undef, );
  754- unless ($TopNavbarNoPrint) {
  755- print "<div id='nb_top'>\n" . $navbar_top . "</div>\n";
  756- }
  757- $BottomNavbarNoPrint = 1;
  758- 
  759- print "<div id='glob_header'>\n", $cust{'glob_header_s'};
  760- if ($printboardname) { print "<h2>$boardname</h2>\n"; }
  761- print $cust{'glob_header_s'}, "</div>\n";
  762- $subdir = "bbs" . int( $messagenumber / 1000 );
  763- open( FILE, "$dir/$subdir/$messagenumber" );
  764- @message = <FILE>;
  765- close(FILE);
  766- print "<div id='misc_msgform'>\n", $cust{'misc_msgform_s'};
  767- &Print_EditForm($messagenumber);
  768- print $cust{'misc_msgform_e'}, "</div>\n";
  769- &Footer( $MessageFooterFile, "credits" );
  770- } ## end sub PostEditForm
  771- 
  772- sub Print_EditForm {
  773- my ( undef, $cancel_button ) = @_;
  774- $message    = $tbb->{'get'}->{'id'};
  775- $quotedtext = "";
  776- foreach $line (@message) {
  777- if    ( $line =~ /^SUBJECT>(.*)/i )      { $sub       = $1; }
  778- elsif ( $line =~ /^ADMIN>(.*)/i )        { $admin     = $1; }
  779- elsif ( $line =~ /^POSTER>(.*)/i )       { $poster    = $1; }
  780- elsif ( $line =~ /^EMAIL>(.*)/i )        { $email     = $1; }
  781- elsif ( $line =~ /^DATE>(.*)/i )         { $date      = $1; }
  782- elsif ( $line =~ /^EMAILNOTICES>(.*)/i ) { $wantemail = $1; }
  783- elsif ( $line =~ /^IP_ADDRESS>(.*)/i )   { $ip        = $1; }
  784- elsif ( $line =~ /^<!--/i )              { next; }
  785- elsif ( $line =~ /^PASSWORD>(.*)/i )     { $password  = $1; }
  786- elsif ( $line =~ /^PREVIOUS>(.*)/i )     { $prev      = $1; }
  787- elsif ( $line =~ /^NEXT>(.*)/i )         { $next      = $1; }
  788- elsif ( $line =~ /^IMAGE>(.*)/i )        { $imageurl  = $1; }
  789- elsif ( $line =~ /^LINKNAME>(.*)/i )     { $linkname  = $1; }
  790- elsif ( $line =~ /^LINKURL>(.*)/i )      { $linkurl   = $1; }
  791- else { $quotedtext .= $line; }
  792- }
  793- 
  794- my $formid_md5 = '';
  795- if ( $FORM{'formid'} ) {
  796- $formid_md5 = $FORM{'formid'};
  797- }
  798- else {
  799- ( undef, $formid_md5 ) = $tbb->{'basic'}->create_id();
  800- }
  801- if ($PRO::VERSION) {
  802- &PRO::cb_message_form_1( 'tbb'      => $main::tbb,
  803-                          'formid'   => $formid_md5,
  804-                          'board_id' => $main::tbb->{'conf'}->{'board_id'},
  805- );
  806- }
  807- 
  808- if (%SmileyCode) {
  809- foreach $key ( keys %SmileyCode ) {
  810- $key2 = $SmileyCode{$key};
  811- $key2       =~ s/([\[\]\(\)\\\*\+\?\\\|])/\\$1/g;
  812- $quotedtext =~ s/$key2/$key/g;
  813- }
  814- }
  815- 
  816- @pres = ();
  817- while ( $quotedtext =~ m/<pre>(.+?)<\/pre>/sig ) {
  818- push( @pres, $1 );
  819- }
  820- for (@pres) {
  821- my $code    = $_;
  822- my $newcode = $code;
  823- $newcode =~ s/\n/<FeEd>/sig;
  824- $_ = $newcode;
  825- $quotedtext =~ s/\Q$code\E/$newcode/sg;
  826- }
  827- 
  828- $quotedtext =~ s/\n//g;
  829- 
  830- for (@pres) {
  831- my $code    = $_;
  832- my $newcode = $code;
  833- $newcode    =~ s/<FeEd>/\n/sg;
  834- $quotedtext =~ s/\Q$code\E/\n$newcode\n/sg;
  835- }
  836- $quotedtext =~ s/<pre>/\n<PRE>/sig;
  837- 
  838- if (%FormatCode) {
  839- $quotedtext = decode_BB_code( $quotedtext, \%FormatCode );
  840- }
  841- if ($AutoHotlink) {
  842- $quotedtext =~ s/<\/?a.*?>//gi;
  843- }
  844- 
  845- if ( !$TinyMCE::VERSION ) {
  846- $quotedtext =~ s/<P>/\n\n/g;
  847- $quotedtext =~ s/<BR>/\n/g;
  848- }
  849- $quotedtext =~ s/^\n*//g;
  850- $quotedtext =~ s/\n*$//g;
  851- $quotedtext =~ s/\& /\&\; /g;
  852- $quotedtext =~ s/"/\"\;/g;
  853- 
  854- if ( ( !$AllowHTML ) || ($TinyMCE::VERSION) ) {
  855- $quotedtext =~ s/\<\;/\<\;/g;
  856- $quotedtext =~ s/\>\;/\>\;/g;
  857- 
  858- $quotedtext =~ s/</\<\;/g;
  859- $quotedtext =~ s/>/\>\;/g;
  860- $quotedtext =~ s/\<\;/\&\;lt\;/g;
  861- $quotedtext =~ s/\>\;/\&\;gt\;/g;
  862- }
  863- 
  864- print "<div id=\"misc_msgform\">\n<FORM ENCTYPE=\"multipart/form-data\" METHOD='POST' ";
  865- print "ACTION=\"$adminurl$BBSquery";
  866- 
  867- print 'md' . $QS2 . "$QueryMode{'post'}\" NAME=\"message\">\n";
  868- 
  869- if ( $cust{'msg_form_01'} ) {
  870- print $cust{'msg_form_01'}, "\n";
  871- }
  872- print "<input type='hidden' name='formid' value='$formid_md5'>\n";
  873- 
  874- print "<INPUT TYPE='HIDDEN' NAME=\"EditPost\" VALUE=\"$_[0]\">\n";
  875- 
  876- print "<table $tablespec><tr>\n";
  877- print "<th colspan='2'><span class=\"big\">";
  878- print "$text{'1504'} # $_[0]\n";
  879- print "</span></th></tr><tr>\n";
  880- print "<td align='right'>";
  881- print "$text{'1510'}";
  882- print "</td><td><INPUT TYPE='TEXT' NAME=\"name\" ";
  883- print "SIZE=$InputLength";
  884- print " VALUE=\"$poster\"";
  885- print "></td></tr><tr>\n";
  886- print "<td align='right'>";
  887- print "$text{'1511'}";
  888- print "</td><td><INPUT TYPE='TEXT' NAME=\"email\" ";
  889- print "SIZE=$InputLength MAXLENGTH=100";
  890- print " VALUE=\"$email\"";
  891- print "></td></tr><tr>\n";
  892- print "<td align='right'>";
  893- print "$text{'1512'}";
  894- print "</td><td><INPUT TYPE='TEXT' NAME=\"subject\" ";
  895- print "SIZE=$InputLength";
  896- 
  897- if (%SmileyCode) {
  898- foreach $key ( keys %SmileyCode ) {
  899- $key2 = $SmileyCode{$key};
  900- $key2 =~ s/([\[\]\(\)\\\*\+\?\\\|])/\\$1/g;
  901- $sub  =~ s/$key2/$key/g;
  902- }
  903- }
  904- if ($NM_Telltale) {
  905- $sub =~ s/ $Cleaned_NM_Telltale//g;
  906- }
  907- if ($Link_Telltale) {
  908- $sub =~ s/ $Cleaned_Link_Telltale//g;
  909- }
  910- if ($Pic_Telltale) {
  911- $sub =~ s/ $Cleaned_Pic_Telltale//g;
  912- }
  913- $sub =~ s/"/\"\;/g;
  914- print " VALUE=\"$sub\"";
  915- print "></td></tr><tr>\n";
  916- print "<td colspan='2' class=\"center\">";
  917- print "$text{'1514'}\n";
  918- if ( $cust{'msg_form_20'} ) {
  919- print $cust{'msg_form_20'}, "\n";
  920- }
  921- print "<TEXTAREA COLS='$InputColumns' ROWS='$InputRows' ";
  922- print "NAME=\"body\">";
  923- print "$quotedtext";
  924- print "</TEXTAREA>\n";
  925- if ( $cust{'msg_form_21'} ) {
  926- print $cust{'msg_form_21'}, "\n";
  927- }
  928- 
  929- print "</td></tr>\n";
  930- if ( $cust{'msg_form_30'} ) {
  931- print $cust{'msg_form_30'}, "\n";
  932- }
  933- 
  934- print "<tr>\n";
  935- print "<td align='right'>";
  936- print "$text{'1515'}</td>";
  937- print "<td><INPUT TYPE='TEXT' ";
  938- print "NAME=\"url\" SIZE=$InputLength MAXLENGTH=250";
  939- print " VALUE=\"$linkurl\"";
  940- print "></td></tr><tr>\n";
  941- print "<td align='right'>";
  942- print "$text{'1516'}</td>";
  943- print "<td><INPUT TYPE='TEXT' ";
  944- print "NAME=\"url_title\" SIZE=$InputLength";
  945- print " VALUE=\"$linkname\"";
  946- print "></td></tr>\n";
  947- if ( $cust{'msg_form_31'} ) {
  948- print $cust{'msg_form_31'}, "\n";
  949- }
  950- 
  951- print "<tr>\n";
  952- print "<td align='right'>";
  953- print "$text{'1517'}</td>";
  954- print "<td><INPUT TYPE='TEXT' ";
  955- print "NAME=\"imageurl\" SIZE='$InputLength' MAXLENGTH='250'";
  956- print " VALUE=\"$imageurl\"";
  957- print "></td></tr>\n";
  958- if ( $cust{'msg_form_32'} ) {
  959- print $cust{'msg_form_32'}, "\n";
  960- }
  961- 
  962- print "<tr>\n";
  963- print "<td align='right'>";
  964- print "$text{'1560'}</td>";
  965- print "<td><INPUT TYPE='TEXT' NAME=\"NewParent\" SIZE=10";
  966- if ($prev) { print " VALUE=\"$prev\""; }
  967- print ">\n";
  968- 
  969- print "</td></tr>\n";
  970- if ( $cust{'msg_form_33'} ) {
  971- print $cust{'msg_form_33'}, "\n";
  972- }
  973- 
  974- print "<tr><td></td>\n", "<td><label><input type='checkbox' name='wantnotice'";
  975- unless ( $wantemail eq "no" ) {
  976- print " checked";
  977- }
  978- print " value='yes'> $text{'1503'}</label>\n";
  979- 
  980- if ($AllowMessageReview) {
  981- print "<input type=\"hidden\" name=\"Admin\" value=\"No\">";
  982- }
  983- else {
  984- print "</td></tr>\n";
  985- if ( $cust{'msg_form_34'} ) {
  986- print $cust{'msg_form_34'}, "\n";
  987- }
  988- 
  989- print "<tr>\n";
  990- print "<td align='right'>";
  991- print "$text{'1518'}</td>";
  992- print "<td><label><INPUT TYPE='RADIO' NAME=\"Admin\" ";
  993- print "VALUE=\"AdminPost\"";
  994- if ( $admin eq "AdminPost" ) { print " CHECKED"; }
  995- print "> $text{'1519'}</label>";
  996- print "<label><INPUT TYPE='RADIO' NAME=\"Admin\" ";
  997- print "VALUE=\"No\"";
  998- unless ( $admin eq "AdminPost" ) { print " CHECKED"; }
  999- print "> $text{'1520'}</label>";
 1000- }
 1001- print "</td></tr>\n";
 1002- if ( $cust{'msg_form_35'} ) {
 1003- print $cust{'msg_form_35'}, "\n";
 1004- }
 1005- 
 1006- print "<tr>\n";
 1007- print "<th colspan='2' class='misc_msgform_b'>";
 1008- if ($cancel_button) {
 1009- print "<button class='button' type='button' onClick='BaseTBB.toggle_me(\"app_edit\",\"\",\"app_msg\",\"\");'>\n", "$text{'12020'}</button>\n";
 1010- }
 1011- if ($SpellCheckURL) {
 1012- print "<button class='button' type='button' onClick='spellcheck_sendtext(\"message\", \"body\", \"$spellcheck_popup_width\", \"$spellcheck_popup_height\", \"$spellcheck_popup_top\", \"$spellcheck_popup_left\")'>\n", "$text{'1552'}</button>\n";
 1013- }
 1014- print "<INPUT TYPE='SUBMIT' class='button' NAME=\"Post\" ";
 1015- print "VALUE=\"$text{'1504'}\"></th>";
 1016- print "</tr></table>\n";
 1017- print "</FORM>\n";
 1018- if ($SpellCheckURL) {
 1019- print "<form name='send' action='$SpellCheckURL' method='POST' target='SpellChecker'>\n", "<input type='hidden' name='checkme'>\n", "<input type='hidden' name='form'>\n", "<input type='hidden' name='field'>\n", "<input type='hidden' name='spell' value='check'>\n", "</form>\n";
 1020- }
 1021- print "</div>\n";
 1022- 
 1023- } ## end sub Print_EditForm
 1024- 
 1025- sub DisplayIndexAdmin3 {
 1026- $SearchString = "$text{'0520'} ";
 1027- $SearchString .= "<span class=\"strong\">"$FORM{'Domain'}"</span>";
 1028- foreach $message (@sortedmessages) {
 1029- if (    ( int( $MessageList{$message} ) >= $startday )
 1030-      && ( int( $MessageList{$message} ) <= $endday ) )
 1031- {
 1032- $date = $sub = $poster = $prev = $next = $count = $admin = $ip = "";
 1033- ( $date, $sub, $poster, $prev, $next, $count, $admin, $ip ) =
 1034-     split( /\|/, $MessageList{$message} );
 1035- if ( $ip =~ /$FORM{'Domain'}/i ) {
 1036- push( @keywordmatches, $message );
 1037- }
 1038- else {
 1039- $DontUse{$message} = 1;
 1040- }
 1041- }
 1042- else {
 1043- $DontUse{$message} = 1;
 1044- }
 1045- }
 1046- @sortedmessages = ( sort { $a <=> $b } @keywordmatches );
 1047- } ## end sub DisplayIndexAdmin3
 1048- 
 1049- sub DisplayIndexAdmin4 {
 1050- if ( $messagecount < 1 ) {
 1051- print "</FORM>\n";
 1052- print "<p class=\"center\"><span class=\"strong\">$text{'0524'}</span></p>\n";
 1053- }
 1054- else {
 1055- 
 1056- print "<div class='adm_navbar'>\n" . "<div class='glob_mnb'>\n"
 1057-     . $tbb->{'tbb_html_admin'}->get_manage_items_HTML( 'type'        => 'selected_messages',
 1058-                                                        'id'          => undef,
 1059-                                                        'div_id'      => 'qthread',
 1060-                                                        'no_form_tag' => 1,
 1061-     )
 1062-     . "<span id='selall' style='display:inline;'><a href='javascript:AdminTBB.select_all(\"delete\");'>$text{'00930'}</a></span>\n"
 1063-     . "<span id='unselall' style='display:none;'><a href='javascript:AdminTBB.unselect_all(\"delete\");'>$text{'00931'}</a></span>\n"
 1064-     . "<div class='clearall'></div>\n"
 1065-     . "</div>\n"
 1066-     . "</div>\n"
 1067-     . "</form>\n";
 1068- }
 1069- if ($NotUsingBestDBM) {
 1070- print "<BLOCKQUOTE><div><span class=\"strong\">CAUTION:</span> You don't seem to have ", ""DB_File", Perl interface module to Berkeley DB (database,) available ", "on your server, so WebBBS is using an alternate module. The script will still run, ", "but not as efficiently as it could. And in high traffic situations, you may see ", "problems with database corruption. Please contact your server's administrators to ",
 1071-     "see if you can get the "DB_File" module installed.</div></BLOCKQUOTE>\n";
 1072- }
 1073- } ## end sub DisplayIndexAdmin4
 1074- 
 1075- sub PostAdminMessage {
 1076- $approve_num = shift;
 1077- my $type = '';
 1078- if    ( $tbb->{'post'}->{'tp'} ) { $type = $tbb->{'post'}->{'tp'}; }
 1079- elsif ( $tbb->{'get'}->{'tp'} )  { $type = $tbb->{'get'}->{'tp'}; }
 1080- my $source = '';
 1081- if    ( $tbb->{'post'}->{'src'} ) { $source = $tbb->{'post'}->{'src'}; }
 1082- elsif ( $tbb->{'get'}->{'src'} )  { $source = $tbb->{'get'}->{'src'}; }
 1083- my $sourceid = '';
 1084- if    ( $tbb->{'post'}->{'srcid'} ) { $sourceid = $tbb->{'post'}->{'srcid'}; }
 1085- elsif ( $tbb->{'get'}->{'srcid'} )  { $sourceid = $tbb->{'get'}->{'srcid'}; }
 1086- 
 1087- if (    ( !$approve_num )
 1088-      && ( !( $type eq 'moderate' ) )
 1089-      && ( !( $type eq 'modconfirm' ) )
 1090-      && ( !( $type eq 'parklist' ) ) )
 1091- {
 1092- &Parse_Post;
 1093- }
 1094- my $move_only = 0;
 1095- if ( $type eq 'parklist' ) {
 1096- $move_only = 1;
 1097- }
 1098- 
 1099- if ($approve_num) {
 1100- use Fcntl;
 1101- 
 1102- BEGIN {
 1103- @AnyDBM_File::ISA = qw (DB_File GDBM_File SDBM_File ODBM_File NDBM_File);
 1104- }
 1105- if ( eval "require DB_File" ) { @ISA = ('DB_File'); }
 1106- else { use AnyDBM_File; $NotUsingBestDBM = 1; }
 1107- &LockOpen( DBLOCK, "$dir/messagelist.lock" );
 1108- &MessageDBMWrite;
 1109- }
 1110- else {
 1111- &Initialize_Data;
 1112- unless ($shortboardname) { $shortboardname = $boardname; }
 1113- }
 1114- 
 1115- if (    ( ( $tbb->{'get'}->{'md'} eq 'manage' ) && ( $type eq 'moderate' ) )
 1116-      || ($approve_num) )
 1117- {
 1118- if ($approve_num) {
 1119- $num = int($approve_num);
 1120- }
 1121- elsif ( $tbb->{'post'}->{'id'} ) {
 1122- $num = int( $tbb->{'post'}->{'id'} );
 1123- }
 1124- elsif ( $tbb->{'post'}->{'EditPost'} ) {
 1125- $num = int( $tbb->{'post'}->{'EditPost'} );
 1126- }
 1127- else {
 1128- $num = int( $tbb->{'get'}->{'id'} );
 1129- }
 1130- 
 1131- my $href = $tbb->{'db'}->{'db_main'}->getpath_message( $num, $source, $sourceid );
 1132- $originalid = $href->{'file'};
 1133- if ( !$move_only ) {
 1134- $num = $tbb->{'db'}->{'db_main'}->get_new_messagenumber();
 1135- if ( !$num ) {
 1136- $tbb->send_error_plain( "89400", "89401" );
 1137- exit;
 1138- }
 1139- 
 1140- }
 1141- 
 1142- $subdir = "bbs" . int( $num / 1000 );
 1143- $tbb->{'db'}->{'db_main'}->make_dir("$dir/$subdir");
 1144- 
 1145- rename( "$originalid", "$dir/$subdir/$num" );
 1146- open( FILE, "$dir/$subdir/$num" ) || $tbb->send_error_plain( "9100", "9101" );
 1147- @message = <FILE>;
 1148- close(FILE);
 1149- $body = $email = $followup = $message_url_title = $message_url = "";
 1150- 
 1151- foreach $line (@message) {
 1152- if ( $line =~ /^SUBJECT>(.*)/i ) { $subject = $1; }
 1153- elsif ( $line =~ /^ADMIN>/i )        { next; }
 1154- elsif ( $line =~ /^POSTER>(.*)/i )   { $name = $1; }
 1155- elsif ( $line =~ /^EMAIL>(.*)/i )    { $email = $1; }
 1156- elsif ( $line =~ /^DATE>(.*)/i )     { $todaydate = $1; }
 1157- elsif ( $line =~ /^EMAILNOTICES>/i ) { next; }
 1158- elsif ( $line =~ /^IP_ADDRESS>(.*)/i ) {
 1159- $ENV{'REMOTE_HOST'} = $1;
 1160- }
 1161- elsif ( $line =~ /^<!--/i )          { next; }
 1162- elsif ( $line =~ /^PASSWORD>/i )     { next; }
 1163- elsif ( $line =~ /^PREVIOUS>(.*)/i ) { $followup = $1; }
 1164- elsif ( $line =~ /^NEXT>/i )         { next; }
 1165- elsif ( $line =~ /^IMAGE>(.*)/i )    { next; }
 1166- elsif ( $line =~ /^LINKNAME>(.*)/i ) { $message_url_title = $1; }
 1167- elsif ( $line =~ /^LINKURL>(.*)/i )  { $message_url = $1; }
 1168- else                                 { $body .= $line; }
 1169- }
 1170- $FORM{'subject'} = $subject;
 1171- $FORM{'name'}    = $name;
 1172- $FORM{'body'}    = $body;
 1173- }
 1174- else {
 1175- if ($ResolveIPs) {
 1176- if ( ( $ENV{'REMOTE_ADDR'} =~ /\d+\.\d+\.\d+\.\d+/ )
 1177-      && ( !( $ENV{'REMOTE_HOST'} )
 1178-           || ( $ENV{'REMOTE_HOST'} =~ /\d+\.\d+\.\d+\.\d+/ ) )
 1179-     )
 1180- {
 1181- @domainbytes = split( /\./, $ENV{'REMOTE_ADDR'} );
 1182- $packaddr = pack( "C4", @domainbytes );
 1183- $resolvedip = ( gethostbyaddr( $packaddr, 2 ) )[0];
 1184- unless ( $resolvedip =~ /^[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,6}|[0-9]{1,3})$/ ) {
 1185- $resolvedip = "";
 1186- }
 1187- if ($resolvedip) {
 1188- $ENV{'REMOTE_HOST'} = $resolvedip;
 1189- }
 1190- }
 1191- }
 1192- else {
 1193- $ENV{'REMOTE_HOST'} = "";
 1194- }
 1195- unless ( $ENV{'REMOTE_HOST'} ) {
 1196- $ENV{'REMOTE_HOST'} = $ENV{'REMOTE_ADDR'};
 1197- }
 1198- if ( $FORM{'followup'} ) { $followup = int( $FORM{'followup'} ); }
 1199- if ( $FORM{'subject'} )  { $subject  = "$FORM{'subject'}"; }
 1200- if ( $subject
 1201-      && (    %SmileyCode
 1202-           || $NM_Telltale
 1203-           || $Link_Telltale
 1204-           || $Pic_Telltale )
 1205-     )
 1206- {
 1207- $subject =~ s/\"\;/"/g;
 1208- $subject =~ s/\<\;/</g;
 1209- $subject =~ s/\>\;/>/g;
 1210- $subject =~ s/\&\;/\&/g;
 1211- 
 1212- $subject = substr( $subject, 0, $MaxInputLength );
 1213- 
 1214- $realsubject = $subject;
 1215- if (%SmileyCode) {
 1216- foreach $key ( keys %SmileyCode ) {
 1217- $key2 = $key;
 1218- $key2    =~ s/([\[\]\(\)\\\*\+\?\\\|])/\\$1/g;
 1219- $subject =~ s/(^$key2)|([ \n]$key2)/ $SmileyCode{$key}/g;
 1220- }
 1221- }
 1222- if ( $NM_Telltale && ( length( $FORM{'body'} ) < 4 ) ) {
 1223- $subject .= " $NM_Telltale";
 1224- }
 1225- if ( $Link_Telltale && $message_url ) {
 1226- $subject .= " $Link_Telltale";
 1227- }
 1228- if ( $Pic_Telltale && $image_url ) {
 1229- $subject .= " $Pic_Telltale";
 1230- }
 1231- }
 1232- 
 1233- if ( $tbb->{'post'}->{'EditPost'} ) {
 1234- @SubjectPrefixes = ();
 1235- }
 1236- if ( $subject && @SubjectPrefixes && !($followup) ) {
 1237- if ( $FORM{'subjectprefix'} ) {
 1238- foreach $key (@SubjectPrefixes) {
 1239- if ( $FORM{'subjectprefix'} eq $key ) {
 1240- $PrefixOK = 1;
 1241- last;
 1242- }
 1243- }
 1244- if ($PrefixOK) {
 1245- $ChosenPrefix = $FORM{'subjectprefix'};
 1246- if (%SmileyCode) {
 1247- foreach $key ( keys %SmileyCode ) {
 1248- $key2 = $key;
 1249- $key2         =~ s/([\[\]\(\)\\\*\+\?\\\|])/\\$1/g;
 1250- $ChosenPrefix =~ s/(^$key2)|([ \n]$key2)/ $SmileyCode{$key}/g;
 1251- }
 1252- }
 1253- $subject = $ChosenPrefix . " " . $subject;
 1254- }
 1255- else { $subject = ""; }
 1256- }
 1257- else { $subject = ""; }
 1258- }
 1259- else { $FORM{'subjectprefix'} = ""; }
 1260- 
 1261- if ( $FORM{'body'} ) { $body = "$FORM{'body'}"; }
 1262- unless ( $name && $subject ) { &Error( "9200", "9201" ); }
 1263- $picname  = "";
 1264- $tempname = $name;
 1265- $tempname =~ s/[^\w\.\-\']/\+/g;
 1266- $tempname =~ tr/A-Z/a-z/;
 1267- $Cleaned_tempname = $tempname;
 1268- $Cleaned_tempname =~ s/([\[\]\(\)\\\*\+\?\\\|])/\\$1/g;
 1269- 
 1270- if ( $FORM{'PostGraphic'} ) {
 1271- &make_dir( $ENV{DOCUMENT_ROOT} . $html_basedir . '/images' );
 1272- &make_dir($UserPicsDir);
 1273- opendir( PICFILES, "$UserPicsDir" );
 1274- @picfiles = readdir(PICFILES);
 1275- closedir(PICFILES);
 1276- foreach $picfile (@picfiles) {
 1277- next if ( $picfile =~ /^\./ );
 1278- next if ( $picfile =~ /^pic\d+\.gif$/ );
 1279- next if ( $picfile =~ /^pic\d+\.jpg$/ );
 1280- next if ( $picfile =~ /^pic\d+\.png$/ );
 1281- if ( $picfile =~ /^pic$Cleaned_tempname/ ) {
 1282- unlink "$UserPicsDir/$picfile";
 1283- }
 1284- elsif ( ( -M "$UserPicsDir/$picfile" ) > .5 ) {
 1285- unlink "$UserPicsDir/$picfile";
 1286- }
 1287- }
 1288- srand();
 1289- $tag = int( rand(1000) );
 1290- $tag = $tempname . $tag;
 1291- if    ( $PicType eq "GIF" ) { $picname = "pic$tag.gif"; }
 1292- elsif ( $PicType eq "JPG" ) { $picname = "pic$tag.jpg"; }
 1293- elsif ( $PicType eq "PNG" ) { $picname = "pic$tag.png"; }
 1294- else { &Error( "9650", "9651" ); }
 1295- if ( length( $FORM{'PostGraphic'} ) > ( $MaxGraphicSize * 1024 ) ) {
 1296- &Error( "9652", "9653" );
 1297- }
 1298- unless ( open( GRAPHIC, ">$UserPicsDir/$picname" ) ) {
 1299- &Error( "9654", "9655" );
 1300- }
 1301- binmode GRAPHIC;
 1302- print GRAPHIC $FORM{'PostGraphic'};
 1303- close(GRAPHIC);
 1304- $image_url = "$UserPicsURL/$picname";
 1305- if ( $Pic_Telltale && !( $subject =~ /$Cleaned_Pic_Telltale/ ) ) {
 1306- $subject .= " $Pic_Telltale";
 1307- }
 1308- }
 1309- if ( $FORM{'Preview'} ) {
 1310- &PreviewPost;
 1311- }
 1312- if ( $FORM{'EditPost'} ) {
 1313- $num    = int( $FORM{'EditPost'} );
 1314- $subdir = "bbs" . int( $num / 1000 );
 1315- if ( -e "$dir/_modbin/$num" ) {
 1316- $originalid = $dir . "/_modbin/" . $num;
 1317- $num        = $tbb->{'db'}->{'db_main'}->get_new_messagenumber();
 1318- if ( !$num ) {
 1319- $tbb->send_error_plain( "89400", "89401" );
 1320- exit;
 1321- }
 1322- $subdir = "bbs" . int( $num / 1000 );
 1323- $tbb->{'db'}->{'db_main'}->make_dir("$dir/$subdir");
 1324- rename( "$originalid", "$dir/$subdir/$num" );
 1325- $EditApproval = 1;
 1326- }
 1327- open( FILE, "$dir/$subdir/$num" ) || &Error( "9100", "9101" );
 1328- @message = <FILE>;
 1329- close(FILE);
 1330- foreach $line (@message) {
 1331- if ( $line =~ /^DATE>(.*)/i ) {
 1332- $todaydate = $1;
 1333- $TransferIntact .= $line;
 1334- }
 1335- elsif ( $line =~ /^IP_ADDRESS>(.*)/i ) {
 1336- $ENV{'REMOTE_HOST'} = $1;
 1337- $TransferIntact .= $line;
 1338- }
 1339- elsif ( $line =~ /^NEXT>/i ) {
 1340- $Transfer_NEXT = $line;
 1341- }
 1342- elsif (     ( $line =~ /^<!--/i )
 1343-         || ( $line =~ /^PASSWORD>/i )
 1344-         || ( $line =~ /^PREVIOUS>/i ) )
 1345- {
 1346- $TransferIntact .= $line;
 1347- }
 1348- }
 1349- $pdate = $psub = $pposter = $pprev = $pnext = $pcount = $padmin = $pip = "";
 1350- ( $pdate, $psub, $pposter, $pprev, $pnext, $pcount, $padmin, $pip ) = split( /\|/, $MessageList{$num} );
 1351- $FORM{'NewParent'} =~ s/ //g;
 1352- if ( ( $FORM{'NewParent'} == 0 ) && ($ReparentNoRestrict) ) {
 1353- $MessageList{$num} = join( "|", ( $pdate, $psub, $pposter, '', $pnext, $pcount, $padmin, $pip ) );
 1354- }
 1355- if ( -e ("$dir/$subdir/$FORM{'NewParent'}") ) {
 1356- $MessageList{$num} = join( "|", ( $pdate, $psub, $pposter, $FORM{'NewParent'}, $pnext, $pcount, $padmin, $pip ) );
 1357- }
 1358- if ( ( $FORM{'NewParent'} == 0 ) && ($ReparentNoRestrict) ) {
 1359- $TransferIntact =~ s/(PREVIOUS>).*/$1/g;
 1360- }
 1361- else {
 1362- $TransferIntact =~ s/PREVIOUS>.*/PREVIOUS>$FORM{'NewParent'}/g;
 1363- }
 1364- if ( !$Transfer_NEXT ) {
 1365- $Transfer_NEXT = "NEXT>\n";
 1366- }
 1367- $TransferIntact .= $Transfer_NEXT;
 1368- 
 1369- unless ( $FORM{'NewParent'} =~ /^\d+$/ ) {
 1370- $FORM{'NewParent'} = $pprev;
 1371- }
 1372- unless ( $FORM{'NewParent'} == $pprev ) {
 1373- 
 1374- $subdir = "bbs" . int( $pprev / 1000 );
 1375- if ( $pprev && ( -e ("$dir/$subdir/$pprev") ) ) {
 1376- &LockOpen( OLD, "$dir/$subdir/$pprev" );
 1377- @old = <OLD>;
 1378- chomp(@old);
 1379- seek( OLD, 0, 0 );
 1380- foreach $line (@old) {
 1381- if ( $line =~ /^NEXT>/i ) {
 1382- $line =~ s/$num//g;
 1383- $line =~ s/\s+/ /g;
 1384- }
 1385- print OLD "$line\n";
 1386- }
 1387- truncate( OLD, tell(OLD) );
 1388- &LockClose( OLD, "$dir/$subdir/$pprev" );
 1389- $mdate = $msub = $mposter = $mprev = $mnext = $mcount = $madmin = $mip = "";
 1390- ( $mdate, $msub, $mposter, $mprev, $mnext, $mcount, $madmin, $mip ) = split( /\|/, $MessageList{$pprev} );
 1391- $mnext =~ s/$num//g;
 1392- $mnext =~ s/\s+/ /g;
 1393- delete( $MessageList{$pprev} );
 1394- 
 1395- foreach $key ( $mdate, $msub, $mposter, $mprev, $mnext, $mcount, $madmin, $mip ) {
 1396- $MessageList{$pprev} .= "$key|";
 1397- }
 1398- }
 1399- $subdir = "bbs" . int( $FORM{'NewParent'} / 1000 );
 1400- if ( -e ("$dir/$subdir/$FORM{'NewParent'}") ) {
 1401- &LockOpen( NEW, "$dir/$subdir/$FORM{'NewParent'}" );
 1402- @new = <NEW>;
 1403- chomp(@new);
 1404- seek( NEW, 0, 0 );
 1405- foreach $line (@new) {
 1406- if ( $line =~ /^NEXT>/i ) {
 1407- $line .= " $num";
 1408- }
 1409- print NEW "$line\n";
 1410- }
 1411- truncate( NEW, tell(NEW) );
 1412- &LockClose( NEW, "$dir/$subdir/$FORM{'NewParent'}" );
 1413- $mdate = $msub = $mposter = $mprev = $mnext = $mcount = $madmin = $mip = "";
 1414- ( $mdate, $msub, $mposter, $mprev, $mnext, $mcount, $madmin, $mip ) = split( /\|/, $MessageList{ $FORM{'NewParent'} } );
 1415- $mnext .= " $num";
 1416- delete( $MessageList{ $FORM{'NewParent'} } );
 1417- foreach $key ( $mdate, $msub, $mposter, $mprev, $mnext, $mcount, $madmin, $mip ) {
 1418- $MessageList{ $FORM{'NewParent'} } .= "$key|";
 1419- }
 1420- }
 1421- }
 1422- }
 1423- else {
 1424- $new_body = $name . $email . $subject . $body . $image_url . $message_url_title . $message_url;
 1425- $new_body =~ s/\n/ /g;
 1426- unless ( -w "$dir" ) { &Error( "9410", "9411" ); }
 1427- open( DUPEDATA, "$dir/dupecheck.txt" );
 1428- $last_body = <DUPEDATA>;
 1429- close(DUPEDATA);
 1430- if ( $last_body eq $new_body ) { &Error( "9500", "9501" ); }
 1431- else {
 1432- open( DUPEDATA, ">$dir/dupecheck.txt" );
 1433- print DUPEDATA "$new_body";
 1434- close(DUPEDATA);
 1435- }
 1436- 
 1437- $num = $tbb->{'db'}->{'db_main'}->get_new_messagenumber();
 1438- if ( !$num ) {
 1439- $tbb->send_error_plain( "89400", "89401" );
 1440- exit;
 1441- }
 1442- 
 1443- if ( $image_url =~ /$Cleaned_tempname/ ) {
 1444- $tag = "";
 1445- $image_url =~ s/$Cleaned_tempname(\d+)\.gif/$num\.gif/g;
 1446- if ($1) { $tag = $1; }
 1447- $image_url =~ s/$Cleaned_tempname(\d+)\.jpg/$num\.jpg/g;
 1448- if ($1) { $tag = $1; }
 1449- $image_url =~ s/$Cleaned_tempname(\d+)\.png/$num\.png/g;
 1450- if ($1) { $tag = $1; }
 1451- rename( "$UserPicsDir/pic$tempname$tag.gif", "$UserPicsDir/pic$num.gif" );
 1452- rename( "$UserPicsDir/pic$tempname$tag.jpg", "$UserPicsDir/pic$num.jpg" );
 1453- rename( "$UserPicsDir/pic$tempname$tag.png", "$UserPicsDir/pic$num.png" );
 1454- }
 1455- }
 1456- $subdir = "bbs" . int( $num / 1000 );
 1457- unless ( -d "$dir/$subdir" ) {
 1458- mkdir( "$dir/$subdir", 0777 );
 1459- chmod 0777, "$dir/$subdir";
 1460- }
 1461- 
 1462- if ($PRO::VERSION) {
 1463- my $href = {};
 1464- if ( $FORM{'EditPost'} ) {
 1465- $href = &PRO::cb_message_edit_2( 'tbb'      => $main::tbb,
 1466-                                  'board_id' => $main::tbb->{'conf'}->{'board_id'},
 1467-                                  'msg_num'  => $num,
 1468-                                  'formid'   => $FORM{'formid'},
 1469-                                  'body'     => $body,
 1470- );
 1471- }
 1472- else {
 1473- $href = &PRO::cb_message_post_3( 'tbb'      => $main::tbb,
 1474-                                  'board_id' => $main::tbb->{'conf'}->{'board_id'},
 1475-                                  'msg_num'  => $num,
 1476-                                  'formid'   => $FORM{'formid'},
 1477-                                  'body'     => $body,
 1478- );
 1479- }
 1480- if ( $href->{'body'} ) {
 1481- $body = $href->{'body'};
 1482- }
 1483- if (    $href->{'media_count'}
 1484-      && $Pic_Telltale
 1485-      && !( $subject =~ /$Cleaned_Pic_Telltale/ ) )
 1486- {
 1487- $subject .= " $Pic_Telltale";
 1488- }
 1489- }
 1490- 
 1491- open( MESSAGE, ">$dir/$subdir/$num" )
 1492-     || &Error( "9400", "9401", "$dir/$subdir/$num" );
 1493- print MESSAGE "SUBJECT>$subject\n";
 1494- if ( $FORM{'Admin'} eq "AdminPost" ) {
 1495- print MESSAGE "ADMIN>AdminPost\n";
 1496- }
 1497- print MESSAGE "POSTER>$name\n";
 1498- print MESSAGE "EMAIL>$email\n";
 1499- 
 1500- unless ( $FORM{'wantnotice'} ) {
 1501- print MESSAGE "EMAILNOTICES>no\n";
 1502- }
 1503- 
 1504- if ( $FORM{'EditPost'} ) {
 1505- print MESSAGE "$TransferIntact";
 1506- }
 1507- else {
 1508- print MESSAGE "DATE>$todaydate\n";
 1509- print MESSAGE "IP_ADDRESS>$ENV{'REMOTE_HOST'}\n";
 1510- if ( $ENV{'REMOTE_USER'} ) {
 1511- print MESSAGE "<!--$ENV{'REMOTE_USER'}-->\n";
 1512- }
 1513- if ( $FORM{'password'} ) {
 1514- $password = crypt( $FORM{'password'}, "aa" );
 1515- print MESSAGE "PASSWORD>$password\n";
 1516- }
 1517- print MESSAGE "PREVIOUS>$followup\n";
 1518- print MESSAGE "NEXT>\n";
 1519- }
 1520- print MESSAGE "IMAGE>$image_url\n";
 1521- print MESSAGE "LINKNAME>$message_url_title\n";
 1522- print MESSAGE "LINKURL>$message_url\n";
 1523- print MESSAGE "$body\n";
 1524- close(MESSAGE);
 1525- }
 1526- 
 1527- if ( !$main::tbb->{'conf'}->{'search'}->{'enable'} ) {
 1528- if ( $FORM{'EditPost'} ) {
 1529- open( SEARCH, "$dir/searchterms.idx" );
 1530- &LockOpen( NEWSEARCH, "$dir/newsearchterms.idx" );
 1531- while (<SEARCH>) {
 1532- if (/^(\d+) /) {
 1533- $message = $1;
 1534- $subdir  = "bbs" . int( $message / 1000 );
 1535- if ( ( -e "$dir/$subdir/$message" ) && ( $message ne $num ) ) {
 1536- print NEWSEARCH "$_";
 1537- }
 1538- }
 1539- }
 1540- close(SEARCH);
 1541- &LockClose( NEWSEARCH, "$dir/newsearchterms.idx" );
 1542- rename( "$dir/newsearchterms.idx", "$dir/searchterms.idx" )
 1543-     || die "rename failed";
 1544- }
 1545- %wordlist = ();
 1546- @words    = ();
 1547- &LockOpen( SEARCH, "$dir/searchterms.idx", "a" );
 1548- print SEARCH "$num ";
 1549- $line = "$subject $name $body";
 1550- $line =~ s/<([^>]|\n)*(>|$)/ /g;
 1551- 
 1552- $line =~ tr/A-Z/a-z/;
 1553- 
 1554- $line =~ s/&[^;\s]*;/ /g;
 1555- $line = &prepare_searchindex($line);
 1556- $line =~ s/(\s)+/ /g;
 1557- @words = split( /\s/, $line );
 1558- foreach $word (@words) {
 1559- next if ( $wordlist{$word} );
 1560- $wordlist{$word} = 1;
 1561- print SEARCH "$word ";
 1562- }
 1563- print SEARCH "\n";
 1564- &LockClose( SEARCH, "$dir/searchterms.idx" );
 1565- 
 1566- }
 1567- 
 1568- if ($EditApproval) {
 1569- $FORM{'EditPost'} = "";
 1570- if   ( $FORM{'NewParent'} ) { $followup = int( $FORM{'NewParent'} ); }
 1571- else                        { $followup = $prev; }
 1572- }
 1573- 
 1574- if ($followup) {
 1575- $subdir = "bbs" . int( $followup / 1000 );
 1576- open( FOLLOWUP, "$dir/$subdir/$followup" );
 1577- @followup_lines = <FOLLOWUP>;
 1578- chomp(@followup_lines);
 1579- close(FOLLOWUP);
 1580- open( FOLLOWUP, ">$dir/$subdir/$followup" );
 1581- foreach $line (@followup_lines) {
 1582- if ( $line =~ /^EMAILNOTICES>/i ) {
 1583- $fuwantnotice = "no";
 1584- }
 1585- elsif ( $line =~ /^EMAIL>(.*)/i ) {
 1586- $fuemail = $1;
 1587- }
 1588- if ( $line =~ /^NEXT>/ ) {
 1589- 
 1590- if ( $line !~ /\b$num\b/ ) {
 1591- my @nexts = split( /\s+/, $line );
 1592- push( @nexts, $num );
 1593- @nexts = sort { $a <=> $b } @nexts;
 1594- print FOLLOWUP join( ' ', @nexts ), "\n";
 1595- }
 1596- }
 1597- else {
 1598- print FOLLOWUP "$line\n";
 1599- }
 1600- }
 1601- close(FOLLOWUP);
 1602- $fudate = $fusub = $fuposter = $fuprev = $funext = $fucount = $fuadmin = $fuip = "";
 1603- ( $fudate, $fusub, $fuposter, $fuprev, $funext, $fucount, $fuadmin, $fuip ) = split( /\|/, $MessageList{$followup} );
 1604- if ( $funext !~ /\b$num\b/ ) {
 1605- my @nexts = split( /\s+/, $funext );
 1606- push( @nexts, $num );
 1607- @nexts = sort { $a <=> $b } @nexts;
 1608- $funext = join( ' ', @nexts );
 1609- }
 1610- delete( $MessageList{$followup} );
 1611- foreach $key ( $fudate, $fusub, $fuposter, $fuprev, $funext, $fucount, $fuadmin, $fuip ) {
 1612- $MessageList{$followup} .= "$key|";
 1613- }
 1614- $fusub    =~ s/&pipe;/\|/g;
 1615- $fuposter =~ s/&pipe;/\|/g;
 1616- }
 1617- if (    $mailprog
 1618-      && ( !( $FORM{'EditPost'} ) )
 1619-      && !($move_only) )
 1620- {
 1621- 
 1622- my %text = %{ $main::tbb->{'conf'}->{'text'} };
 1623- my $QS0  = $main::tbb->{'conf'}->{'main'}->{'QS0'};
 1624- my $QS1  = $main::tbb->{'conf'}->{'main'}->{'QS1'};
 1625- my $QS2  = $main::tbb->{'conf'}->{'main'}->{'QS2'};
 1626- 
 1627- $FORM{'subject'} = &UnWebify( $FORM{'subject'} );
 1628- if ( length( $FORM{'subject'} ) > 50 ) {
 1629- $FORM{'subject'} = substr( $FORM{'subject'}, 0, 46 );
 1630- $FORM{'subject'} .= "....";
 1631- }
 1632- $FORM{'name'} = &UnWebify( $FORM{'name'} );
 1633- if ( length( $FORM{'name'} ) > 15 ) {
 1634- $FORM{'name'} = substr( $FORM{'name'}, 0, 11 );
 1635- $FORM{'name'} .= "....";
 1636- }
 1637- $FORM{'body'} .= "\n";
 1638- $FORM{'body'}      = &UnWebify( $FORM{'body'} );
 1639- $message_url_title = &UnWebify($message_url_title);
 1640- $body              = $text{'7000'} . "\r\n\r\n" . $text{'7001'} . "\r\n\r\n";
 1641- $body .= "$text{'7600'} (#$num) $FORM{'subject'}\r\n";
 1642- $body .= "$text{'7603'} <$cgiurl" . "$QS0" . "rev" . "$QS2" . "$num>\r\n";
 1643- $body .= "$text{'7601'} $FORM{'name'}";
 1644- $body .= "\r\n";
 1645- $body .= "$text{'7602'} ";
 1646- $body .= &PrintDate($todaydate) . "\r\n\r\n";
 1647- 
 1648- if ($followup) {
 1649- $subjectfu = &UnWebify($fusub);
 1650- if ( length($subjectfu) > 50 ) {
 1651- $subjectfu = substr( $subjectfu, 0, 46 );
 1652- $subjectfu .= "....";
 1653- }
 1654- $posterfu = &UnWebify($fuposter);
 1655- if ( length($posterfu) > 15 ) {
 1656- $posterfu = substr( $posterfu, 0, 11 );
 1657- $posterfu .= "....";
 1658- }
 1659- $body .= "$text{'7604'} (#$followup) $subjectfu\r\n";
 1660- $body .= "$text{'7605'} $posterfu\r\n";
 1661- $body .= "$text{'7606'} ";
 1662- $body .= &PrintDate($fudate) . "\r\n\r\n";
 1663- }
 1664- unless ($HeaderOnly) {
 1665- $body .= $FORM{'body'} . "\r\n";
 1666- if ( $message_url && $message_url_title ) {
 1667- $body .= "$text{'7607'} $message_url_title\r\n";
 1668- $body .= "$text{'7608'} <$message_url>\r\n\r\n";
 1669- }
 1670- if ($image_url) {
 1671- $body .= "$text{'7609'} <$image_url>\r\n\r\n";
 1672- }
 1673- }
 1674- $body .= $text{'7001'} . "\r\n\r\n" . $text{'7002'};
 1675- $body .= "\r\n\r\n";
 1676- @bodylines = split( /\n/, $body );
 1677- $body = "";
 1678- foreach $bodyline (@bodylines) {
 1679- if ( $bodyline =~ /^\./ ) {
 1680- $bodyline = "." . $bodyline;
 1681- }
 1682- $quotewrap = 0;
 1683- @quotedwords = split( /\s/, $bodyline );
 1684- foreach $quotedword (@quotedwords) {
 1685- $quotewrap += length($quotedword) + 1;
 1686- if ( $quotewrap > 79 ) {
 1687- if ( $quotedword =~ /^\./ ) {
 1688- $body .= "\r\n.$quotedword ";
 1689- }
 1690- else {
 1691- $body .= "\r\n$quotedword ";
 1692- }
 1693- $quotewrap = length($quotedword) + 1;
 1694- }
 1695- else {
 1696- $body .= "$quotedword ";
 1697- }
 1698- }
 1699- $body .= "\r\n";
 1700- }
 1701- $bcc = "";
 1702- if ( $email_list == 1 ) {
 1703- if ( -e "$dir/addresses.txt" ) {
 1704- open( ADDRESSES, "$dir/addresses.txt" );
 1705- @addresses = <ADDRESSES>;
 1706- chomp(@addresses);
 1707- close(ADDRESSES);
 1708- foreach $address (@addresses) {
 1709- unless (    ( $address =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|,|;|\// || $address !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,6}|[0-9]{1,3})(\]?)$/ )
 1710-          || ( $email && ( $address =~ /$email/i ) )
 1711-          || ( $fuemail
 1712-               && ( $address =~ /$fuemail/i ) )
 1713-     )
 1714- {
 1715- $bcc .= ", " . $address;
 1716- }
 1717- if ( $fuemail
 1718-      && ( $address =~ /$fuemail/i ) )
 1719- {
 1720- $onrecipientlist = 1;
 1721- }
 1722- }
 1723- $bcc =~ s/^, //;
 1724- }
 1725- &SendMail;
 1726- }
 1727- if ($fuemail) {
 1728- $bcc = "";
 1729- unless (    ( ( $fuwantnotice eq "no" ) && !$onrecipientlist )
 1730-          || ( $fuemail eq $email ) )
 1731- {
 1732- &SendMail($fuemail);
 1733- }
 1734- }
 1735- }
 1736- if ( $MessageList{$num} > 0 ) {
 1737- $date = $sub = $poster = $prev = $next = $count = $admin = $ip = "";
 1738- ( $date, $sub, $poster, $prev, $next, $count, $admin, $ip ) =
 1739-     split( /\|/, $MessageList{$num} );
 1740- $todaydate = $date;
 1741- if   ( $FORM{'NewParent'} ) { $followup = int( $FORM{'NewParent'} ); }
 1742- else                        { $followup = $prev; }
 1743- $ENV{'REMOTE_HOST'} = $ip;
 1744- }
 1745- else {
 1746- $next  = "";
 1747- $count = "";
 1748- }
 1749- unless ( $FORM{'Admin'} eq "AdminPost" ) { $FORM{'Admin'} = ""; }
 1750- delete( $MessageList{$num} );
 1751- $subject =~ s/\|/&pipe;/g;
 1752- $name    =~ s/\|/&pipe;/g;
 1753- foreach $key ( $todaydate, $subject, $name, $followup, $next, $count, $FORM{'Admin'}, $ENV{'REMOTE_HOST'} ) {
 1754- $MessageList{$num} .= "$key|";
 1755- }
 1756- 
 1757- if ($PRO::VERSION) {
 1758- &PRO::cb_message_post_4( 'tbb'         => $main::tbb,
 1759-                          'msg_num'     => $num,
 1760-                          'tied_db_ref' => \%MessageList,
 1761- );
 1762- }
 1763- 
 1764- if ($approve_num) {
 1765- &MessageDBM_close();
 1766- return ( $num, $subject );
 1767- }
 1768- 
 1769- &Header( $text{'1600'}, $MessageHeaderFile, "refreshalways", "$num" );
 1770- my %subnav_args = ( 'msg_num'        => $num,
 1771-                     'refresh_anchor' => $num,
 1772-                     'moderated'      => $Moderated,
 1773- );
 1774- ( $navbar_top, $navbar_bottom ) =
 1775-     $main::tbb->{'tbb_html'}->get_navbar_HTML( 'sub_navbar'  => 'post',
 1776-                                                'subnav_args' => \%subnav_args, );
 1777- unless ($TopNavbarNoPrint) {
 1778- print "<div id='nb_top'>\n" . $navbar_top . "</div>\n";
 1779- }
 1780- print "<div id='glob_header'>\n", $cust{'glob_header_s'};
 1781- if ($printboardname) { print "<h2>$boardname</h2>\n"; }
 1782- 
 1783- if (    ( $tbb->{'get'}->{'src'} eq 'moderate' )
 1784-      || ( $tbb->{'post'}->{'src'} eq 'moderate' ) )
 1785- {
 1786- print $cust{'glob_header_s'} . "</div>\n" . "<p class='ac'>$text{'12129'}</p>\n";
 1787- }
 1788- elsif ( $tbb->{'post'}->{'action'} =~ /mv_park_(\d+)/ ) {
 1789- print $cust{'glob_header_s'} . "</div>\n" . "<p class='ac'>$text{'12158'}" . " \"" . $parking_folders{$1}->[0] . "\"</p>\n";
 1790- }
 1791- else {
 1792- print "<h3>$text{'1600'}</h3>\n" . $cust{'glob_header_s'} . "</div>\n" . "<p class='ac'>$text{'1601'}</p>\n";
 1793- }
 1794- &Footer( $MessageFooterFile, "return", "refreshalways" );
 1795- } ## end sub PostAdminMessage
 1796- 
 1797- sub SetAdminCookieData {
 1798- unless ($CookieAlreadyRead) {
 1799- &GetCookie($boardname);
 1800- $Cookies{'UseFrames'} = "No";
 1801- }
 1802- return if ( $CookieReadOnly > 0 );
 1803- unless ( $FORM{'ListType'} ) { $FORM{'ListType'} = $Cookies{'listtype'}; }
 1804- unless ( $FORM{'ListTime'} ) { $FORM{'ListTime'} = $Cookies{'listtime'}; }
 1805- unless ( $FORM{'password'} ) { $FORM{'password'} = $Cookies{'password'}; }
 1806- if ( $FORM{'KeySearch'} eq "No" ) {
 1807- $listtype = $FORM{'ListType'};
 1808- $listtime = $FORM{'ListTime'};
 1809- }
 1810- 
 1811- if (    ( $ENV{'QUERY_STRING'} =~ /read=(\d+)/i )
 1812-      || ( $ENV{'QUERY_STRING'} =~ /moderate=(\d+)/i )
 1813-      || ( $ENV{'QUERY_STRING'} =~ /moderate/i )
 1814-      || ( $ENV{'QUERY_STRING'} =~ /topstats/i )
 1815-      || ( $ENV{'QUERY_STRING'} =~ /$QueryMode{'form'}=(\d+)/i )
 1816-      || ( $ENV{'QUERY_STRING'} =~ /edit=(\d+)/i )
 1817-      || ( $ENV{'QUERY_STRING'} =~ /resetpass/i )
 1818-      || ( $ENV{'QUERY_STRING'} =~ /addresslist/i )
 1819-      || ( $ENV{'QUERY_STRING'} =~ /subscribe/i )
 1820-      || ( $ENV{'QUERY_STRING'} =~ /search/i )
 1821-      || ( $ENV{'QUERY_STRING'} =~ /reconfigure/i )
 1822-      || ( $ENV{'QUERY_STRING'} =~ /delete/i )
 1823-      || ( $ENV{'QUERY_STRING'} =~ /profile/i )
 1824-      || ( $ENV{'QUERY_STRING'} =~ /$QueryMode{'profilesave'}/ )
 1825-      || ( $ENV{'QUERY_STRING'} =~ /$QueryMode{'profileedit'}/ )
 1826-      || $FORM{'EditPost'}
 1827-      || $FORM{'ApprovePost'} )
 1828- {
 1829- return;
 1830- }
 1831- if ( $ENV{'QUERY_STRING'} =~ /$QueryMode{'post'}/ ) {
 1832- unless ( $FORM{'wantnotice'} ) { $Cookies{'wantnotice'} = "no"; }
 1833- else                           { $Cookies{'wantnotice'} = "yes"; }
 1834- }
 1835- unless ( ( $ENV{'QUERY_STRING'} =~ /$QueryMode{'post'}/ )
 1836-          || $FORM{'ResetConfig'} )
 1837- {
 1838- if ( !$name )        { $name        = $Cookies{'name'}; }
 1839- if ( !$email )       { $email       = $Cookies{'email'}; }
 1840- if ( !$message_url ) { $message_url = $Cookies{'linkurl'}; }
 1841- if ( !$message_url_title ) {
 1842- $message_url_title = $Cookies{'linkname'};
 1843- }
 1844- if ( !$image_url ) { $image_url = $Cookies{'imageurl'}; }
 1845- }
 1846- if ( !$listtype ) { $listtype = $Cookies{'listtype'}; }
 1847- if ( !$listtime ) { $listtime = $Cookies{'listtime'}; }
 1848- unless ( $Cookies{'lastvisit'} ) {
 1849- $Cookies{'lastvisit'}   = $lastvisit = $todaydate;
 1850- $Cookies{'lastmessage'} = $lastseen  = $lastmessage;
 1851- $Cookies{'thisvisit'}   = $thisvisit = $todaydate;
 1852- $Cookies{'thismessage'} = $thisseen  = $lastmessage;
 1853- }
 1854- if ( $Cookies{'timestamp'}
 1855-      && ( ( $time - $Cookies{'timestamp'} ) > $SessionTime ) )
 1856- {
 1857- $Cookies{'lastvisit'}   = $lastvisit = $Cookies{'thisvisit'};
 1858- $Cookies{'lastmessage'} = $lastseen  = $Cookies{'thismessage'};
 1859- $Cookies{'thisvisit'}   = $thisvisit = $todaydate;
 1860- $Cookies{'thismessage'} = $thisseen  = $lastmessage;
 1861- }
 1862- elsif (    ( $ENV{'QUERY_STRING'} =~ /resetnew/i )
 1863-         && ($AllowRemoveNew) )
 1864- {
 1865- open( NUMBER, "$dir/data.txt" );
 1866- $lastmessage = <NUMBER>;
 1867- close(NUMBER);
 1868- $Cookies{'lastvisit'}   = $lastvisit = $todaydate;
 1869- $Cookies{'lastmessage'} = $lastseen  = $lastmessage;
 1870- $Cookies{'thisvisit'}   = $thisvisit = $todaydate + 1;
 1871- $Cookies{'thismessage'} = $thisseen  = $lastmessage;
 1872- }
 1873- else {
 1874- $lastvisit = $Cookies{'lastvisit'};
 1875- $lastseen  = $Cookies{'lastmessage'};
 1876- $thisvisit = $Cookies{'thisvisit'};
 1877- $thisseen  = $Cookies{'thismessage'};
 1878- }
 1879- &WriteCookie;
 1880- } ## end sub SetAdminCookieData
 1881- 
 1882- sub flag_naughty {
 1883- my $line = shift;
 1884- foreach $naughtyword (@naughtywords) {
 1885- next unless $naughtyword;
 1886- $line =~ s/($naughtyword)/\<span class='cause_mod'\>$1\<\/span\>/gi;
 1887- }
 1888- return $line;
 1889- } ## end sub flag_naughty
 1890- 
 1891- sub flag_ip {
 1892- my $ip = shift;
 1893- if ($BannedIPsFile) {
 1894- open( BANNED, "$BannedIPsFile" );
 1895- @bannedips = <BANNED>;
 1896- chomp(@bannedips);
 1897- close(BANNED);
 1898- foreach $bannedip (@bannedips) {
 1899- next unless $bannedip;
 1900- $bannedip =~ s/^([^\s]*)\s.*$/$1/g;
 1901- $ip       =~ s/($bannedip)/\<span class='cause_mod'\>$1\<\/span\>/gi;
 1902- }
 1903- }
 1904- return $ip;
 1905- } ## end sub flag_ip
 1906- 
 1907- 1;