Server Object

Description

The Server object provides access to methods and properties on the server. Most of these methods and properties serve as utility functions.

Syntax

Server.property|method([parameters])

Properties

FoxWebPath The location where the FoxWeb software was installed.

Methods

AddScriptTimeout Extends the Script Timeout setting for the current script.
Execute Calls a FoxWeb FWX script.
HashMD5 Converts a string of arbitrary length to a 128-bit "fingerprint", using the MD5 algorithm. Can be used in conjunction with the EncryptPassword property of the Auth object.
HTMLEncode Applies HTML encoding to a string.
JSEscape Encodes a text for inclusion in a JavaScript string.
JSUnescape Reverses the effects of JSEscape.
SetScriptTimeout Sets the Script Timeout setting for the current script.
ToString Converts a variant of any data type to a string.
Transfer Transfers control to another FoxWeb FWX script.
URLDecode Converts a previously URLEncoded string back to its original (non-URLEncoded) content.
URLEncode Applies URL encoding, including escape characters, to a string.

FoxWebPath Property

Description

The Server.FoxWebPath property returns the directory where the FoxWeb software was installed.

This property is read only.

Syntax

sPath = Server.FoxWebPath


AddScriptTimeout Method

Description

The Server.AddScriptTimeout method extends the Script Timeout setting.

Syntax

Server.AddScriptTimeout(nSeconds, [bFromNow])

Parameters

nSeconds

The number of seconds to extend the Script Timeout by.

bFromNow

If this optional argument is set to .T., then the method extends the timeout to nSeconds from the time of the call -- otherwise it simply adds nSeconds to the total ScriptTimeout setting.

Example

<%
SELECT * FROM bill
SCAN
    * Extend the script timeout
    Server.AddScriptTimeout(5, .T.)
    * Time-consuming code that takes up to 5 seconds
    .
    .
    .
ENDSCAN
%>

Execute Method

Description

The Server.Execute method calls an FWX script from another FWX script or from a regular PRG script.

Syntax

cRetValue = Server.Execute(cScriptName, [vParam1, vParam2, ...])

Parameters

cScriptName

Specifies the name and location of the script to be called.

vParamX

A list of parameters that can be passed to the specified script name. You can pass up to 20 parameters of any data type, separated by commas.

Return Value

Variant: The value returned by the script.


HashMD5 Method

Description

The HashMD5 method utilizes the MD5 algorithm to convert a string of arbitrary length to a 128-bit "fingerprint". It is conjectured that it is computationally infeasible to produce two messages having the same message digest, or to produce any message having a given pre-specified target message digest. The MD5 algorithm is intended for digital signature applications, where a large file must be "compressed" in a secure manner before being encrypted with a private (secret) key under a public-key crypto-system. In essence, MD5 is a way to verify data integrity, and is much more reliable than checksum and many other commonly used methods. The Server.HashMD5 method returns its value as a 32-character string, corresponding to the hexadecimal representation of the 128-bit fingerprint.

In FoxWeb the HashMD5 can be used to "encrypt" passwords that will be used in conjunction with the EncryptPassword property of the Auth object.

Syntax

cFingerprint = Server.HashMD5(cTextString)

Parameters

cTextString

The string to be converted.

Return Value

Character: A 32-character string, corresponding to cTextString after it is processed with the MD5 algorithm.


HTMLEncode Method

Description

The Server.HTMLEncode method applies HTML-encoding to a specified string. HTML-Encoding a string can be useful in situations where you want the browser to display reserved HTML characters such as < and >. When browsers encounter these characters, they try to interpret them as HTML tags. To prevent this you must encode them with the HTMLEncode method.

Syntax

cOutput = Server.HTMLEncode(cSource])

Parameters

cSource

Specifies the string to encode.

Return Value

Character: The HTML-Encoded string.

Example

<%=Server.HTMLEncode("The <B> tag turns text into bold type")%>

In the above example the HTMLEncode method will return the following string:

The &lt;B&gt; tag turns text into bold type

JSEscape Method

Description

The Server.JSEscape method can be called to convert text into a valid format for use in a JavaScript string. The following characters are translated: \, ", ', Carriage Return (ASCII 13), Line Feed (ASCII 10) and Tab (ASCII 9).

Syntax

cOutput = Server.JSEscape(cSource)

Parameters

cSource

Specifies the string to encode.

Return Value

Character: The escaped string.


JSUnescape Method

Description

The Server.JSUnescape can return a JSEscaped string back to its original form. It can be used to manually deserialize JSON strings.

Syntax

cOutput = Server.JSUnescape(cSource)

Parameters

cSource

Specifies the string to unescape.

Return Value

Character


SetScriptTimeout Method

Description

The Server.SetScriptTimeout method sets the Script Timeout setting for the current script.

Syntax

Server.SetScriptTimeout(nSeconds)

Parameters

nSeconds

The number of seconds that the Script Timeout should be set to. If this value is smaller than the currently set Script Timeout then it is simply ignored.


ToString Method

Description

The Server.ToString method converts variants of most data types supported by VFP into character strings. Supported data types are Character, Date, DateTime, Numeric, Memo and Boolean. Character and Memo values are returned without any conversion, while Boolean values are returned as "True" or "False".

Syntax

cOutput = Server.ToString(vSource)

Parameters

vSource

Specifies the value that is to be converted to character format.

Return Value

Character: The converted value.


Transfer Method

Description

The Server.Transfer method calls an FWX script from another FWX script or from a regular PRG script. It works similarly to Server.Execute with the exception that control does not return back to the calling script. It is equivalent to a Server.Execute followed by Response.End.

Syntax

Server.Transfer(cScriptName, [vParam1, vParam2, ...])

Parameters

cScriptName

Specifies the name and location of the script to be called.

vParamX

A list of parameters that can be passed to the specified script name. You can pass up to 20 parameters of any data type, separated by commas.


URLDecode Method

Description

The Server.URLDecode method converts a previously URL-Encoded string back to its original content. Browsers URL-Encode the Query String and in most cases the POST data before sending it to the Web server. Even though the Request.QueryString and Request.Form methods automatically decode these values, this function can be useful when trying to process the contents of the QUERY_STRING server variable, or the Post data buffer directly.

Syntax

cOutput = Server.URLDecode(cSource)

Parameters

cSource

Specifies the string to decode.

Return Value

Character: The URL-Decoded string.

Example

<%=Server.URLDecode(Request.ServerVariables("QUERY_STRING"))%>

URLEncode Method

Description

The Server.URLEncode method can be called to convert a string into a valid format for use in a URL. Characters such as '&' are converted to codes as they have special meanings when found within a URL. The new encoded string is returned.

Syntax

cOutput = Server.URLEncode(cSource)

Parameters

cSource

Specifies the string to encode.

Return Value

Character: The URL-Encoded string.

Example

<%='<a href="MyProg.fwx?name=' + Server.URLEncode(Name) + '">'%>

© Aegis Group