# Define the site-specific information
#
Variable    SERVER_NAME     __MVC_SERVERNAME__
Variable    CGI_URL         __MVC_CGIURL__
Variable    SECURE_SERVER   http://__MVC_SERVERNAME__
Variable    ORDERS_TO       __MVC_MAILORDERTO__
Variable    IMAGE_DIR       __MVC_IMAGEURL__
Variable    DOCROOT         __MVC_DOCUMENTROOT__
Variable    SAMPLEHTML      __MVC_SAMPLEHTML__
Variable    SAMPLEURL       __MVC_SAMPLEURL__

Variable    TEMPLATE        __MVC_TEMPLATE__
Variable    COMPANY         __MVC_COMPANY__
Variable    ADDRESS         __MVC_ADDRESS__
Variable    CITY            __MVC_CITY__
Variable    PHONE           __MVC_PHONE__
Variable    TOLLFREE        __MVC_TOLLFREE__
Variable    FAX             __MVC_FAX__
Variable    LOGO            __MVC_LOGO__
Variable    SMLOGO          __MVC_SMLOGO__
Variable    ENCRYPTOR       __MVC_ENCRYPTOR__
Variable    TAXAREA         __MVC_TAXAREA__
Variable    TAXRATE         __MVC_TAXRATE__
Variable    TAXSHIPPING     __MVC_TAXSHIPPING__
Variable    MULTIORDER      __MVC_MULTIORDER__

# Set single-page order style
Variable      ORDER_STYLE   ord

# Set multi-page order style if MULTIORDER variable set
#ifdef MULTIORDER
Variable      ORDER_STYLE   multi
#endif

## END SITE CONFIGURATION

## Whether to encrypt passwords in UserDB
UserDB    default    crypt         __MVC_CRYPTPW__0
## Change a field to something that doesn't conflict in MySQL
UserDB    default    time_field    mod_time

#ifdef TEMPLATE eq 'brown1'
Variable    BARBG           MAROON
Variable    BARTEXT         #FFFFFF
Variable    BODY            BGCOLOR=WHITE LINK=BLACK
Variable    CONTRAST        RED
Variable    HEADERBG        BGCOLOR=#C6A563
Variable    HEADERTEXT      MAROON
Variable    LINECOLOR       #000000
Variable    TABLEFG         BGCOLOR=#E3D5B5
Variable    TITLEBG         NAVY
Variable    TITLETEXT       #FFFFFF
Variable    TOPCOLOR        #F22B34
Variable    TOPTEXT         YELLOW
#endif

#ifdef TEMPLATE eq 'blue1'
Variable    BARBG           #FF6701
Variable    BARTEXT         #FFFFFF
Variable    BODY            BGCOLOR=WHITE LINK=BLACK
Variable    CONTRAST        RED
Variable    HEADERBG        BGCOLOR=#4F87CB
Variable    HEADERTEXT      #CCFF99
Variable    LINECOLOR       #000000
Variable    TABLEFG         BGCOLOR=LIGHTBLUE
Variable    TITLEBG         NAVY
Variable    TITLETEXT       #FFFFFF
Variable    TOPCOLOR        #F22B34
Variable    TOPTEXT         YELLOW
#endif

#ifdef TEMPLATE eq 'yellow1'
Variable    BARBG           #000000
Variable    BARTEXT         #FFFFFF
Variable    BODY            BGCOLOR=WHITE LINK=BLACK
Variable    CONTRAST        RED
Variable    HEADERBG        BGCOLOR=#FFE88D
Variable    HEADERTEXT      #000000
Variable    LINECOLOR       #000000
Variable    TABLEFG         BGCOLOR=MOCCASIN
Variable    TITLEBG         #000000
Variable    TITLETEXT       #FFFFFF
Variable    TOPCOLOR        #F22B34
Variable    TOPTEXT         YELLOW
#endif

## Set some menubars and headers
## Use [include ...] with low traffic settings (from minivend.cfg)
## Put in memory with high traffic settings (from minivend.cfg)
ParseVariables  Yes

