Overview

Packages

  • Util

Classes

  • Horde_Array
  • Horde_Array_Sort_Helper
  • Horde_Domhtml
  • Horde_String
  • Horde_Util
  • Horde_Variables
  • Overview
  • Package
  • Class
  • Tree

Class Horde_Util

The Horde_Util:: class provides generally useful methods.

Copyright 1999-2012 Horde LLC (http://www.horde.org/)

See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

Package: Util
Category: Horde
License: LGPL 2.1
Author: Chuck Hagenbuch chuck@horde.org
Author: Jon Parise jon@horde.org
Located at Horde/Util.php
Methods summary
public static object &
# cloneObject( object & $obj )

Returns an object's clone.

Returns an object's clone.

Parameters

$obj
$obj The object to clone.

Returns

object
The cloned object.
public static mixed
# nonInputVar( string $varname, mixed $default = null )

Checks to see if a value has been set by the script and not by GET, POST, or cookie input. The value being checked MUST be in the global scope.

Checks to see if a value has been set by the script and not by GET, POST, or cookie input. The value being checked MUST be in the global scope.

Parameters

$varname
The variable name to check.
$default
<p>Default value if the variable isn't present or was specified by the user. Defaults to null.</p>

Returns

mixed

$default if the var is in user input or not present, the variable value otherwise.

public static string
# formInput( boolean $append_session = 0 )

Returns a hidden form input containing the session name and id.

Returns a hidden form input containing the session name and id.

Parameters

$append_session
0 = only if needed, 1 = always.

Returns

string
The hidden form input, if needed/requested.
public static
# pformInput( boolean $append_session = 0 )

Prints a hidden form input containing the session name and id.

Prints a hidden form input containing the session name and id.

Parameters

$append_session
0 = only if needed, 1 = always.
public static mixed
# dispelMagicQuotes( mixed $var )

If magic_quotes_gpc is in use, run stripslashes() on $var.

If magic_quotes_gpc is in use, run stripslashes() on $var.

Parameters

$var
The string, or an array of strings, to un-quote.

Returns

mixed
$var, minus any magic quotes.
public static string
# getFormData( string $var, string $default = null )

Gets a form variable from GET or POST data, stripped of magic quotes if necessary. If the variable is somehow set in both the GET data and the POST data, the value from the POST data will be returned and the GET value will be ignored.

Gets a form variable from GET or POST data, stripped of magic quotes if necessary. If the variable is somehow set in both the GET data and the POST data, the value from the POST data will be returned and the GET value will be ignored.

Parameters

$var
The name of the form variable to look for.
$default
<p>The value to return if the variable is not there.</p>

Returns

string
The cleaned form variable, or $default.
public static string
# getGet( string $var, string $default = null )

Gets a form variable from GET data, stripped of magic quotes if necessary. This function will NOT return a POST variable.

Gets a form variable from GET data, stripped of magic quotes if necessary. This function will NOT return a POST variable.

Parameters

$var
The name of the form variable to look for.
$default
<p>The value to return if the variable is not there.</p>

Returns

string
The cleaned form variable, or $default.
public static string
# getPost( string $var, string $default = null )

Gets a form variable from POST data, stripped of magic quotes if necessary. This function will NOT return a GET variable.

Gets a form variable from POST data, stripped of magic quotes if necessary. This function will NOT return a GET variable.

Parameters

$var
The name of the form variable to look for.
$default
<p>The value to return if the variable is not there.</p>

Returns

string
The cleaned form variable, or $default.
public static string
# getTempDir( )

Determines the location of the system temporary directory.

Determines the location of the system temporary directory.

Returns

string

A directory name which can be used for temp files. Returns false if one could not be found.

public static string
# getTempFile( string $prefix = '', boolean $delete = true, string $dir = '', boolean $secure = false )

Creates a temporary filename for the lifetime of the script, and (optionally) registers it to be deleted at request shutdown.

Creates a temporary filename for the lifetime of the script, and (optionally) registers it to be deleted at request shutdown.

Parameters

$prefix
<p>Prefix to make the temporary name more recognizable.</p>
$delete
Delete the file at the end of the request?
$dir
Directory to create the temporary file in.
$secure
<p>If deleting the file, should we securely delete the file by overwriting it with random data?</p>

Returns

string

Returns the full path-name to the temporary file. Returns false if a temp file could not be created.

public static string
# getTempFileWithExtension( string $extension = '.tmp', string $prefix = '', boolean $delete = true, string $dir = '', boolean $secure = false )

Creates a temporary filename with a specific extension for the lifetime of the script, and (optionally) registers it to be deleted at request shutdown.

Creates a temporary filename with a specific extension for the lifetime of the script, and (optionally) registers it to be deleted at request shutdown.

Parameters

$extension
The file extension to use.
$prefix
<p>Prefix to make the temporary name more recognizable.</p>
$delete
Delete the file at the end of the request?
$dir
Directory to create the temporary file in.
$secure
<p>If deleting file, should we securely delete the file by overwriting it with random data?</p>

Returns

string

Returns the full path-name to the temporary file. Returns false if a temporary file could not be created.

public static string
# createTempDir( boolean $delete = true, string $temp_dir = null )

Creates a temporary directory in the system's temporary directory.

Creates a temporary directory in the system's temporary directory.

Parameters

$delete
<p>Delete the temporary directory at the end of the request?</p>
$temp_dir
<p>Use this temporary directory as the directory where the temporary directory will be created.</p>

Returns

string

The pathname to the new temporary directory. Returns false if directory not created.

public static array|boolean
# getCsv( resource $file, array $params = array() )

Wrapper around fgetcsv().

Wrapper around fgetcsv().

Empty lines will be skipped. If the 'length' parameter is provided, all rows are filled up with empty strings up to this length, or stripped down to this length.

Parameters

$file
A file pointer.
$params
<p>Optional parameters. Possible values: - 'separator': The field delimiter. - 'quote': The quote character. - 'escape': The escape character. - 'length': The expected number of fields.</p>

Returns

array|boolean

A row from the CSV file or false on error or end of file.

public static string
# realPath( string $path )

Returns the canonical path of the string. Like PHP's built-in realpath() except the directory need not exist on the local server.

Returns the canonical path of the string. Like PHP's built-in realpath() except the directory need not exist on the local server.

Algorithim loosely based on code from the Perl File::Spec::Unix module (version 1.5).

Parameters

$path
A file path.

Returns

string
The canonicalized file path.
public static
# deleteAtShutdown( string $filename, boolean $register = true, boolean $secure = false )

Removes given elements at request shutdown.

Removes given elements at request shutdown.

If called with a filename will delete that file at request shutdown; if called with a directory will remove that directory and all files in that directory at request shutdown.

If called with no arguments, return all elements to be deleted (this should only be done by Horde_Util::_deleteAtShutdown()).

The first time it is called, it initializes the array and registers Horde_Util::_deleteAtShutdown() as a shutdown function - no need to do so manually.

The second parameter allows the unregistering of previously registered elements.

Parameters

$filename
<p>The filename to be deleted at the end of the request.</p>
$register
<p>If true, then register the element for deletion, otherwise, unregister it.</p>
$secure
<p>If deleting file, should we securely delete the file?</p>
public static
# shutdown( )

Deletes registered files at request shutdown.

Deletes registered files at request shutdown.

This function should never be called manually; it is registered as a shutdown function by Horde_Util::deleteAtShutdown() and called automatically at the end of the request.

Contains code from gpg_functions.php. Copyright 2002-2003 Braverock Ventures

public static boolean
# extensionExists( string $ext )

Caches the result of extension_loaded() calls.

Caches the result of extension_loaded() calls.

Parameters

$ext
The extension name.

Returns

boolean
Is the extension loaded?
public static boolean
# loadExtension( string $ext )

Tries to load a PHP extension, behaving correctly for all operating systems.

Tries to load a PHP extension, behaving correctly for all operating systems.

Parameters

$ext
The extension to load.

Returns

boolean

True if the extension is now loaded, false if not. True can mean that the extension was already loaded, OR was loaded dynamically.

public static string
# getPathInfo( )

Utility function to obtain PATH_INFO information.

Utility function to obtain PATH_INFO information.

Returns

string
The PATH_INFO string.
Properties summary
public static array $patterns

A list of random patterns to use for overwriting purposes. See http://www.cs.auckland.ac.nz/~pgut001/pubs/secure_del.html. We save the random overwrites for efficiency reasons.

A list of random patterns to use for overwriting purposes. See http://www.cs.auckland.ac.nz/~pgut001/pubs/secure_del.html. We save the random overwrites for efficiency reasons.

# array( "\x55", "\xaa", "\x92\x49\x24", "\x49\x24\x92", "\x24\x92\x49", "\x00", "\x11", "\x22", "\x33", "\x44", "\x55", "\x66", "\x77", "\x88", "\x99", "\xaa", "\xbb", "\xcc", "\xdd", "\xee", "\xff", "\x92\x49\x24", "\x49\x24\x92", "\x24\x92\x49", "\x6d\xb6\xdb", "\xb6\xdb\x6d", "\xdb\x6d\xb6" )
public static array $tmpLocations

Temp directory locations.

Temp directory locations.

# array( '/tmp/', '/var/tmp/', 'c:\WUTemp\\', 'c:\temp\\', 'c:\windows\temp\\', 'c:\winnt\temp\\' )
API documentation generated by ApiGen