These commands let you conditionally execute script and send HTML.
if, ifnot, else, endif
The commands if and ifnot require a full expression to evaluate. This expression is in the form:<!-- #if VARIABLE OPERATOR param1 param2-->
Where VARIABLE is one of the scripting environment variables listed below, a user defined variable ( see set ), or the contents of a Form Field or HTTP Request Header.
OPERATOR can be on of the following:
CONTAINS, IS, STARTSWITH, GREATER_THAN, LESS_THAN.Not all variables support every operator.
You can nest if - endif and ifnot - endif blocks. Each if or ifnot command must be balanced by an endif, or else and endif commands to form an execution block.
if command
When the expression is true, the script and html within the block will be processed, otherwise it is discarded until an else or endif command is found in the file.ifnot command
When the expression is false, the script and html within the block will be processed, otherwise it is discarded until an else or endif command is found in the file.
Valid VARIABLEs and OPERATORs
Theses are the variables you can use with the if and ifnot commands.
- ADDRESS Test the user's address against a string.
- COUNT Test numbers against the page's view count.
- DAYOFMONTH Test the current day of the month ( 1 thru 31 ) against a list of dates.
- DAYOFWEEK Test the current day of the week against a list of day names.
- DIRNAME Test the contents the of the directory name string against a string.
- FALSE Never run this block
- FIELDS Test the contents of two HTML Forms fields against each other.
- FormsData Test the contents the of any HTML Forms Data against a string.
- HTTPRequestHeader Test the contents the of any HTTP Request Header against a string.
- LOCATION / DOCUMENT_URI Test the contents the of the location of the page as provided in the URL.
- MONTH Test the current month against a list of month names.
- PARENT_DIRNAME Test the contents the of the Parent Directory name string against a string.
- PATH_INFO / PATH_ARGS Test the contents the of the Path Args string against a string.
- REFERER Test the URL of the referring page against a string.
- REGISTER_ERR Test the contents the of the Register Error string against a string.
- TIMEOFDAY Test the current hour of the day ( 24 hour clock ) against a list of hours.
- TRUE Always run this block.
- USER_AGENT Make a case sensitive comparison of the browser string against a string.
- UserVariable Test the contents the of any UserVariable string against a string.
ADDRESS
Test the user's address against a string.Operand is a quoted IP address (ie: "199.35.3." )
Operators are IS, STARTSWITH or CONTAINS; use IS for an exact match, STARTSWITH for a sub-string match beginning with the first character, CONTAINS for a sub-string match beginning at any character.
Example
<!-- #if ADDRESS CONTAINS "199.35.3." -->show this to clients in Spider Island's net
<!-- #endif -->
COUNT
Test numbers against the page's hit count.Parameters are any number
Operators are IS, GREATER_THAN or LESS_THAN
example
<!-- #if COUNT IS 100 -->You are the 100th visitor and win a free trip to this URL....
<!-- #endif -->
DAYOFMONTH
Test the current day of the month ( 1 thru 31 ) against a list of dates.Operands are 1 ... 31
Operator is IS
Example
<!-- #if DAYOFMONTH IS 25 -->show this at the 25th of any month
<!-- #endif -->
DAYOFWEEK
Test the current day of the week against a list of day names.Operands are SUN MON TUES WED THUR FRI SAT
Operator is IS
example
<!-- #if DAYOFWEEK IS SAT SUN -->show this on Saturday and Sunday
<!-- #endif -->
DIRNAME
Test the contents the of the Directory name string against a string. Operators are IS or CONTAINS, use IS for an exact match; CONTAINS for sub-strings.
FALSE
Never run this block
example
<!-- #if FALSE -->never show this
<!-- #else-->
always show this
<!-- #endif -->
FIELDS
Test the contents of two HTML Forms fields against each other. Operators are IS, GREATER_THAN or LESS_THAN . The strings are compared for case-insensitive equality.
example
<!-- #if FIELDS IS pcheck password -->Compares the contents of the two field names for case sensitive equality. See the BBS registration pages "reg.spml" to see how it can be used for checking a password.
FormsData
Test the contents the of any HTML Forms Data against a string. Operators are IS, STARTSWITH or CONTAINS, use IS for an exact match; CONTAINS for sub-strings. See also the #set command.
HTTPRequestHeader
Test the contents the of any HTTP Request Header against a string. Operators are IS, STARTSWITH or CONTAINS. Use IS for an exact match; CONTAINS for sub-strings. See also the #set command.
LOCATION / DOCUMENT_URI
Test the contents the of the location of the page as provided in the URL. Operators are IS, STARTSWITH or CONTAINS. Use IS for an exact match; CONTAINS for sub-strings.
MONTH
Test the current month against a list of month names.Operands are JAN FEB MAR APR JUN JUL AUG SEP OCT NOV DEC
Operator is IS
Example
<!-- #if MONTH IS DEC -->show this during December
<!-- #endif -->
PARENT_DIRNAME
Test the contents the of the Parent Directory name string against a string. Operators are IS or CONTAINS, use IS for an exact match; CONTAINS for sub-strings.
PATH_INFO / PATH_ARGS
Test the contents the of the Path Args string against a string. Operators are IS or CONTAINS, use IS for an exact match; CONTAINS for sub-strings.
REFERER
Test the URL of the referring page against a string.Operand must be a quoted string (ie: "http://www.spiderisland" )
Operators are IS, STARTSWITH or CONTAINS; use IS for an exact match, STARTSWITH for a sub-string match beginning with the first character, CONTAINS for a sub-string match beginning at any character.
Example
<!-- #if REFERER CONTAINS "www.spiderisland.com" -->show this to browsers linking from Spider Islands homepage
<!-- #endif -->
REGISTER_ERR
Test the contents the of the Register Error string against a string. See also the #register command. Operators are IS or CONTAINS, use IS for an exact match; CONTAINS for sub-strings.
TIMEOFDAY
Test the current hour of the day ( 24 hour clock ) against a list of hours.Operands are 0 ... 23
Operator is IS
Example
<!-- #if TIMEOFDAY IS 0 1 -->show this at midnight and 1 am
<!-- #endif -->
TRUE
Always run this block.
USER_AGENT
Make a case sensitive comparison of the browser string against a string.Operand is a quoted string (ie: "Mozilla 1.0" )
Operators are IS or CONTAINS, use IS for an exact match; CONTAINS for sub-strings.
Example
<!-- #if USER_AGENT CONTAINS "Mozilla" -->show this to any version of NetScape only
<!-- #else-->
show this to any other browser
<!-- #endif -->
UserVariable
Test the contents the of any UserVariable string against a string. Operators are IS or CONTAINS, use IS for an exact match; CONTAINS for sub-strings. See also the set command.