###############################################################################
# UB_DoReply.src                                                              #
###############################################################################
# UltraBoard 2000 by UltraScripts.com, Inc.                                   #
# Scripts written by Jacky Wing Wa Yung, WebMaster@UltraScripts.com           #
# Available from http://www.UltraBoard.org/                                   #
# =========================================================================== #
# COPYRIGHT NOTICE :                                                          #
#                                                                             #
# Copyright (c) 1999-2000 UltraScripts.com, Inc. All Rights Reserved.         #
#                                                                             #
# This program is being distributed as shareware. It may be used and modified #
# free for personal, government or non-profit. Any commercial use must be     #
# registered. However, modified versions cannot be sold or distributed. You   #
# cannot alter the copyright and "powered by" notices throughout the scripts. #
# These notices must be clearly visible to the end users.                     #
#                                                                             #
# WARRANTY DISCLAIMER:                                                        #
#                                                                             #
# THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT #
# ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR       #
# FITNESS FOR A PARTICULAR PURPOSE.                                           #
###############################################################################

package Source;

#use strict;
use File::Copy;

sub DoReply {

  if (-e $SYSTEM::TEMP_PATH."/Posting-$ENV{'REMOTE_ADDR'}.tmp") {
    &Standard::FileOpen(*POSTING, "r", $SYSTEM::TEMP_PATH."/Posting-$ENV{'REMOTE_ADDR'}.tmp");
      my ($time) = join ("", <POSTING>);
    close (POSTING);

    if (time < ($time + 20)) {
      &Error("DOUBLE_POSTING")
    } else {
      unlink ($SYSTEM::TEMP_PATH."/Posting-$ENV{'REMOTE_ADDR'}.tmp");
    }
  }

# =========================================================================== #
# Checking Permission

  (
    my ($Board) = &DB::BinarySelect (
      TABLE   => "Boards",
      COLUMNS => ["ID", "TITLE", "CATEGORY", "STATUS", "UB_CODES", "HTML_TAGS", "FILE_ATTACH"],
      KEY     => $UB::QUERY{'BID'}
    )
  ) || &HTML::Error(MESSAGE => $DB::Error);

  (
    my ($Category) = &DB::BinarySelect (
      TABLE   => "Categories",
      COLUMNS => ["ID", "TITLE"],
      KEY     => $Board->{'CATEGORY'}
    )
  ) || &HTML::Error(MESSAGE => $DB::Error);

  if ( ( ($UB::MEMBER{'LOGIN'} == 1) && ($UB::MEMBER{'LEVEL'} ne "70") && ($UB::MEMBER{'LEVEL'} ne "100") ) || ($UB::MEMBER{'LOGIN'} == 0)) {
    if (($Board->{'STATUS'} == 50) || ($Board->{'STATUS'} == 70)) {
      &Standard::FileOpen(*DATA, "r", "$SYSTEM::DB_PATH/B".$Board->{'ID'}."/REPLY-LEVEL-00.dat");
        my $REPLY_LEVEL_00 = join ("", <DATA>);
      close (DATA);

      if ($REPLY_LEVEL_00 ne "*") {
        if ($UB::MEMBER{'LOGIN'} == 1) {
          &Login unless &Standard::GetBoardPermission ($Board->{'ID'}, "REPLY", $UB::MEMBER{'LEVEL'}, $UB::MEMBER{'GROUP'});
        } else {
          &Login;
        }
      }
    } elsif ($Board->{'STATUS'} == 30) {
      &HTML::Error(CODE => "BOARD_INACTIVATE");
    } elsif ($Board->{'STATUS'} != 70) {
      &HTML::Error(CODE => "BOARD_INACTIVATE");
    }
  }

  my $SendMail = 0;
  if ($SYSTEM::SENDMAIL == 1) {
    if ( ($SYSTEM::MAIL_SYSTEM eq "SMTP") && ($SYSTEM::SMTP_PATH ne "") ) {
      $SendMail = &Standard::Require("SMTP.lib", "$UB::LIBRARIES_PATH/SMTP.lib");
    } elsif ( ($SYSTEM::MAIL_SYSTEM eq "Sendmail") && ($SYSTEM::SENDMAIL_PATH ne "") ) {
      $SendMail = &Standard::Require("Sendmail.lib", "$UB::LIBRARIES_PATH/Sendmail.lib");
    }
  }

  &Standard::Require("UltraBoard.lib", "$UB::LIBRARIES_PATH/UltraBoard.lib") if ($Board->{'UB_CODES'} == 1);
  &Standard::Require("Thread.lib", "$UB::LIBRARIES_PATH/Thread.lib");

# =========================================================================== #
# Verify Variables

  # checking missing fields
  if ($UB::QUERY{'FORM_SUBJECT'} eq "") { &Error("MISS_SUBJECT") };
  if ($UB::QUERY{'FORM_MESSAGE'} eq "") { &Error("MISS_MESSAGE") };

  if ($UB::MEMBER{'LOGIN'} != 1) {
    if ($UB::QUERY{'FORM_NICKNAME'} eq "") { &Error("MISS_NICKNAME") };
    if ($UB::QUERY{'FORM_EMAIL'}    eq "") { &Error("MISS_EMAIL")    };

    # checking invalid nickname
    if (
      (length ($UB::QUERY{'FORM_NICKNAME'}) > 32)           ||
      (length ($UB::QUERY{'FORM_NICKNAME'}) <  2)
    ) {
      &Error("INVALID_NICKNAME");
    }

    # checking invalid email
    if (
      ($UB::QUERY{'FORM_EMAIL'} !~ /[\.\w\-]+\@[\.\w\-]+\.[\.\w\-]+/) ||
      (length ($UB::QUERY{'FORM_EMAIL'}) > 64)
    ) {
      &Error("INVALID_EMAIL");
    }
  }

  my $FileName = "";
  my ($AttachFile, $tmpAttachFile);
  $AttachFile = $UB::CGI->param('FORM_ATTACH');
  if (($AttachFile) && ($UB::MEMBER{'LOGIN'} == 1) && ($Board->{'FILE_ATTACH'} == 1)) {
    my $Type = $UB::CGI->uploadInfo($AttachFile)->{'Content-Type'};

    $tmpAttachFile = $UB::CGI->tmpFileName($AttachFile);

    my $Found = 0;
    foreach (@GENERAL::ATTACH_TYPE) {
      if (/^$Type$/i) {
        $Found = 1;
      }
    }

    if ($Found == 0) {
      &Error("INVALID_ATTACH");
    }

    my ($Size) = (stat ($tmpAttachFile))[7];

    (
      my ($Group) = &DB::BinarySelect (
        TABLE   => "Groups",
        COLUMNS => ["ID", "MAX_FILE_SIZE"],
        KEY     => $UB::MEMBER{'GROUP'}
      )
    ) || &HTML::Error(MESSAGE => $DB::Error);

    if ($Size > ($Group->{'MAX_FILE_SIZE'} * 1024)) {
      &Error("INVALID_ATTACH");
    }

    $AttachFile =~ /([^\\\/]+)$/;
    $FileName = $1;
  } elsif (($UB::QUERY{'TMP'}) && ($UB::QUERY{'ATTACH'}) && (-e $SYSTEM::TEMP_PATH."/Post-".$Board->{'ID'}."-".$UB::QUERY{'TMP'}."-".$UB::QUERY{'ATTACH'})) {
    $FileName = $UB::QUERY{'ATTACH'};
  }

  # checking length of fields
  if (length($UB::QUERY{'FORM_SUBJECT'}) > $GENERAL::MAX_SUBJECT_LENGTH) {
    &Error("OVER_SUBJECT");
  }

  if (length($UB::QUERY{'FORM_MESSAGE'}) > $GENERAL::MAX_MESSAGE_LENGTH) {
    &Error("OVER_MESSAGE");
  }

# =========================================================================== #
# Assign Variables
  my %FORM;

  if ($UB::MEMBER{'LOGIN'} != 1) {
    $FORM{'NICKNAME'}    = $UB::QUERY{'FORM_NICKNAME'};
    $FORM{'NICKNAME'}    = &Standard::EncodeHTML($FORM{'NICKNAME'});

    $FORM{'EMAIL'}       = lc ($UB::QUERY{'FORM_EMAIL'});

    #push (
    #  @UB::COOKIES,
    #  $UB::CGI->cookie(
    #    -name     => "NICKNAME",
    #    -value    => $FORM{'NICKNAME'},
    #    -expires  => '+1Y'
    #  )
    #);

    #push (
    #  @UB::COOKIES,
    #  $UB::CGI->cookie(
    #    -name     => "EMAIL",
    #    -value    => $FORM{'EMAIL'},
    #    -expires  => '+1Y'
    #  )
    #);

    $UB::COOKIES{'NICKNAME'} = $FORM{'NICKNAME'};
    $UB::COOKIES{'EMAIL'}    = $FORM{'EMAIL'};
  } else {
    $FORM{'USERNAME'}    = $UB::MEMBER{'USERNAME'};

    $FORM{'NICKNAME'}    = $UB::MEMBER{'NICKNAME'};

    unless ($UB::MEMBER{'HIDE_EMAIL'} == 1) {
      $FORM{'EMAIL'}       = lc ($UB::MEMBER{'EMAIL'});
    }

    $FORM{'MEMBER_LEVEL'} = $UB::MEMBER{'LEVEL_TEXT'};
    $FORM{'MEMBER_GROUP'} = $UB::MEMBER{'GROUP_TEXT'};
  }

  $FORM{'SUBJECT'}       = $UB::QUERY{'FORM_SUBJECT'};
  $FORM{'SUBJECT'}       = &Standard::EncodeHTML($FORM{'SUBJECT'});

  $FORM{'MESSAGE'}       = $UB::QUERY{'FORM_MESSAGE'};
  $FORM{'MESSAGE'}       = &Standard::EncodeHTML($FORM{'MESSAGE'});

  $FORM{'POST_SECOND'}   = time;

  $FORM{'POST_DATE'}     = &Standard::ConvertEpochToDate($FORM{'POST_SECOND'});
  $FORM{'POST_TIME'}     = &Standard::ConvertEpochToTime($FORM{'POST_SECOND'});

  $FORM{'LAST_UPDATE_SECOND'} = $FORM{'POST_SECOND'};
  $FORM{'LAST_UPDATE_DATE'  } = $FORM{ 'POST_DATE' };
  $FORM{'LAST_UPDATE_TIME'  } = $FORM{ 'POST_TIME' };


  if (
    ($UB::QUERY{'FORM_EMAIL_NOTIFY'} eq  "1") ||
    ($UB::QUERY{'FORM_EMAIL_NOTIFY'} eq "on")
  ) {
    $FORM{'REPLY_NOTIFY'}   = 1;
  } else {
    $FORM{'REPLY_NOTIFY'}   = 0;
  }

  if (
    ($UB::QUERY{'FORM_SIGNATURE_INCLUDE'} eq  "1") ||
    ($UB::QUERY{'FORM_SIGNATURE_INCLUDE'} eq "on")
  ) {
    $FORM{'SIGNATURE'}  = 1;
  } else {
    $FORM{'SIGNATURE'}  = 0;
  }

  $FORM{'IP'}         = $ENV{'REMOTE_ADDR'};

  $FORM{'HOST'}       = $ENV{'REMOTE_HOST'};

  if ($Board->{'APROVED'} == 1) {
    $FORM{'APROVED'}  = 0;
  } else {
    $FORM{'APROVED'}  = 1;
  }

  if ($FileName) {
    $FORM{'ATTACHMENT'}   = $FileName;
  }

  $FORM{'SYMBOL'} = $UB::QUERY{'FORM_SYMBOL'};

  if ($UB::MEMBER{'LOGIN'} != 1) {
# =========================================================================== #
# Check the nickname is it existed

    if ($GENERAL::NICKNAME_FILTER) {
      if ( &Standard::NicknameFilter ($FORM{'NICKNAME'}) ) {
        &Error ("NOT_AVAILABLE_NICKNAME");
      }
    }

    unless ($GENERAL::NICKNAME_DUPLICATE == 1) {
      my @Nicknames = &Standard::GetList ($SYSTEM::DB_PATH."/accounts.nickname");

      foreach (@Nicknames) {
        if (/^$FORM{'NICKNAME'}$/i) {
          &Error ("TAKEN_NICKNAME");
        }
      }
      @Nicknames = ();
    }

# =========================================================================== #
# Check the email is it existed

    if ($GENERAL::EMAIL_FILTER) {
      if ( &Standard::EmailFilter ($FORM{'EMAIL'}) ) {
        &Error ("NOT_AVAILABLE_EMAIL");
      }
    }

    unless ($GENERAL::EMAIL_DUPLICATE == 1) {
      my @Emails = &Standard::GetList ($SYSTEM::DB_PATH."/accounts.email");

      foreach (@Emails) {
        if (/^$FORM{'EMAIL'}$/i) {
          &Error ("TAKEN_EMAIL");
        }
      }
      @Emails = ();
    }
  }

  ($FORM{'SUBJECT'}, $FORM{'MESSAGE'}) = &Standard::WordFilter($FORM{'SUBJECT'}, $FORM{'MESSAGE'});

  my ($Post);
  (
    ($Post) = &DB::BinarySelect (
      TABLE   => "B".$Board->{'ID'},
      COLUMNS => [
        "ID"              ,
        "SUBJECT"         ,
        "USERNAME"        ,
        "NICKNAME"        ,
        "EMAIL"           ,
        "ROOT"            ,
        "REPLY_NOTIFY"    ,
        "APROVED"         ,
        "READ_ONLY"
      ],
      KEY     => $UB::QUERY{'TID'}
    )
  ) || &HTML::Error(MESSAGE => $DB::Error);

  if ($Post->{'ROOT'} > 0) {
    $FORM{'ROOT'} = $Post->{'ROOT'};
    (
      ($Post) = &DB::BinarySelect (
        TABLE   => "B".$Board->{'ID'},
        COLUMNS => [
          "ID"              ,
          "SUBJECT"         ,
          "USERNAME"        ,
          "NICKNAME"        ,
          "EMAIL"           ,
          "ROOT"            ,
          "REPLY_NOTIFY"    ,
          "APROVED"         ,
          "READ_ONLY"
        ],
        KEY     => $FORM{'ROOT'}
      )
    ) || &HTML::Error(MESSAGE => $DB::Error);
  } else {
    $FORM{'ROOT'} = $UB::QUERY{'TID'};
  }

  if ($Post->{'APROVED'} != 1) {
    &HTML::Error(CODE => "POST_NOT_APPROVED");
  }

  if ($Post->{'READ_ONLY'} == 1) {
    &HTML::Error(CODE => "POST_READ_ONLY");
  }

# =========================================================================== #
# Add Reply to Database

  &Standard::FileOpen(*POSTING, "w", $SYSTEM::TEMP_PATH."/Posting-$ENV{'REMOTE_ADDR'}.tmp");
    print POSTING time;
  close (POSTING);

  ( # insert reply information into board database
    my $ID = &DB::Insert (
      TABLE  => "B".$UB::QUERY{'BID'},
      VALUES => \%FORM
    )
  ) || &HTML::Error(MESSAGE => $DB::Error);

  (
    &DB::Update (
      TABLE   => "Categories",
      VALUES  => {
        TOTAL_POSTS         => "++\${TOTAL_POSTS}"  ,
        LAST_UPDATE_SECOND  => $FORM{'POST_SECOND'} ,
        LAST_UPDATE_DATE    => $FORM{'POST_DATE'}   ,
        LAST_UPDATE_TIME    => $FORM{'POST_TIME'}
      },
      KEY     => $Board->{'CATEGORY'}
    )
  ) || &HTML::Error(MESSAGE => $DB::Error);

  (
    &DB::Update (
      TABLE   => "Boards",
      VALUES  => {
        TOTAL_POSTS         => "++\${TOTAL_POSTS}"  ,
        LAST_POST_SECOND    => $FORM{'POST_SECOND'} ,
        LAST_POST_DATE      => $FORM{'POST_DATE'}   ,
        LAST_POST_TIME      => $FORM{'POST_TIME'}   ,
        LAST_UPDATE_SECOND  => $FORM{'POST_SECOND'} ,
        LAST_UPDATE_DATE    => $FORM{'POST_DATE'}   ,
        LAST_UPDATE_TIME    => $FORM{'POST_TIME'}
      },
      KEY     => $Board->{'ID'}
    )
  ) || &HTML::Error(MESSAGE => $DB::Error);

  (
    &DB::Update (
      TABLE   => "B".$Board->{'ID'},
      VALUES  => {
        REPLIES           => "\${REPLIES}.\",$ID\"" ,
        NUMBER_REPLIES    => "++\${NUMBER_REPLIES}" ,
        LAST_POST_SECOND  => $FORM{'POST_SECOND'}   ,
        LAST_POST_DATE    => $FORM{'POST_DATE'}     ,
        LAST_POST_TIME    => $FORM{'POST_TIME'}
      },
      KEY     => $FORM{'ROOT'}
    )
  ) || &HTML::Error(MESSAGE => $DB::Error);

  if ($UB::MEMBER{'LOGIN'} == 1) {
    if (($UB::MEMBER{'LEVEL'} < 50) && ($UB::MEMBER{'TOTAL_POSTS'} > $GENERAL::UPGRADE_LEVEL)) {
      $UB::MEMBER{'LEVEL'}      = "50";
      $UB::MEMBER{'LEVEL_TEXT'} = $GENERAL::MEMBER_LEVEL_50;
    }

    (
      &DB::Update (
        TABLE   => "Accounts",
        VALUES  => {
          TOTAL_POSTS         => ++$UB::MEMBER{'TOTAL_POSTS'},
          LAST_POST_SECOND    => $FORM{'POST_SECOND'}        ,
          LAST_POST_DATE      => $FORM{'POST_DATE'}          ,
          LAST_POST_TIME      => $FORM{'POST_TIME'}          ,
          LEVEL               => $UB::MEMBER{'LEVEL'}        ,
          LEVEL_TEXT          => $UB::MEMBER{'LEVEL_TEXT'}
        },
        KEY     => $UB::MEMBER{'USERNAME'}
      )
    ) || &HTML::Error(MESSAGE => $DB::Error);
  }

  &Standard::FileOpen(*POST, "w", $SYSTEM::DB_PATH."/B".$Board->{'ID'}."/".$ID.".src");
    print POST $FORM{'MESSAGE'};
  close (POST);

  if ($Board->{'UB_CODES'} == 1) {
    $FORM{'MESSAGE'} = &UltraBoard::Encode($FORM{'MESSAGE'}, 0, $Board->{'HTML_TAGS'}, $Board->{'ID'}, $ID);
  }

  if (($FORM{'SIGNATURE'} == 1) && ($UB::MEMBER{'LOGIN'} == 1)) {
    my ($Profile) = &DB::BinarySelect (
      TABLE   => "Profiles",
      COLUMNS => ["USERNAME", "SIGNATURE"],
      KEY     => $UB::MEMBER{'USERNAME'}
    );

    if (length ($Profile->{'SIGNATURE'}) > 1) {
      $Profile->{'SIGNATURE'}  = &UltraBoard::Encode($Profile->{'SIGNATURE'}, 1);
      $FORM{'MESSAGE'} .= qq~\n<!-- SIGNATURE -->\n<!-- hr --><hr><!-- hr -->\n$Profile->{'SIGNATURE'}\n<!-- SIGNATURE -->~;
    }
  }

  &Standard::FileOpen(*POST, "w", $SYSTEM::DB_PATH."/B".$Board->{'ID'}."/".$ID.".post");
    print POST $FORM{'MESSAGE'};
  close (POST);

  if (-e $tmpAttachFile) {
    chmod (0777, $SYSTEM::UPLOAD_PATH);
    my $New = $SYSTEM::UPLOAD_PATH."/Post-".$Board->{'ID'}."-".$ID."-".$FileName;
    copy ($tmpAttachFile, $New);
    chmod (0777, $New);
  } elsif (($UB::QUERY{'TMP'}) && ($UB::QUERY{'ATTACH'}) && (-e $SYSTEM::TEMP_PATH."/Post-".$Board->{'ID'}."-".$UB::QUERY{'TMP'}."-".$UB::QUERY{'ATTACH'})) {
    chmod (0777, $SYSTEM::TEMP_PATH);
    chmod (0777, $SYSTEM::UPLOAD_PATH);
    my $Old = $SYSTEM::TEMP_PATH."/Post-".$Board->{'ID'}."-".$UB::QUERY{'TMP'}."-".$UB::QUERY{'ATTACH'};
    my $New = $SYSTEM::UPLOAD_PATH."/Post-".$Board->{'ID'}."-".$ID."-".$UB::QUERY{'ATTACH'};
    move ($Old, $New);
    chmod (0777, $New);
  }

  close ($AttachFile) if ($AttachFile);

# =========================================================================== #
# Printing Topic into Static HTML Page

  if ($Board->{'APROVED'} != 1) {
    &Thread::Build (
      BOARD     => $Board->{'ID'},
      THREAD    => $FORM{'ROOT'} ,
    );
  }

# =========================================================================== #
# Mailing to ...

  &Standard::FileOpen(*HEADER, "r", "$SYSTEM::DB_PATH/B".$Board->{'ID'}."/header.inc");
    my $HEADER = join ("", <HEADER>);
  close (HEADER);

  &Standard::FileOpen(*FOOTER, "r", "$SYSTEM::DB_PATH/B".$Board->{'ID'}."/footer.inc");
    my $FOOTER = join ("", <FOOTER>);
  close (FOOTER);

  my $BoardOption = &Standard::GetBoardsList("", "", "", 1, "", $Board->{'ID'});

  my %REPLY = (
    "CATEGORY.ID"       => $Category->{'ID'}              || "",
    "CATEGORY.TITLE"    => $Category->{'TITLE'}           || "",

    "BOARD.ID"          => $Board->{'ID'}                 || "",
    "BOARD.TITLE"       => $Board->{'TITLE'}              || "",
    "BOARD.REVIEW_POST" => $Board->{'APROVED'}            || "",

    "BOARD.HEADER"      => $HEADER                             ,
    "BOARD.FOOTER"      => $FOOTER                             ,

    "TOPIC.ID"          => $Post->{'ID'}                  || "",
    "TOPIC.USERNAME"    => $Post->{'USERNAME'}            || "",
    "TOPIC.NICKNAME"    => $Post->{'NICKNAME'}            || "",
    "TOPIC.EMAIL"       => $Post->{'EMAIL'}               || "",
    "TOPIC.SUBJECT"     => $Post->{'SUBJECT'}             || "",

    "POST.ID"           => $ID                            || "",
    "POST.USERNAME"     => $FORM{'USERNAME'}              || "",
    "POST.NICKNAME"     => $FORM{'NICKNAME'}              || "",
    "POST.EMAIL"        => $FORM{'EMAIL'}                 || "",
    "POST.DATE"         => $FORM{'POST_DATE'}             || "",
    "POST.TIME"         => $FORM{'POST_TIME'}             || "",
    "POST.IP"           => $FORM{'IP'}                    || "",
    "POST.HOST"         => $FORM{'HOST'}                  || "",
    "POST.SUBJECT"      => $FORM{'SUBJECT'}               || "",
    "POST.MESSAGE"      => $FORM{'MESSAGE'}               || "",
    "POST.ATTACHMENT"   => $FORM{'ATTACHMENT'}            || "",
    "POST.SYMBOL"       => $FORM{'SYMBOL'}                || "",

    "PAGE"              => $UB::QUERY{'PAGE'}                  ,

    "SHOW.BOARDS.LIST"  => 1                                   ,
    "BOARDS.LIST"       => $BoardOption                        ,

    "ADDRESS"           => "<a href=\"$SYSTEM::UB_URL/UltraBoard.$SYSTEM::EXT?action=Category&CID=".$Category->{'ID'}."&SID=".$UB::MEMBER{'SESSION'}."\" style=\"color:$UB::STYLE{'NORMAL_TEXT_COLOR'}\">".$Category-> {'TITLE'}."</a>".
                           " / ".
                           "<a href=\"$SYSTEM::UB_URL/UltraBoard.$SYSTEM::EXT?action=Headlines&BID=".$Board->{'ID'}."&SID=".$UB::MEMBER{'SESSION'}."\" style=\"color:$UB::STYLE{'NORMAL_TEXT_COLOR'}\">".$Board-> {'TITLE'}."</a>",

    &Standard::ExtraVariables()
  );
  &Standard::PrintHTMLHeader();
  if (($SYSTEM::SENDMAIL == 1) && ($SendMail == 1)) {
    if ($Board->{'APROVED'} == 1) {
      &Standard::Require("UB_Admin_Review_Message.src", "$UB::INTERFACES_PATH/$SYSTEM::DEFAULT_THEME/UB_Admin_Review_Message.src");

      &Mail::Send (
        SUBJECT => $Admin_Review_Message::DYNAMIC{'LANGUAGE.SUBJECT'},
        MESSAGE => &Admin_Review_Message::Parse(\%REPLY),
#       HEADER  => $GENERAL::EMAIL_FORMAT,
        TO      => $SYSTEM::ADMIN_EMAIL
      );
    } elsif ($Board->{'APROVED'} != 1) {

      if ($GENERAL::NOTIFY_POST == 1) {
        &Standard::Require("UB_Admin_Notify_Message.src", "$UB::INTERFACES_PATH/$SYSTEM::DEFAULT_THEME/UB_Admin_Notify_Message.src");

        &Mail::Send (
          SUBJECT => $Admin_Notify_Message::DYNAMIC{'LANGUAGE.SUBJECT'},
          MESSAGE => &Admin_Notify_Message::Parse(\%REPLY),
#          HEADER => $GENERAL::EMAIL_FORMAT,
          TO      => $SYSTEM::ADMIN_EMAIL
        );
      }

      if (($Post->{'REPLY_NOTIFY'} == 1) && ($GENERAL::NOTIFY_MEMBER_POST == 1)) {
        &Standard::Require("UB_Notify_Reply.src", "$UB::INTERFACES_PATH/$SYSTEM::DEFAULT_THEME/UB_Notify_Reply.src");

        &Mail::Send (
          SUBJECT => $Notify_Reply::DYNAMIC{'LANGUAGE.SUBJECT'},
          MESSAGE => &Notify_Reply::Parse(\%REPLY),
#          HEADER => $GENERAL::EMAIL_FORMAT,
          TO      => $Post->{'EMAIL'}
        );
      }
    }
  }

  &Success(\%REPLY);
}

###############################################################################
# Error function
# - function of printing error message of creating members account
sub Error {
  my ($code) = @_;

  require "$UB::SOURCES_PATH/UB_Reply.src";
  &Source::Reply($code);

  exit;
}

###############################################################################
# Success function
# - function of printing success message of creating members account
sub Success {
  my ($REPLY) = @_;

  &Standard::Require("UB_Reply_Success.src", "$UB::INTERFACES_PATH/$SYSTEM::DEFAULT_THEME/UB_Reply_Success.src");

  &Standard::PrintHTMLHeader();
  print &Reply_Success::Parse($REPLY);
  exit;
}

sub Login {
  print "Location: $SYSTEM::UB_URL/UltraBoard.$SYSTEM::EXT?action=Login&refer=Reply&BID=".$UB::QUERY{'BID'}."&TID=".$UB::QUERY{'TID'}."&PID=".$UB::QUERY{'PID'}."\n\n";
}

###############################################################################
1; # end of UB_DoReply.src file
###############################################################################