# Better performance this way
#ifdef @TRAFFIC =~ /high/i
ConfigDir config/__TEMPLATE__
Variable      TIMED_CATOPT  [timed-build minutes=10 file=tmp/catoptions]
Variable      TIMED_CATLIST [timed-build minutes=10 file=tmp/catlist]
Variable      END_TIMED     [/timed-build]
Variable      LEFTSIDE   <leftside
Variable      RIGHTSIDE  <rightside
Variable      NO_RIGHT   <no_right
Variable      MENUBAR    <menubar
Variable      MENUBOTTOM <menubottom
Variable      ONLYLOGO   <only_logo
Variable      LOGOBAR    <logobar
Variable      COPYRIGHT  <copyright
ConfigDir config
#endif

# template changes show up immediately this way
#ifdef @TRAFFIC =~ /low/i
Variable      LEFTSIDE   [include config/__TEMPLATE__/leftside]
Variable      RIGHTSIDE  [include config/__TEMPLATE__/rightside]
Variable      NO_RIGHT   [include config/__TEMPLATE__/no_right]
Variable      MENUBAR    [include config/__TEMPLATE__/menubar]
Variable      MENUBOTTOM [include config/__TEMPLATE__/menubottom]
Variable      ONLYLOGO   [include config/__TEMPLATE__/only_logo]
Variable      LOGOBAR    [include config/__TEMPLATE__/logobar]
Variable      COPYRIGHT  [include config/__TEMPLATE__/copyright]
#endif

ScratchDefault   mv_add_dot_html   1
ScratchDefault   mv_no_session_id  1
ScratchDefault   mv_no_count       1
ScratchDefault   order_style       1
ValuesDefault    mv_shipmode       upsg

ParseVariables  Yes

# Sets Minivend to not parse <BODY MV="body 1"> and other tags within
# HTML tags, use [pragma no_html_parse 0] to enable on a page
Pragma          no_html_parse

MailOrderTo             __ORDERS_TO__
VendURL                 http://__SERVER_NAME____CGI_URL__
SecureURL               __SECURE_SERVER____CGI_URL__

Variable            SOMESQL      __MVC_MYSQL____MVC_PGSQL__
Variable            MYSQL        __MVC_MYSQL__
Variable            PGSQL        __MVC_PGSQL__

#ifndef SOMESQL
Database            area         area.txt          TAB
Database            area         AUTO_NUMBER       1
Database            cat          cat.txt           TAB
Database            country      country.txt       TAB
Database            inventory    inventory.txt     TAB
Database            products     products.txt      TAB
Database            pricing      pricing.txt       TAB
Database            pricing      KEY               sku
Database            pricing      NUMERIC           q2
Database            products     HOT               1
Database            products     INDEX             category:c
Database            shipping     shipping.txt      TAB
Database            shipping     AUTO_NUMBER       1
Database            orderline    orderline.txt     TAB
Database            transactions transactions.txt  TAB
Database            userdb       userdb.txt        TAB
#endif

#ifdef MYSQL

Variable  SQLDSN   dbi:mysql:test_minivend
Message <<EOF

Using MySQL for databases, DSN=__SQLDSN__.
EOF

# Uncomment if needed
#Variable  SQLUSER  foo
#Variable  SQLPASS  bar

# The tables are in separate files in the mysql directory

#include mysql/*

#endif

#ifdef PGSQL

Variable  SQLDSN   dbi:Pg:dbname=test_minivend
Message <<EOF

Using PostgreSQL for databases, DSN=__SQLDSN__.
EOF

# Uncomment if needed
#Variable  SQLPASS  foo
#Variable  SQLUSER  bar

# The tables are in separate files in the mysql directory

#include pgsql/*

#endif

# We are always keeping these in DBM, can be in SQL if you wish
Variable            MINIMATE_META   mv_metadata
Variable            MINIMATE_TABLE  minimate
Database            minimate        minimate.asc      TAB
Database            mv_metadata     mv_metadata.asc   TAB
Database            banner          banner.txt        TAB
Database            banner          NUMERIC           weight
Database            locale          locale.txt        TAB
Database            2ndDayAir       2ndDayAir.csv     CSV
Database            Ground          Ground.csv        CSV
Database            NextDayAir      NextDayAir.csv    CSV

ProductFiles   products

