F:\WEBSITES\testbed\zipped\yabb_svn_new\branches\2.5.2\cgi-bin\yabb2\Sources\SetStatus.pl F:\WEBSITES\testbed\zipped\yabb_svn_new\trunk\cgi-bin\yabb2\Sources\SetStatus.pm
############################################################################### ###############################################################################
# SetStatus.pl                                                                # # SetStatus.pm                                                                #
  # $Date: 01.05.16 $                                                           #
############################################################################### ###############################################################################
# YaBB: Yet another Bulletin Board                                            # # YaBB: Yet another Bulletin Board                                            #
# Open-Source Community Software for Webmasters                               # # Open-Source Community Software for Webmasters                               #
# Version:        YaBB 2.5.2                                                  # # Version:        YaBB 2.6.12                                                 #
# Packaged:       October 21, 2012                                            # # Packaged:       January 5, 2016                                             #
# Distributed by: http://www.yabbforum.com                                    # # Distributed by: http://www.yabbforum.com                                    #
# =========================================================================== # # =========================================================================== #
# Copyright (c) 2000-2012 YaBB (www.yabbforum.com) - All Rights Reserved.     # # Copyright (c) 2000-2016 YaBB (www.yabbforum.com) - All Rights Reserved.     #
# Software by:  The YaBB Development Team                                     # # Software by:  The YaBB Development Team                                     #
#               with assistance from the YaBB community.                      # #               with assistance from the YaBB community.                      #
############################################################################### ###############################################################################
  use CGI::Carp qw(fatalsToBrowser);
  our $VERSION = '2.6.12';
   
$setstatusplver = 'YaBB 2.5.2 $Revision: 1.0 $'; $setstatuspmver = 'YaBB 2.6.12 $Revision: 1710 $';
if ($action eq 'detailedversion') { return 1; } if ( $action eq 'detailedversion' ) { return 1; }
   
sub SetStatus { sub SetStatus {
   &fatal_error('no_access') unless ($iammod || $iamadmin || $iamgmod);     if ( !$staff ) { fatal_error('no_access'); } 
   
   my $start      = $INFO{'start'} || 0;    my $start = $INFO{'start'} || 0;
   my $status     = substr($INFO{'action'}, 0, 1) || substr($FORM{'action'}, 0, 1);     my $status = substr( $INFO{'action'}, 0, 1 ) 
   my $threadid   = $INFO{'thread'};       || substr $FORM{'action'}, 0, 1; 
   my $thisstatus = '';     my $threadid   = $INFO{'thread'}; 
     my $thisstatus = q{};
   if (!$currentboard) {  
       &MessageTotals("load", $threadid);     if ( !$currentboard ) { 
       $currentboard = ${$threadid}{'board'};         MessageTotals( 'load', $threadid ); 
   }         $currentboard = ${$threadid}{'board'}; 
     }
   fopen(BOARDFILE, "+<$boardsdir/$currentboard.txt") || &fatal_error("cannot_open","$boardsdir/$currentboard.txt", 1);  
   my @boardfile = <BOARDFILE>;     fopen( BOARDFILE, "<$boardsdir/$currentboard.txt" ) 
   for (my $line = 0; $line < @boardfile; $line++) {       or fatal_error( 'cannot_open', "$boardsdir/$currentboard.txt", 1 ); 
       if ($boardfile[$line] =~ m~\A$threadid\|~) {     my @boardfile = <BOARDFILE>; 
           my ($mnum, $msub, $mname, $memail, $mdate, $mreplies, $musername, $micon, $mstate) = split(/\|/, $boardfile[$line]);     fclose( BOARDFILE ); 
           chomp $mstate;     for my $line ( 0 .. $#boardfile ) { 
         if ( $boardfile[$line] =~ m/\A$threadid\|/xsm ) {
           $mstate .= 0 if $mstate !~ /0/;             my ( 
                 $mnum,     $msub,      $mname, $memail, $mdate,
           if ($mstate =~ /$status/) {                 $mreplies, $musername, $micon, $mstate 
               $mstate =~ s/$status//ig;             ) = split /\|/xsm, $boardfile[$line]; 
               # Sticky-ing redirects to messageindex always             chomp $mstate; 
               # Also handle message index  
               if ($status eq 's' || $INFO{'tomessageindex'}) {             if ( $mstate !~ /0/sm ) { $mstate .= '0'; } 
                   $yySetLocation = qq~$scripturl?board=$currentboard~;  
               } else {            if ( $mstate =~ /$status/xsm ) {
                   $yySetLocation = qq~$scripturl?num=$threadid/$start~;                 $mstate =~ s/$status//igxsm; 
               }  
           } else {                 # Sticky-ing redirects to messageindex always 
               $mstate .= $status;                 # Also handle message index 
               $yySetLocation = qq~$scripturl?board=$currentboard~;                 if ( $status eq 's' || $INFO{'tomessageindex'} ) { 
           }                     $yySetLocation = qq~$scripturl?board=$currentboard~; 
           $thisstatus = $mstate;                 } 
                 else {
           $boardfile[$line] = "$mnum|$msub|$mname|$memail|$mdate|$mreplies|$musername|$micon|$mstate\n";                     $yySetLocation = qq~$scripturl?num=$threadid/$start~; 
                 }
       }            }
   }             else { 
   truncate BOARDFILE, 0;                 $mstate .= $status; 
   seek BOARDFILE, 0, 0;                 $yySetLocation = qq~$scripturl?board=$currentboard~; 
   print BOARDFILE @boardfile;             } 
   fclose(BOARDFILE);             $thisstatus = $mstate; 
   
   &MessageTotals("load",$threadid);             $boardfile[$line] = 
   ${$threadid}{'threadstatus'} = $thisstatus;  "$mnum|$msub|$mname|$memail|$mdate|$mreplies|$musername|$micon|$mstate\n"; 
   &MessageTotals("update",$threadid);         } 
     }
   &BoardSetLastInfo($currentboard,\@boardfile);     fopen( BOARDFILE, ">$boardsdir/$currentboard.txt" ) 
   if (!$INFO{'moveit'}) {       or fatal_error( 'cannot_open', "$boardsdir/$currentboard.txt", 1 ); 
       &redirectexit;     print {BOARDFILE} @boardfile or croak "$croak{'print'} BOARDFILE"; 
   }     fclose(BOARDFILE); 
   
     MessageTotals( 'load', $threadid );
     ${$threadid}{'threadstatus'} = $thisstatus;
     MessageTotals( 'update', $threadid );
   
     BoardSetLastInfo( $currentboard, \@boardfile );
     if ( !$INFO{'moveit'} ) {
         redirectexit();
     }
     return;
} }
   
1; 1;