###############################################################################
# UB_Logout.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;

sub Logout {
  my $SID = $UB::MEMBER{'SESSION'};

  unless ($SID) {
    print "Location: $SYSTEM::UB_URL/UltraBoard.$SYSTEM::EXT\n\n";
    exit;
  }

  &DB::Delete (
    TABLE  => "Sessions",
    KEYS   => [$SID]
  );

  $UB::COOKIES{'SID'}      = "";
  $UB::COOKIES{'Username'} = "";
  $UB::COOKIES{'Password'} = "";

  my %FORM = (
    "BOARD.ID"          => $UB::QUERY{'BID'} || "",
    "TOPIC.ID"          => $UB::QUERY{'TID'} || "",

    &Standard::ExtraVariables()
  );

  &Success(\%FORM);
}

###############################################################################
# Success function
# - function of printing success message of logout
sub Success {
  my ($FORM) = @_;

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

  &Standard::PrintHTMLHeader();
  print &Logout_Success::Parse($FORM);
  exit;
}

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