AlwaysSecure         ord/checkout multi/checkout
AsciiTrack           etc/tracking.asc
CommonAdjust   pricing:q2,q5,q10,q25,q100, ;products:price, ;$ ==color:pricing, ==size:pricing

# Here is one that sets up "Mix and match" based upon the price_group field
# in the "pricing" database.
#CommonAdjust   pricing:price_group,q2,q5,q10,q25,q100, ;products:price, ;$ ==color:pricing, ==size:pricing
CookieLogin  Yes

# This sets up the new payment charge mode in MiniVend 4
# You set it to "custom name", where name is the name of a GlobalSub
# that performs the charge operation. If it is not "custom", then
# it will use the CyberCash routines.
#
# "minivend_test" is special, and the demo order profile
# works with the demo order form to test
#
#Variable  MV_PAYMENT_MODE   minivend_test

# Uncomment to use creditCardAuto if you want, now handled better in
# order profiles with "&credit_card=standard".
#CreditCardAuto      Yes

# These are usually all you need for CyberCash 3
# Uncomment and edit to suit; make sure you remove CreditCardAuto somehow
#
#Variable         CYBER_CONFIGFILE    /home/you/yourid75/mck-cgi/merchant_conf
#Variable         CYBER_VERSION       3.2
#Variable         CYBER_MODE          mauthonly

#ifdef CYBER_MODE
Variable         MV_PAYMENT_MODE     mauthonly
CreditCardAuto   No
#endif

# The old CyberCash stuff still should work, but use the above
#CyberCash        Yes

EncryptProgram   __ENCRYPTOR__
ImageAlias       __IMAGE_DIR__/template/  __IMAGE_DIR__/__TEMPLATE__/
ImageDir         __IMAGE_DIR__/
ImageDirInternal http://__SERVER_NAME____IMAGE_DIR__/

# Uncomment only if you have these locales on your system
#Locale          de_DE
#Locale          de_DE LC_CTYPE de_DE
#Locale          fr_FR
#Locale          en_US

Locale          en_US LC_CTYPE C
LocaleDatabase  locale

Onfly           onfly
OrderCounter    etc/order.number
OrderLineLimit  25
OrderProfile    etc/profiles.order etc/profiles.login etc/profiles.misc
Password        __MVC_SUPASSWD__

# This makes CommonAdjust effective, since no_price doesn't exist
PriceField      no_price
ReadPermission  group
RemoteUser      __MVC_SUPERUSER__
RobotLimit       50

ActionMap  deliver   <<EOR
sub {
	my $deliverable = shift;
	$Scratch->{deliverable} = $CGI->{mv_arg};
	$CGI->{mv_nextpage} = 'deliver';
	return 1;
}
EOR

ActionMap  get_password   <<EOR
sub {
	$Config->{NoSearch} = '';
	$CGI->{mv_nextpage} = $CGI->{mv_search_page} = 'action/get_password';
	$CGI->{mv_todo} = 'search';
	$Tag->update('process');
	return;
}
EOR

ParseVariables Yes
Route log       attach          0
Route log       cybermode       ""
Route log       empty           1
Route log       encrypt         0
Route log       increment       0
Route log       report          etc/log_transaction
Route log       supplant        0
Route log       track           etc/log

Route copy_user attach          0
Route copy_user cybermode       ""
Route copy_user empty           1
Route copy_user encrypt         0
Route copy_user increment       0
Route copy_user report          etc/mail_receipt
Route copy_user supplant        0
Route copy_user track           etc/log

# Main route must be last to make default
Route main      attach           0
#Route main      counter         etc/some.other.order.number
Route main      credit_card      0
Route main      cybermode        ""
Route main      default          1
Route main      email            __ORDERS_TO__
Route main      encrypt          0
Route main      encrypt_program  __ENCRYPTOR__
Route main      errors_to        __ORDERS_TO__
Route main      increment        0
Route main      pgp_cc_key       ""
Route main      pgp_key          ""
Route main      receipt          etc/receipt.html
Route main      report           etc/report
Route main      supplant         1
Route main      individual_track orders
Route main      track            etc/tracking.asc

SalesTax         state
SeparateItems Yes
SpecialPage          flypage        flypage
SpecialPage          catalog        index
SpecialPage          checkout       __ORDER_STYLE__/checkout
SpecialPage          order          __ORDER_STYLE__/basket
SpecialPage          search         results
SpecialPage          results        results
SpecialPage          report         ../etc/report
SpecialPage          receipt        ../etc/receipt

