###############################################################################
# CP_DoRebuild.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 DoRebuild {
  my $BOARD = $UB::QUERY{'FORM_BOARD'} || "1";
  my $TYPE  = $UB::QUERY{'FORM_TYPE'}  || "DATABASE";
  my $FROM  = $UB::QUERY{'FROM'}       || 0;
  my $EVERY = $UB::QUERY{'EVERY'}      || 100;
  my $TO    = $FROM + $EVERY - 1;

  my $NewFROM = $TO + 1;

  &Standard::PrintHTMLHeader();
  print &HTML::Header;
  print<<HTML;
<form action="$SYSTEM::CP_URL/Panel.$SYSTEM::EXT" method="post">
<input type="hidden" name="action" value="DoRebuild">
<input type="hidden" name="FROM" value="$NewFROM">
<input type="hidden" name="EVERY" value="$EVERY">
<input type="hidden" name="FORM_TYPE" value="$TYPE">
<input type="hidden" name="FORM_BOARD" value="$BOARD">
<table width="100%" border="0" cellspacing="0" cellpadding="5">
  <tr bgcolor="Gray">
    <td><font color="White"><b>
      <a href="$SYSTEM::CP_URL/Panel.$SYSTEM::EXT?action=body" target="UBBODY" class="address">Control Panel</a> / UltraBoard Utilities / Rebuild data
    </b></font></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td>
      <table width="100%" border="0" cellspacing="0" cellpadding="2">
        <tr>
          <td>
            <table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolordark="White" bordercolorlight="Gray">
              <tr>
                <td>
                  <table width="100%" border="0" cellspacing="0" cellpadding="2">
                    <tr>
                      <td>
HTML
  my $Process;
  print "<textarea cols=\"45\" rows=\"30\" style=\"font-family: MS Sans Serif, Arial; font-size: x-small; width:100%\" wrap=\"off\" readonly>";
  if ($UB::QUERY{'FORM_TYPE'} eq "TOPICS") {
    &Standard::Require("Thread.lib", "$UB::LIBRARIES_PATH/Thread.lib");

    ($Process) = &Thread::All (
      BOARD     => $BOARD,
      FROM      => $FROM,
      TO        => $TO,
      DETAIL    => 1,
    );
  } else {
    &Standard::Require("Rebuild.lib", "$UB::LIBRARIES_PATH/Rebuild.lib");

    ($Process) = Rebuild::Database(
      DETAIL    => 1,
    );
  }
  print "</textarea>";
  print<<HTML;
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
HTML

  unless ($Process < $EVERY) {
    print<<HTML;
      <table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td align="right"><input type="submit" value="Next Step >"></td>
        </tr>
      </table>
HTML
  }

  print<<HTML;
    </td>
  </tr>
</table>
</form>
</body>
</html>
HTML

}

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