Utility library. Implements some general purpose functions plus some wrappers that implement functionality available in PHP 5.
function SESSION( |
| ) |
A wrapper for the $_SESSION superglobal. Provides a handy way to avoid undefined variable warnings without explicitly calling isset() or empty() every time.
key | The key for the superglobal index. |
val | The optional value to set to the superglobal. |
The value of the superglobal at index key, false if index is not set.
function SERVER( |
| ) |
key | The key for the superglobal index. |
val | The optional value to set to the superglobal. |
The value of the superglobal at index key, false if index is not set.
function COOKIE( |
| ) |
key | The key for the superglobal index. |
val | The optional value to set to the superglobal. |
The value of the superglobal at index key, false if index is not set.
function POST( |
| ) |
key | The key for the superglobal index. |
val | The optional value to set to the superglobal. |
The value of the superglobal at index key, false if index is not set.
function GET( |
| ) |
key | The key for the superglobal index. |
val | The optional value to set to the superglobal. |
The value of the superglobal at index key, false if index is not set.
Determine if there is any POST data.
True if $_POST has any members, false otherwise.
function current_uri( |
| ) |
Convenience function to return the path to the current script. Useful for the action attribute in form tags.
relative | Optionally get the URI relative to the current directory, i.e. just the file name. Default is false. |
query_string | Query string to append to URI. Default is false, which mean that the current query string will be used. |
no_escape | Indicates whether or not ampersands in the query string should be escaped as &, which is needed for XHTML compliance. |
A string with the URI.
function current_file( |
| ) |
An alias for current_uri(true, false, $no_escape).
function current_url( |
| ) |
The absolute URL of the requested script.
Quick function to get the user's IP address. This should probably be extended to account for proxies and such.
The numeric IP address of the client.
Get the user's user-agent string, or a default if it is not set.
A string representing the user agent.
function getlink( |
| ) |
Returns a path suitable for use with <link> tags or as an href or src attribute. Takes a file name and optional type (script, image, or style sheet) and returns a URI. If the type is not given, the function guesses it from the file extension.
name | The filename of the item to link. |
type | The optional type of the item. May be one of the defined constants LINK_IMAGE, LINK_SCRIPT, of LINK_STYLESHEET. |
The root-relative path to the item. If no item is found in any path, returns the name parameter as-is.
function sanitize( |
| ) |
Strips the input of certain characters. This is a thin wrapper around the preg_replace function.
str | The string to strip. |
pattern | The pattern to match. Default is /\W/, i.e. non-word chars. |
sub | The substitution string for pattern, default is null string. |
The string with all characters matching sub replaced by the sub character.
function in_arrayi( |
| ) |
Like in_array() standard function, except case-insensitive for strings.
function make_uri( |
| ) |
Builds a correct URI with query string. This is an all-purpose kind of function designed to handle most contingencies.
base | The base URI to use. If not given, the current URI is used. |
query_string | An associative array representing the query string. |
no_get | A boolean set to true to suppress automatic importing of the $_GET superglobal into the query_string parameter. |
link_sep | Character to separate query string parameters. Default value is '&' for link hrefs. Use '&' for redirects. |
add_host | If set to true, adds a host and protocol to the returned URI if they are not already present. |
A string containing the resulting URI.
function get_entry_from_uri( |
| ) |
Takes a URI and converts it into an entry object.
function ahref( |
| ) |
Creates markup for a hyperlink.
href | The URL to link to. |
text | The main link text. |
attribs | An associative array of additional attributes, with the key as the attribute name. |