This library offers some useful functions of the operating system, such as date, and file operations. More system functions are offered by Lua itself - see Lua's manual section 6.4 I/O Facilities. | |
Library's author(s): | Anna Hester and Renato Borges |
Loaded by default: | yes |
Reference: | See above. |
Description | |||
This function creates a directory on the local filesystem. | |||
Parameters | |||
| |||
Return | |||
Returns nil in case of failure or 1 in success.
|
Description | |||
Changes the current directory to the directory specified. | |||
Parameters | |||
| |||
Return | |||
No return. In case of failure, the script is aborted and an error message is given. |
Description |
Retrieves the current working directory. |
Return |
A string containing the complete path of the current working directory. |
Description | |
Copy the file in the path source to target .
| |
Return | |
A nil return indicates that an error occurred; in this
case, the second return is a string describing the error.
| |
Example of use | |
|
Description | |||
Retrieves the file type. | |||
Parameters | |||
| |||
Return | |||
One of the strings "file" , "directory" or
"other" according to the file type, or nil
if the file type could not be retrieved.
|
Description | |||||
Retrieves the last modification time of a file. | |||||
Parameters | |||||
| |||||
Return | |||||
A string with the last modification time, according to the format specified. | |||||
Example of use | |||||
The following code:
produces the following output: |
Description | |||||
Converts a date to the corresponding number of seconds since January 1st, 1970. | |||||
Parameters | |||||
| |||||
Return | |||||
The corresponding number of seconds. | |||||
Example of use | |||||
The following code:
produces the following output: |
Description | |||||
This function takes a number and converts it to a date, considering that the number is the number of seconds since January 1th, 1970. | |||||
Parameters | |||||
| |||||
Return | |||||
The date corresponding to the number of seconds given as parameter. | |||||
Example of use | |||||
The following code:
produces the following output: |
Description | |||||
This function locks or unlocks a file. The mechanism is called "advisory record locking" because the lock does not prevents unauthorized access on the file, only helps programs to implement exclusive file operations. It depends, then, on programing discipline to work correctly. | |||||
Parameters | |||||
| |||||
Return | |||||
Returns nil in case of failure or 1 in success.
| |||||
Example of use | |||||
The following code waits until no other process is using
the file to set a lock:
|
Description | |||
This function makes the current process or thread sleep for msec
miliseconds.
| |||
Parameters | |||
|
This library offers access to databases. On Unix systems, the Mini SQL database can be accessed. On Windows systems, any database with a ODBC driver can be accessed (MS Access, SQL Server, Oracle, Ingres, ...). | |
Library's author(s): | Mauricio Mediano |
Loaded by default: | no |
Reference: | See main functions above, but for further details refer to DBLua's homepage. |
Description | |||
This function opens a connection to the database described by dbdescr .
| |||
Parameters | |||
| |||
Return | |||
Returns nil if the connection were successfuly open or
a string describing the error occurred.
| |||
Example of use | |||
On ODBC systems:
When authentication is needed to be done explicity, the values
On Mini-SQL systems:
| |||
Notes | |||
For portability, DATABASE and DSN keywords
are equivalent, and HOST is ignored on ODBC systems.
Therefore, a connecition string "HOST=davinci;DATABASE=agenda; |
Description | |||
Executes an SQL command on the open database connection. | |||
Parameters | |||
| |||
Example of use | |||
For helping avoiding confusion with Lua's string delimiters (
| |||
Notes | |||
In case of error in the SQL statement, an execution error is issued, aborting
the execution of the script. To avoid this kind of behavior, execute
commands to test error situations (e.g test if a record exists with a
SELECT statement before trying to deleting it).
If this behaviour is really unconvenient, the error signal can
be avoided redefining DBExec to use a different
error method (see Lua's manual for details and the file cgilua.conf/dblua.lua
for an example of this kind of redefinition).
|
Description | |||||||||||||||||
This function retrieves the next row of the result table produced by the SQL query previously executed (function DBExec). | |||||||||||||||||
Return | |||||||||||||||||
A Lua table containing the row data,
with all the columns of the result table in positional order
(indexes [1] , [2] , ... ) and also indexed by
each column's name (indexes [" ,
[" , ... ). When there is no next row
(the result table has reached its end) the return is nil .
| |||||||||||||||||
Example of use | |||||||||||||||||
Suppose there is table named "employees " in the database,
with the following format and data:
The following commands could be used in a
And the result would be: On the first cycle of the loop, the
Lua table The same commands could be done is a HTML template:
| |||||||||||||||||
Notes | |||||||||||||||||
Null values are translated to nil values in Lua, therefore care
should be taken with tables that accept NULL values. In the previous example
the following code could be written to avoid problems trying to write
nil values:
|
Description | |
This function closes the active database connection, open with DBClose. | |
Example of use | |
|
This library provides some cryptography functionalities, such as functions for secret-key cryptography, message digest (hash) function, and RFC 822 encoding/decoding functions (useful for building MIME compliant messages, for instance). | |
Library's author(s): |
[target unknown] (MD5), Roberto Ierusalimschy (MD5), Frederico Liporace (DES) and Anna M. Hester (Encode, DES) |
Loaded by default: | yes |
Reference: | See above. |
Description | |||||
This function does a 56-bit DES cryptography, using the "Fast DES" algorithm as coded and proposed by Stuart Levy, Minnesota Supercomputer Center. | |||||
Parameters | |||||
| |||||
Return | |||||
This function returns the encrypted data, a full 8-bit buffer that can be normally held by Lua variables. | |||||
Example of use | |||||
See the following code:
Note the use of encode before displaying the
encrypted | |||||
Notes | |||||
For printing the encrypted data or sending it with URLs, use
the encode functions (safe 7-bit ASCII characters)
and the cgilua.escape related functions (safe URL encoding).
Establishing a reasonably secure system with the use of
this library requests adicional measures than simply applying
this function to sensitive data.
Note that if Also note that 56-bit cryptography schemes are not considered safe from brute-force attacks. |
Description | |||
This function decrypts a buffer, using the DES cryptography algorithm. | |||
Parameters | |||
| |||
Return | |||
The original data, decrypted. | |||
Example of use | |||
| |||
Notes | |||
See function crypt for further details. |
Description | |||
This function executes a Lua file that has been encrypted with the crypt executable utility. Lua files precompiled before being encrypted are also accepted. | |||
Parameters | |||
| |||
Notes | |||
If anything wrong happens, a Lua error is issued. This function is normally used to protect source files of Web Systems, and is only useful with the executable to crypt the files. Using the function crypt to create the crypted files is not valid since the internal key for both are different. The crypt executable is provided by request. If you are interested, please contact [topic unknown]. |
Description | |||
This function decrypts an encrypted file and returns its content. | |||
Parameters | |||
| |||
Return | |||
The first return is the decrypted content, the second is the size in bytes of the decrypted content. Both can be normally handled by Lua variables. | |||
Example of use | |||
| |||
Notes | |||
As in docryptedfile, this function is only useful
with the executable to encrypt the files. A usual application is
to use this function inside the preprocess module
(cgilua.conf/preprocess.lua ), so CGILua will only
accept encrypted templates.
|
Description | |||
This function applies the hash algorithm Message Digest 5 to the input. | |||
Parameters | |||
| |||
Return | |||
The result of the MD5 operation on the input. | |||
Example of use | |||
|
Description | |||||
Performs binary exclusive XOR on the buffers taken as arguments. It can be useful to build other cryptography functions with the md5 function. | |||||
Parameters | |||||
| |||||
Return | |||||
The resulting binary buffer. |
Description | |||
Performs the conversion of arbitrary 8-bit buffers to a string of 7-bit ASCII characters, as specified in RFC 822. It is traditionally used to attach binary data to eletronic messages (since SMTP gateways may refuse to accept non-ASCII messages), but is also applied in general situations in which the encoding of binary data is required. | |||
Parameters | |||
| |||
Return | |||
The resulting encoded string. | |||
Example of use | |||
The code above:
Produces the following output:
|
Description | |||
Restores a buffer encoded with the encode function. | |||
Parameters | |||
| |||
Return | |||
The decoded buffer. | |||
Example of use | |||
From the example in function encode:
the resulting output is:
|
Cookie is an HTTP mechanism for managing state information on the client side of the HTTP connection. This library offers some functions for cookie handling, hiding from the user some crude details of the HTTP headers format. | |
Library's author(s): | Anna M. Hester |
Loaded by default: | yes |
Reference: | See above. |
Description | |||
This function makes the server inform the value of the cookie stored in the name
name , which was provided by the client (browser)
when the current script was requested.
| |||
Parameters | |||
| |||
Return | |||
The value of the cookie requested. | |||
Example of use | |||
The code above:
produces the following output: | |||
Notes | |||
Description | |||||||||||||
This function issues the HTTP header needed to set a cookie on the client machine. | |||||||||||||
Parameters | |||||||||||||
| |||||||||||||
Example of use | |||||||||||||
The code below implements a simple client-side counter:
| |||||||||||||
Notes | |||||||||||||
This function must be a part of the HTTP header of the script, so it
must be called before any body content is written
(e.g, write with HTML code). The function can be called
multiple times to set more than one cookie.
As this function must be called when the HTTP header is still being built, its use only makes sense in Lua scripts. Care should be taken to call this function *before* an HTTP header ending function is called (such as cgilua.htmlheader). To set cookie values on HTML templates, please refer to function setcookiehtml. |
Description | |||||||||||||
Same as function setcookie, but useful to be called in HTML templates. | |||||||||||||
Parameters | |||||||||||||
| |||||||||||||
Return | |||||||||||||
Value of the Set-Cookie header needed to set the specified cookie.
| |||||||||||||
Example of use | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
This function must be called inside the <head> and
</head> HTML tags.
|
Description | |||
Removes the cookie named name from the client machine.
| |||
Parameters | |||
| |||
Example of use | |||
|
This library provides support for dynamic library loading. | |
Library's author(s): | Renato Borges |
Loaded by default: | yes |
Reference: | See above. |
Description | |||||
Loads the library loadlib .
| |||||
Parameters | |||||
| |||||
Return | |||||
The function returns a handle to be used with the functions unloadlib and
callfromlib. If the library cannot be loaded, the function returns
nil as the first return and a string describing the error as a the second return.
| |||||
Example of use | |||||
|
Description | |||
Unloads the library whose handle is libhandle .
| |||
Parameters | |||
| |||
Example of use | |||
| |||
Notes | |||
The Lua functions eventually registered by the library are not automatically removed. |
Description | |||||
Call the function funcname from the library whose handle is
libhandle .
| |||||
Parameters | |||||
| |||||
Example of use | |||||
| |||||
Notes | |||||
Typically, you use callfromlib only once, after loadlib,
to call an "open" function that will register the library functions in the Lua environment.
|
Allows a message to be sent via an SMTP mail server. | |
Library's author(s): | Anna Hester |
Loaded by default: | yes |
Reference: | See above. |
Description | |||||||||||||||
Sends a message to the recipients listed in to .
| |||||||||||||||
Parameters | |||||||||||||||
| |||||||||||||||
Return | |||||||||||||||
Returns a non-nil value (1 ) if the message was successfully sent or
nil if an error occurred, with the second return being a string
describing the error.
| |||||||||||||||
Example of use | |||||||||||||||
| |||||||||||||||
Notes | |||||||||||||||
On Windows systems, is mandatory to specify the field "mailserver ".
It is possible to set this value globally to all scripts defining the
Lua global variable MAILSERVER .
On Unix systems, please verify if the path to the sendmail executable is
correct (file cgilua.conf/mail.lua ).
|
Library of HTML "classes" that allows HTML tags to be built using operations on Lua objects (and not Lua strings). | |
Library's author(s): | Anna Hester |
Loaded by default: | no |
Reference: | See the homepage and the source code (included in CGILua's distribution). |
HTK is a library of Lua constructors to create HTML forms elements. HTK is based on the Htmltoolkit. | |
Library's author(s): | Tomás Guisasola Gorham |
Loaded by default: | no |
Reference: | See the homepage and the source code (included in CGILua's distribution). |