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

&Standard::Require("Cfg.lib", "$UB::LIBRARIES_PATH/Cfg.lib");

sub CfgSystem {
  my ($ERROR) = @_;

  &Standard::PrintHTMLHeader();
  print &HTML::Header;
  print<<HTML;
<form action="$SYSTEM::CP_URL/Panel.$SYSTEM::EXT" method="post">
<input type="hidden" name="action" value="DoCfgSystem">
<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> / General Management / Configure system options
    </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

  if ($ERROR ne "") {
    print<<HTML;
                        There were the following errors during updating system options.<br>
                        <table width="100%" border="0" cellspacing="2" cellpadding="2">
                          <tr>
                            <td><font color="#FF0000">$ERROR</font></td>
                          </tr>
                        </table>
                        Please make any changes and try again!<br>
HTML
  }

print<<HTML;
                      Please fill out all required (<font color="Red"><b>*</b></font>) fields.
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>

HTML

print<<HTML;
&nbsp;<br>
&nbsp;&nbsp;Absolute Paths
<table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolordark="White" bordercolorlight="Gray">
 <tr>
  <td>
   <table width="100%" border="0" cellspacing="0" cellpadding="2">
HTML

  print &TextField (
    TITLE       => "Datebase Path",
    DESCRIPTION => "the absolute path of directory where all the ultraboard data files will be located. (e.g. \"/home/yourdomain/cgi-bin/UltraBoard/Private/Database\")",
    NAME        => "DB_PATH",
    VALUE       => $UB::QUERY{'DB_PATH'} || $SYSTEM::DB_PATH,
    REQUIRED    => "1",

    MAXLENGTH   => "",
    SIZE        => "30"
  );

  print &TextField (
    TITLE       => "Backup Path",
    DESCRIPTION => "the absolute path of directory where all backup files will be located. (e.g. \"/home/yourdomain/cgi-bin/UltraBoard/Private/Backups\")",
    NAME        => "BACKUP",
    VALUE       => $UB::QUERY{'BACKUP'} || $SYSTEM::BACKUP,
    REQUIRED    => "1",

    MAXLENGTH   => "",
    SIZE        => "30"
  );

  print &TextField (
    TITLE       => "Theme Path",
    DESCRIPTION => "the absolute path of directory where all theme files will be located. (e.g. \"/home/yourdomain/cgi-bin/UltraBoard/Private/Themes\")",
    NAME        => "THEME_PATH",
    VALUE       => $UB::QUERY{'THEME_PATH'} || $SYSTEM::THEME_PATH,
    REQUIRED    => "1",

    MAXLENGTH   => "",
    SIZE        => "30"
  );

  print &TextField (
    TITLE       => "Images Path",
    DESCRIPTION => "the absolute path of directory where all images files will be located. (e.g. \"/home/yourdomain/cgi-bin/UltraBoard/Public/Images\")",
    NAME        => "IMAGE_PATH",
    VALUE       => $UB::QUERY{'IMAGE_PATH'} || $SYSTEM::IMAGE_PATH,
    REQUIRED    => "1",

    MAXLENGTH   => "",
    SIZE        => "30"
  );

  print &TextField (
    TITLE       => "Upload Path",
    DESCRIPTION => "the absolute path of directory where all upload files will be located. (e.g. \"/home/yourdomain/cgi-bin/UltraBoard/Public/Uploads\")",
    NAME        => "UPLOAD_PATH",
    VALUE       => $UB::QUERY{'UPLOAD_PATH'} || $SYSTEM::UPLOAD_PATH,
    REQUIRED    => "1",

    MAXLENGTH   => "",
    SIZE        => "30"
  );

print<<HTML;
   </table>
  </td>
 </tr>
</table>
HTML

print<<HTML;
&nbsp;<br>
&nbsp;&nbsp;URL Addresses
<table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolordark="White" bordercolorlight="Gray">
 <tr>
  <td>
   <table width="100%" border="0" cellspacing="0" cellpadding="2">
HTML

  print &TextField (
    TITLE       => "Control Panel URL",
    DESCRIPTION => "the location where the Panel.cgi is located. (e.g. \"http://www.yourdomain.com/cgi-bin/UltraBoard\")",
    NAME        => "CP_URL",
    VALUE       => $UB::QUERY{'CP_URL'} || $SYSTEM::CP_URL,
    REQUIRED    => "1",

    MAXLENGTH   => "",
    SIZE        => "30"
  );

  print &TextField (
    TITLE       => "UltraBoard URL",
    DESCRIPTION => "the location where all files will be uploaded. (e.g. \"http://www.yourdomain.com/cgi-bin/UltraBoard/Public/Uploads\")",
    NAME        => "UB_URL",
    VALUE       => $UB::QUERY{'UB_URL'} || $SYSTEM::UB_URL,
    REQUIRED    => "1",

    MAXLENGTH   => "",
    SIZE        => "30"
  );

  print &TextField (
    TITLE       => "Upload URL",
    DESCRIPTION => "the location where all the images are located. (e.g. \"http://www.yourdomain.com/cgi-bin/UltraBoard/Public/Images\")",
    NAME        => "UPLOAD_URL",
    VALUE       => $UB::QUERY{'UPLOAD_URL'} || $SYSTEM::UPLOAD_URL,
    REQUIRED    => "1",

    MAXLENGTH   => "",
    SIZE        => "30"
  );

  print &TextField (
    TITLE       => "Images URL",
    DESCRIPTION => "the absolute path of directory where all theme files will be located. (e.g. \"/home/yourdomain/cgi-bin/UltraBoard/Private/Themes\")",
    NAME        => "IMAGE_URL",
    VALUE       => $UB::QUERY{'IMAGE_URL'} || $SYSTEM::IMAGE_URL,
    REQUIRED    => "1",

    MAXLENGTH   => "",
    SIZE        => "30"
  );

print<<HTML;
   </table>
  </td>
 </tr>
</table>
HTML

print<<HTML;
&nbsp;<br>
&nbsp;&nbsp;Email Options
<table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolordark="White" bordercolorlight="Gray">
 <tr>
  <td>
   <table width="100%" border="0" cellspacing="0" cellpadding="2">
HTML

  print &TextField (
    TITLE       => "Administrator Email",
    DESCRIPTION => "your email address, it only used to send email from ultraboard only. (e.g. \"webmaster\@yourdomain.com\")",
    NAME        => "ADMIN_EMAIL",
    VALUE       => $UB::QUERY{'ADMIN_EMAIL'} || $SYSTEM::ADMIN_EMAIL,
    REQUIRED    => "1",

    MAXLENGTH   => "",
    SIZE        => "30"
  );

  print &Radio (
    TITLE       => "Mail Functions",
    DESCRIPTION => "are you going to use mailing functions in ultraboard 2000?",
    NAME        => "SENDMAIL",
    VALUE       => [
      {
        VALUE => "1",
        TITLE => "Enable"
      }, {
        VALUE => "0",
        TITLE => "Disable"
      }
    ],
    WRAP        => 0,
    SELECT      => $UB::QUERY{'SENDMAIL'} || $SYSTEM::SENDMAIL,
    REQUIRED    => "0",
  );

  print &Radio (
    TITLE       => "Mail System",
    DESCRIPTION => "which mail system are you going to use? if you are using windows system, you may choose the smtp system.",
    NAME        => "MAIL_SYSTEM",
    VALUE       => [
      {
        VALUE => "SMTP",
        TITLE => "SMTP System"
      }, {
        VALUE => "SENDMAIL",
        TITLE => "Sendmail System"
      }
    ],
    SELECT      => $UB::QUERY{'MAIL_SYSTEM'} || $SYSTEM::MAIL_SYSTEM,
    REQUIRED    => "0",
  );

  print &TextField (
    TITLE       => "SMTP Address",
    DESCRIPTION => "the url where your smtp server located. (e.g. \"smtp.yourdomain.com\")",
    NAME        => "SMTP_PATH",
    VALUE       => $UB::QUERY{'SMTP_PATH'} || $SYSTEM::SMTP_PATH,

    MAXLENGTH   => "",
    SIZE        => "30"
  );

  print &TextField (
    TITLE       => "Sendmail Path",
    DESCRIPTION => "the absolute path of the sendmail program (e.g. \"/usr/bin/sendmail\")",
    NAME        => "SENDMAIL_PATH",
    VALUE       => $UB::QUERY{'SENDMAIL_PATH'} || $SYSTEM::SENDMAIL_PATH,

    MAXLENGTH   => "",
    SIZE        => "30"
  );

print<<HTML;
   </table>
  </td>
 </tr>
</table>
HTML


print<<HTML;
&nbsp;<br>
&nbsp;&nbsp;Date/Time Options
<table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolordark="White" bordercolorlight="Gray">
 <tr>
  <td>
   <table width="100%" border="0" cellspacing="0" cellpadding="2">
HTML

  print &TextField (
    TITLE       => "Time Zone Name",
    DESCRIPTION => "the time zone of your area. (e.g. \"GMT\", \"EST\")",
    NAME        => "TIMEZONE",
    VALUE       => $UB::QUERY{'TIMEZONE'} || $SYSTEM::TIMEZONE,
    REQUIRED    => "1",

    MAXLENGTH   => "",
    SIZE        => "30"
  );

  print &TextField (
    TITLE       => "Time Zone Offset",
    DESCRIPTION => "the time different between your area and your server.",
    NAME        => "LOCALTIME_OFFSET",
    VALUE       => $UB::QUERY{'LOCALTIME_OFFSET'} || $SYSTEM::LOCALTIME_OFFSET,
    REQUIRED    => "1",

    MAXLENGTH   => "",
    SIZE        => "30"
  );

  print &Radio (
    TITLE       => "Date Format",
    DESCRIPTION => "select the date format you prefer.",
    NAME        => "DATE_FORMAT",
    VALUE       => [
      {
        VALUE => "US",
        TITLE => "US Format (MM-DD-YYYY)"
      }, {
        VALUE => "USE",
        TITLE => "Expanded US Format (Month DD, YYYY)"
      }, {
        VALUE => "EU",
        TITLE => "European Format (DD-MM-YYYY)"
      }, {
        VALUE => "EUE",
        TITLE => "Expanded European Format (DD Month, YYYY)"
      }
    ],
    SELECT      => $UB::QUERY{'DATE_FORMAT'} || $SYSTEM::DATE_FORMAT,
    REQUIRED    => "0",
  );

  print &Radio (
    TITLE       => "Time Format",
    DESCRIPTION => "select the time format you prefer.",
    NAME        => "TIME_FORMAT",
    VALUE       => [
      {
        VALUE => "12",
        TITLE => "AM/PM Time Format"
      }, {
        VALUE => "24",
        TITLE => "24 Hour Time Format"
      }
    ],
    SELECT      => $UB::QUERY{'TIME_FORMAT'} || $SYSTEM::TIME_FORMAT,
    REQUIRED    => "0",
  );

print<<HTML;
   </table>
  </td>
 </tr>
</table>
HTML

print<<HTML;
&nbsp;<br>
&nbsp;&nbsp;Miscellaneous Options
<table width="100%" border="1" cellspacing="0" cellpadding="3" bordercolordark="White" bordercolorlight="Gray">
 <tr>
  <td>
   <table width="100%" border="0" cellspacing="0" cellpadding="2">
HTML

  my $Themes = [];
  opendir (DIR, "$SYSTEM::THEME_PATH");
    while ( defined (my $FILE = readdir (DIR)) ) {
      next if ($FILE =~ /^\.\.?$/);
      if (-e $SYSTEM::THEME_PATH."/".$FILE."/".$FILE.".cfg") {
        push (
          @{ $Themes },
          {
            VALUE => $FILE,
            TITLE => $FILE
          }
        );
      }
    }
  closedir (DIR);

  print &Radio (
    TITLE       => "Theme",
    DESCRIPTION => "which theme are you going to use?",
    NAME        => "DEFAULT_THEME",
    VALUE       => $Themes,
    SELECT      => $UB::QUERY{'DEFAULT_THEME'} || $SYSTEM::DEFAULT_THEME,
    REQUIRED    => "0",
  );

  print &TextField (
    TITLE       => "Sessions Expire",
    DESCRIPTION => "every how many second clean up the members session files once? (in seconds)",
    NAME        => "SESSIONS_EXPIRE",
    VALUE       => $UB::QUERY{'SESSIONS_EXPIRE'} || $SYSTEM::SESSIONS_EXPIRE,
    REQUIRED    => "1",

    MAXLENGTH   => "",
    SIZE        => "30"
  );

  print &TextArea (
    TITLE       => "Offline Message",
    DESCRIPTION => "this message will appear while the board is offline.",
    NAME        => "OFFLINE_MESSAGE",
    VALUE       => $UB::QUERY{'OFFLINE_MESSAGE'} || $SYSTEM::OFFLINE_MESSAGE,
    REQUIRED    => "0",

    COLS        => "30",
    ROWS        => "3"
  );

  print &Radio (
    TITLE       => "File Lock",
    DESCRIPTION => "if your server supports the flock() function, I suggest you to enable this.",
    NAME        => "FLOCK",
    VALUE       => [
      {
        VALUE => "1",
        TITLE => "Enable"
      }, {
        VALUE => "0",
        TITLE => "Disable"
      }
    ],
    WRAP        => 0,
    SELECT      => $UB::QUERY{'FLOCK'} || $SYSTEM::FLOCK,
    REQUIRED    => "0",
  );

  print &Radio (
    TITLE       => "Stats",
    DESCRIPTION => "if you want to know how many people access your board hourly, daily and monthly, use this option.",
    NAME        => "STATS",
    VALUE       => [
      {
        VALUE => "1",
        TITLE => "Enable"
      }, {
        VALUE => "0",
        TITLE => "Disable"
      }
    ],
    WRAP        => 0,
    SELECT      => $UB::QUERY{'STATS'} || $SYSTEM::STATS,
    REQUIRED    => "0",
  );

  print &Radio (
    TITLE       => "Logs",
    DESCRIPTION => "if you want to log all users who access your board, use this option.",
    NAME        => "LOGS",
    VALUE       => [
      {
        VALUE => "1",
        TITLE => "Enable"
      }, {
        VALUE => "0",
        TITLE => "Disable"
      }
    ],
    WRAP        => 0,
    SELECT      => $UB::QUERY{'LOGS'} || $SYSTEM::LOGS,
    REQUIRED    => "0",
  );

  print &TextField (
    TITLE       => "Max. # of Logs",
    DESCRIPTION => "how many lines of logs information do you want to keep track of?",
    NAME        => "MAX_LOGS",
    VALUE       => $UB::QUERY{'MAX_LOGS'} || $SYSTEM::MAX_LOGS,

    MAXLENGTH   => "",
    SIZE        => "30"
  );

  print<<HTML;
<script type="text/javascript" language="JavaScript">
<!--
function if_add_option(f)
{
  var filter   = f.IP_FILTER;
  var ip       = f.if_ip;

  if (ip.value != "") {
    filter.value = filter.value + ip.value;
    filter.value = filter.value + "\|";
  }

  ip.value  = "";
}
-->
</script>
<tr>
  <td width="200" valign="top" nowrap>IP Filter</td>
  <td width="100%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td colspan=3><textarea cols="30" rows="3" name="IP_FILTER" style="width:100%" class="TextArea">$SYSTEM::IP_FILTER\|</textarea></td>
    </tr>
    <tr>
      <td><input type="button" name="if_add" value="add" onClick="if_add_option(this.form)">&nbsp;</td>
      <td width="100%"><input type="text" name="if_ip" style="width:100%"></td>
    </tr>
  </table></td>
  <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="add some ip that you don't want them visit your ultraboard. (you don't have to enter the full ip, just enter first 2 to 3 numbers of the ip, e.g. 192.168.0, then it will block all ips than start with these numbers)"></td>
</tr>
HTML

  print<<HTML;
<script type="text/javascript" language="JavaScript">
<!--
function hf_add_option(f)
{
  var filter   = f.HOST_FILTER;
  var host     = f.hf_host;

  if (host.value != "") {
    filter.value = filter.value + host.value;
    filter.value = filter.value + "\|";
  }

  host.value  = "";
}
-->
</script>
<tr>
  <td width="200" valign="top" nowrap>Host Filter</td>
  <td width="100%"><table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td colspan=3><textarea cols="30" rows="3" name="HOST_FILTER" style="width:100%" class="TextArea">$SYSTEM::HOST_FILTER\|</textarea></td>
    </tr>
    <tr>
      <td><input type="button" name="hf_add" value="add" onClick="hf_add_option(this.form)">&nbsp;</td>
      <td width="100%"><input type="text" name="hf_host" style="width:100%"></td>
    </tr>
  </table></td>
  <td width="20" valign="top" nowrap><img src="$SYSTEM::IMAGE_URL/help.gif" width=20 height=20 border=0 alt="add some host address that you don't want them to visit your ultraboard. (you don't have to enter the full address, just enter last part of the address, e.g. host.com, then it will block all addresses that end with this name)"></td>
</tr>
HTML

print<<HTML;
   </table>
  </td>
 </tr>
</table>
HTML

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

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