[an error occurred while processing this directive]

18. System Variables


System variables are automatically initialized when a Miva Script program begins execution. There are two types of system variables:

All of the time-related variables (except for dyn_time_remaining and globaltimeout) have both static and dynamic versions: the dynamic variables start with the dyn_ prefix. With the exception of recno, all other system variables are static.

Time Variables
Dynamic
Static
Return value
dyn_time_t
time_t
Number of seconds since 1 Jan. 1970 (numeric)
dyn_tm_hour
tm_hour
Hour in current day (numeric)
dyn_tm_isdst
tm_isdst
Has the value true (1) if daylight time is in effect in this time zone (boolean)
dyn_tm_mday
tm_mday
Day of the month (numeric)
dyn_tm_min
tm_min
Minutes in current hour (numeric)
dyn_stm_mon
stm_mon
Month of the year (string)
dyn_tm_mon
tm_mon
Month of the year (numeric)
dyn_tm_sec
tm_sec
Seconds in current minute (numeric)
dyn_tm_usec
tm_usec
The current microsecond, relative to dyn_tm_sec or tm_sec. (On Windows, this value is updated only in 50-millisecond increments).
dyn_stm_wday
stm_wday
Day of the week (string)
dyn_tm_wday
tm_wday
Day of the week (numeric)
dyn_tm_yday
tm_yday
Day in year (numeric)
dyn_tm_year
tm_year
Year (numeric)
dyn_stm_zone
stm_zone
The time zone (string)
---
globaltimeout
Maximum total number of seconds that this script can execute.
dyn_time_remaining
---
Number of seconds before the current script will time out.

Note: The values returned by the dyn_tm_ variables are not zero-padded; for example, if the time is 12:04, dyn_tm_min returns '4', not '04'. You can use the padl() function to perform padding, if required.

CGI, HTTP, and Other Variables

All available CGI environment variables are automatically converted into static Miva Script system variables upon start-up. All HTTP headers are saved in environment variables and therefore are also converted to Miva Script static variables. The availability of environment variables depends on the server software; the availability of HTTP headers also depends on the browser; therefore, not all variables listed here are guaranteed to be available in all circumstances. For more information on HTTP headers and environment variables, consult a CGI reference and/or your server documentation.

Note: HTTP servers convert HTTP headers into environment variables in which '-' is converted to '_', and to which the prefix 'HTTP' is added.

In the CGI version of Miva Empresa, all available HTTP headers and CGI variables (except for TERMCAP, MAIL, LOGNAME, and PATH) are accessible. In the NSAPI version, a selection of variables and headers (listed below) are accessible. With Miva Mia, all available headers are accessible, as are the variables remote_addr, remote_host, request_method, server_name, server_port, and server_protocol.

The list below contains many of the variables that you may encounter. If the browser and/or server software support other variables, they will be inherited by Miva Script where possible. The following key is used in the table below to summarize the accessibility of system variables:

Origin:

S: generated by Miva Empresa, Miva Mia

E: if available, inherited from environment

H: if available, inherited from HTTP header (via the environment)

Platform:

C: accessible with CGI version of Miva Empresa

N: accessible with NSAPI version of Miva Empresa

P: accessible with Miva Mia

For example, E: C,N means that the variable in question is inherited from the environment and is accessible in the CGI and NSAPI versions of Miva Empresa.

Variable
Return Value
Accessibility
apitype
Platform: 'CGI', 'NSAPI', or 'Mia' (Miva Mia)
S: C,N,P
argN
If a list of values is passed to a Miva Script program, argN is the value of the Nth argument on the URL used to call the script. arg1 always contains the program file name. The first argument after the file name will be arg2, and so forth.
S: C,N,P
auth_type
Authentication method user by the server
E: C,N
callerid
Each time a cookie-enabled browser accesses a Miva Script document, Miva Script creates a 32-character cookie that is unique to that browser and URL. The cookie lasts for one year after being set. Cookies can be turned off in Miva Empresa; contact your server administrator.
S: C,N,P
content_length
Length of any attached (POST) information
E: C
content_type
Type of data for POST
E: C
documenturl
Contains URL of the currently running Miva Script program. This URL also contains the character between the program name and the command line arguments ('+' for NSAPI and Miva Mia, and '?' for CGI).
S: C,N,P
gateway_interface
Version of CGI used
E: C
http_accept
Comma-separated list of MIME types (type/subtype) that the browser will accept. This list is very incomplete on most browsers.
H: C,N,P
http_accept_charset
Character sets preferred by the browser (other than the default ASCII or ISO Latin-1)
H: C,N,P
http_accept_language
ISO codes for the languages preferred by the browser
H: C,N,P
http_connection
String that browser sends to the server to preserve a TCP connection (also called a "keep-alive" string). Not supported by all browsers and servers.
H: C,N,P
http_cookie
Contents of all the cookies set for the document.
H: C,N,P
http_host
Remote host name (usually same as server_name)
H: C,N,P
http_pragma
Mode client is running under
H: C,P
http_referer
The document that the current document was accessed from.
H: C,P
http_user_agent
Browser name, platform, version, and library
H: C,N,P
mivaversion
Version of the Miva Script language preprocessor
S: C,N,P
nargs
If a list of values is passed to a Miva Script program, nargs is the number of arguments on the URL, including the program file name.
S: C,N,P
path_info
Extra path information in the URL (a directory path that occurs immediately after the name of the CGI program in the URL)
E: C,N
path_translated
path_info, translated to a physical location by prepending the server document directory to its value
E: C
process_id
Currently running process number
S: C,N,P
query_string
Information passed after a URL and a "?" via the GET method
E: C
recno
Current record number in a flat file being accessed by <MvIMPORT>, or current record number in a database
S: C,N,P
remote_addr
IP address of remote host
E: C,N,P
remote_host
The domain name of the remote host
E: C,N,P
remote_ident
Remote user name, from servers that support RFC 931 identification
E: C
remote_user
User name associated with protected script, on servers that support user authentication
E: C,N
request_method
GET, POST, or HEAD
E: C,N,P
script_name
Virtual path to CGI script; not mapped locally to actual path
E: C
server_hostname
The name of the server
E: C,N
server_name
Same as server_hostname
E: C,N,P
server_port
Port under which server is running
E: C,P
server_port_secure
Whether the port is secure (boolean)
E: C
server_protocol
Name and revision of protocol used
E: C,N,P
server_software
HTTP server and version number that processed the request
E: C,P
server_url
server_hostname, in URL format
E: C,N
server_version
Version of the server
E: C,N
user_agent
Same as http_user_agent
H: N
version
Miva Empresa or Miva Mia version number
S: C,N,P

Miva Script also allows site administrators to define their own system variables. Check with your administrator to find out whether any have been added to your site.

Note: Miva does not give scripts direct access to standard input (STDIN).