File/utils.php

Description
Constants
SCRIPT_APPEND = 1 (line 232)

Add script by keeping current content and appending to the end

SCRIPT_PREFIX = 2 (line 234)

Add script by keeping current content and prefixing to the beginning

SCRIPT_REPLACE = (line 230)

Add script by replacing current content (default)

Functions
add_http_prefix (line 349)

Make sure there is an http:// on a URL. If already present then string is returned untouched.

  • return: The URL prefixed with the protocol
string add_http_prefix (string $url, [string $ssl = false])
  • string $url: URL to add protocol prefix to
  • string $ssl: If true then add "https", else "http"
defaulted (line 158)

Return a value which may be defaulted Returns the value of the variable, if it is valid, otherwise returns the specified default value.

  • return: Either the value, or the default
mixed defaulted (mixed $val, mixed $default)
  • mixed $val: The value of interest
  • mixed $default: The default value to apply if $val is empty
errorcode_exit (line 145)

Exit with HTTP error code Send a simple error code and then die.

void errorcode_exit (integer $code)
  • integer $code: HTTP error code
error_exit (line 67)

Exit the application with error message Echo the message and leave. Intended to handle 'emergencies'.

void error_exit (string $heading, [string $msg = ""])
  • string $heading: Message heading, subject
  • string $msg: Message in detail
format_name (line 413)

Returns the name in the form SURNAME, Firstname.

  • return: The name in format SURNAME, Firstname
string format_name (string $firstname, string $lastname)
  • string $firstname: First name
  • string $lastname: Last name(s)
href_addparm (line 364)

Add a parameter keyvalue pair to a URL. We check that it isn't already there, and use the right delimiter.

void href_addparm (string $href, string $pname, string $pvalue)
  • string $href: URL to append the new parm to
  • string $pname: Name of the parameter
  • string $pvalue: Value of the parameter
href_delparm (line 387)

Remove a parameter keyvalue pair from a URL.

void href_delparm (string $href, string $pname)
  • string $href: URL to remove the parm from
  • string $pname: Name of the parameter
HTTPError (line 107)

Return an HTTP error message

Returns a formatted HTTP Error

  • return: The formatted HTTP error code
string HTTPError (integer $code)
  • integer $code: HTTP error code
inline_script (line 236)
void inline_script (mixed $newscript, [mixed $oldscript = ""], [mixed $mode = SCRIPT_REPLACE])
ip_format (line 174)

Format a string (dotted) form of an IP address. We make sure we have

the full dotted quad, and if we have to pad it with zeroes, then we add the network spec (/24, /16 etc.) as well. If the given IP already has a netmask, then we don't change it, and assume the IP is already correctly formatted by someone who knows what they are doing!

  • return: The padded IP address
string ip_format (mixed $ip, string $pi)
  • string $pi: IP address in string dotted format
is_ipaddress (line 212)

Check string to see if it is in IPv4 format. This is pretty simplistic. It returns true if the string $ip is of the form 'n.n.n.n'.

  • return: True if it is in IPv4 format
bool is_ipaddress (mixed $ip)
log_sys (line 48)

Send a message to the system logfile Send message to the syslog, prefixed with APP_NAME nicely. Saves having to prefix it each time.

void log_sys (string $msg, [string $prefix = ""])
  • string $msg: Message to enter into the system log
  • string $prefix: Prefix to the message
next_sequencevalue (line 305)

DEPRECATED: This global utility function is now deprecated since the

code is non-database-independent, and was written solely to support Postgresql sequences. Instead, please update your code to use the new 'get_next_sequencevalue()' global function, or 'next_sequencevalue()' methods on the 'dbupdate' and 'dbinsert' classes, or else use the new 'dbseq' class itself. Return next sequence value - get the next value of the given sequence

  • return: The next sequence value
integer next_sequencevalue (string $seq)
  • string $seq: The name of the sequence to get the next value of
nicebytesize (line 481)

Returns a nicely formatted size string for displaying

byte sizes. Eg. 1024 returns '1Kb', etc. Obviously this is a display-only string, not a number. You can specify the number of decimal places, and the thousands separator if you for example want nullstring instead of a comma.

  • return: A formatted bytesize eg.
string nicebytesize (integer $bytes, [integer $decimals = 0], [string $thousep = ","])
  • integer $bytes: Number of bytes.
  • integer $decimals: Number of decimal places to report
  • string $thousep: Thousands separator
nicetime (line 453)

Returns a nicely formatted time string in '3d 12h 14m 33s' format, given a number of seconds. Leading elements are suppressed if they are zero.

  • return: A formatted time string eg: '12h 14m 33s'
string nicetime (integer $secs)
  • integer $secs: Number of seconds to convert to time string
protocol_prefixed (line 325)

Detect a URL with the "xxx://" protocol prefix. Returns true if it does, else false.

  • return: True if it is a prefixed URL
boolean protocol_prefixed (string $url)
  • string $url: URL to detect protocol prefix
quoted_valuestring (line 426)

Returns a value inside quotes. The type of quotes (single or double) are determined from the value content. If the content already has a double quote in it, then single quotes are used, else (default) double quotes are used.

  • return: The value string with appropriate quotes around it.
string quoted_valuestring (mixed $val)
resolveFK (line 276)

Resolve a foreign key value Resolve a simple single-level foreign key. The variable 'display_fields' can contain multiple fields separated by the "|" char. A literal is prefixed by "#".

  • return: The returned value
mixed resolveFK (mixed $fkey, string $tbl, string $key_field, string $display_fields)
  • mixed $fkey: The value of the foreign key field to look up
  • string $tbl: The name of the table to look up in
  • string $key_field: Name of the key field to look up
  • string $display_fields: Name of the display fields to get data from
strip_http_prefix (line 336)

Strip off any xxxx:// protocol prefix from a URL. Usually in Axyl, this is "http://", hence the name of this function.

  • return: URL stripped of protocol prefix.
string strip_http_prefix (string $url)
  • string $url: URL to strip of protocol prefix
vspace (line 36)

Insert vertical space in table Insert some vertical whitespace into a table.

  • return: HTML for a row of the given height
string vspace (integer $height, [integer $cols = 1])
  • integer $height: Whitespace height in pixels
  • integer $cols: No. of columns in the target table

Documentation generated by phpDocumentor 1.3.0RC3