NoCache  reconfig special config query ord multi
Static        No
StaticAll     Yes
StaticDBM     static
StaticDepth   2
StaticDir     __SAMPLEHTML__/pages
StaticFly     Yes
StaticPath    __SAMPLEURL__/pages
TaxShipping   __TAXSHIPPING__
UpsZoneFile   products/450.csv
UseModifier   size color
AutoModifier  pricing:price_group

UserTag quick-table HasEndTag
UserTag quick_table Interpolate
UserTag quick-table Order  border
UserTag quick_table Routine <<EOF
sub {
    my ($border,$input) = @_;
    $border = " BORDER=$border" if $border;
    my $out = "<TABLE ALIGN=LEFT$border>";
    my @rows = split /\n+/, $input;
    my ($left, $right);
    for(@rows) {
        $out .= '<TR><TD ALIGN=RIGHT VALIGN=TOP>';
        ($left, $right) = split /\s*:\s*/, $_, 2;
        $out .= '<B>' unless $left =~ /</;
        $out .= $left;
        $out .= '</B>' unless $left =~ /</;
        $out .= '</TD><TD VALIGN=TOP>';
        $out .= $right;
        $out .= '</TD></TR>';
        $out .= "\n";
    }
    $out .= '</TABLE>';
}
EOF

# This UserTag sets a default font face, size, color
# or more in a table without having to type it in every
# time.
# 
# Usage:
# [table-font face="arial, helvetica" size="-1"]
# <TABLE><TR><TD>Test.</TD></TR></TABLE>
#    Will do multiple tables.
# <TABLE><TR><TD>Test.</TD></TR></TABLE>
# [/table-font]
#
UserTag table-font Order face
UserTag table-font PosNumber 1
UserTag table-font addAttr 1
UserTag table-font hasEndTag
UserTag table-font Routine <<EOR
sub {
    my ($face, $opt, $table) = @_;

    my @parms;
    push(@parms, qq{FACE="$face"})
        if $face;
    for(qw/size color/) {
        push(@parms, qq{\U$_\E="} . $opt->{$_} . '"')
            if $opt->{$_};
    }
    push(@parms, $opt->{extra})
        if $opt->{extra};
    my $front = "<FONT " . join(" ", @parms) . '>';
    $table =~ s:(<T[HD][^>]*>):$1$front:ig;
    $table =~ s:(</T[HD]\s*>):</FONT>$1:ig;
    return $table;
}
EOR

History 10
UserTag history-scan Order find exclude default
UserTag history-scan addAttr
UserTag history-scan Routine <<EOR
my %var_exclude = ( qw/
	mv_credit_card_number 1
	mv_pc                 1
	mv_session_id         1
/);
sub {
	my ($find, $exclude, $default) = @_;
	my $ref = $Vend::Session->{History}
		or return $Tag->area($default || $Config->{SpecialPage}{catalog});
	my ($hist, $href, $cgi);
	$exclude = qr/$exclude/ if $exclude;
	for(my $i = $#$ref; $i >= 0; $i--) {
		#Log("checking $ref->[$i][0] for $exclude");
		if ($exclude and $ref->[$i][0] =~ $exclude) {
			next;
		}
		if($find) {
			next unless $ref->[$i][0] =~ /$find/;
		}
		($href, $cgi) = @{$ref->[$i]};
		last;
	}
	return $Tag->area($default || $Config->{SpecialPage}{catalog})
		if ! $href;
	my $form = '';
	for(grep !$var_exclude{$_}, keys %$cgi) {
		$form .= "\n$_=";
		$form .= join("\n$_=", split /\0/, $cgi->{$_});
	}
	return $Tag->area( { href => $href, form => $form} );
}
EOR

WritePermission group

# Here you can set up fatal errors if a necessary sub or usertag
# doesn't exist, uncomment one of next lines to test
#Require globalsub   nevairbe
#Require usertag   nevairbe

Require usertag   email
Require usertag   email_raw
Require usertag   var
Require usertag   loc
Require usertag   summary
Require usertag   reconfig
