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

sub Index {

  &Standard::PrintHTMLHeader();
  print &HTML::Header;
  print<<HTML;
<table width="100%" border="0" cellspacing="0" cellpadding="5">
  <tr bgcolor="Gray">
    <td><font color="White"><b>
      Control Panel
    </b></font></td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td>
HTML

  (
    my ($Categories, $CategoriesIndex) = &DB::Query (
      TABLE   => "Categories",
      COLUMNS => ["ID", "TITLE"]
    )
  );

  (
    my ($Boards, $BoardsIndex) = &DB::Query (
      TABLE   => "Boards",
      COLUMNS => ["ID", "TITLE", "CATEGORY"]
    )
  );

  my %HashBoard;
  foreach my $Board ( @{ $Boards } ) {
    my $Messages = [];
    ($Messages) = &DB::Query (
      TABLE   => "B".$Board->{'ID'},
      COLUMNS => ["ID", "ROOT", "SUBJECT", "USERNAME", "APROVED", "NICKNAME", "READ_ONLY", "POST_SECOND", "POST_DATE", "POST_TIME"],
      WHERE   => {
        APROVED => [0]
      },
      MATCH   => "ALL",
      SORT    => "POST_SECOND",
      BY      => "Z-A",
      TO      => "0-9"
    );

    push ( @{ $HashBoard{$Board->{'ID'}} }, @{ $Messages }) if scalar ( @{ $Messages } ) > 0;
  }

print<<HTML;
      <form action="$SYSTEM::CP_URL/Panel.$SYSTEM::EXT" method="post">
      <input type="hidden" name="action" value="DoDisApprovePosts">
      <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>
                      Last 10 posts that were waiting to approve or disapprove.
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
            &nbsp;<br>
            <table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolordark="White" bordercolorlight="Gray">
              <tr height=24>
                <td nowrap>&nbsp;</td>
                <td width="70%">&nbsp;Subject&nbsp;</td>
                <td width="30%">&nbsp;Author&nbsp;</td>
                <td nowrap>&nbsp;Post date&nbsp;</td>
              </tr>
HTML

  foreach my $ID (sort keys %HashBoard) {
    my $Board = $HashBoard{$ID};
    print<<HTML;
              <tr height=24>
                <td bgcolor="Silver" nowrap colspan="4">$Boards->[ $Boards->[$BoardsIndex->{$ID}]{'CATEGORY'} ]{'TITLE'} / $Boards->[$BoardsIndex->{$ID}]{'TITLE'}</td>
              </tr>
HTML

    for (my $i = 0; $i <= $#{ $Board }; $i++) {
      my $Topic = $Board->[$i];
      $Form = &HTML::Checkbox (
        NAME    => "PID",
        VALUE   => "BID_".$ID."-PID_".$Topic->{'ID'},
      );

      print<<HTML;
              <tr bgcolor="White">
                <td bgcolor="Silver" nowrap>$Form</td>
                <td width="70%">&nbsp;<a href="$SYSTEM::CP_URL/Panel.$SYSTEM::EXT?action=Read&BID=$ID&TID=$Topic->{'ID'}" target="CPViewer">$Topic->{'SUBJECT'}</a>&nbsp;</td>
                <td width="30%">&nbsp;$Topic->{'NICKNAME'}&nbsp;</td>
                <td nowrap>&nbsp;${ \(($Topic->{'POST_DATE'}) ? $Topic->{'POST_DATE'}." ".$Topic->{'POST_TIME'} : "n/a") }&nbsp;</td>
              </tr>
HTML
    }
  }

print<<HTML;
            </table>
          </td>
        </tr>
      </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td align="right"><input type="submit" value="Approve">&nbsp;&nbsp;<input type="submit" value="Disapprove">&nbsp;&nbsp;<input type="Reset" value="Cancel"></td>
        </tr>
      </table>
      </form>
HTML

  (
    my ($Accounts, $AccountsIndex) = &DB::Query (
      TABLE   => "Accounts",
      COLUMNS => ["USERNAME", "LEVEL", "GROUP", "NICKNAME", "LEVEL_TEXT", "GROUP_TEXT", "EMAIL", "REGISTERED_SECOND", "REGISTERED_DATE", "REGISTERED_TIME", "HOST", "IP", "APROVED"],
      WHERE   => {
        APROVED => [0]
      },
      MATCH   => "ALL",
      SORT    => "REGISTERED_SECOND",
      BY      => "Z-A",
      TO      => "0-9"
    )
  );

print<<HTML;
      <form action="$SYSTEM::CP_URL/Panel.$SYSTEM::EXT" method="post">
      <input type="hidden" name="action" value="DoDisApproveAccounts">
      <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>
                      Last 10 member accounts that were waiting to approve or disapprove.
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
            &nbsp;<br>
            <table width="100%" border="1" cellspacing="0" cellpadding="2" bordercolordark="White" bordercolorlight="Gray">
              <tr height=24>
                <td nowrap>&nbsp;</td>
                <td width="20%">&nbsp;Username&nbsp;</td>
                <td width="20%">&nbsp;Nickname&nbsp;</td>
                <td width="30%" nowrap>&nbsp;Email&nbsp;</td>
                <td nowrap>&nbsp;Level&nbsp;</td>
                <td nowrap>&nbsp;Group&nbsp;</td>
                <td width="30%" nowrap>&nbsp;Registered date&nbsp;</td>
                <td nowrap>&nbsp;Host&nbsp;</td>
                <td nowrap>&nbsp;IP&nbsp;</td>
              </tr>
HTML

  for (my $i = 0; $i <= $#{ $Accounts }; $i++) {
    my $Account = $Accounts->[$i];

    $Form = &HTML::Checkbox (
      NAME    => "UID",
      VALUE   => $Account->{'USERNAME'},
    );

    print<<HTML;
              <tr bgcolor="White">
                <td bgcolor="Silver" nowrap>$Form</td>
                <td width="20%">&nbsp;<a href="$SYSTEM::CP_URL/Panel.$SYSTEM::EXT?action=Profile&UID=$Account->{'USERNAME'}" target="CPViewer">$Account->{'USERNAME'}</a>&nbsp;</td>
                <td width="20%">&nbsp;$Account->{'NICKNAME'}&nbsp;</td>
                <td width="30%">&nbsp;$Account->{'EMAIL'}&nbsp;</td>
                <td nowrap>&nbsp;$Account->{'LEVEL_TEXT'}&nbsp;</td>
                <td nowrap>&nbsp;$Account->{'GROUP_TEXT'}&nbsp;</td>
                <td width="30%">${ \(($Account->{'REGISTERED_SECOND'}) ? $Account->{'REGISTERED_DATE'}." ".$Account->{'REGISTERED_TIME'} : "n/a") }&nbsp;</td>
                <td nowrap>&nbsp;$Account->{'HOST'}&nbsp;</td>
                <td nowrap>&nbsp;$Account->{'IP'}&nbsp;</td>
              </tr>
HTML
  }

print<<HTML;
            </table>
          </td>
        </tr>
      </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="5">
        <tr>
          <td align="right"><input type="submit" name="Submit" value="Approve">&nbsp;&nbsp;<input type="submit" name="Submit" value="Disapprove">&nbsp;&nbsp;<input type="Reset" value="Cancel"></td>
        </tr>
      </table>
      </form>
    </td>
  </tr>
</table>
</body>
</html>
HTML
}

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