Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 39 and 400]

(no description)

File Size: 577 lines (19 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Horde_Util:: (17 methods):
  nonInputVar()
  formInput()
  pformInput()
  dispelMagicQuotes()
  getFormData()
  getGet()
  getPost()
  getTempFile()
  getTempFileWithExtension()
  createTempDir()
  realPath()
  deleteAtShutdown()
  shutdown()
  _secureDelete()
  extensionExists()
  loadExtension()
  getPathInfo()


Class: Horde_Util  - X-Ref

The Horde_Util:: class provides generally useful methods.

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

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

nonInputVar($varname, $default = null)   X-Ref
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.

return: mixed  $default if the var is in user input or not present,
param: string $varname  The variable name to check.
param: mixed $default   Default value if the variable isn't present

formInput($append_session = 0)   X-Ref
Returns a hidden form input containing the session name and id.

return: string  The hidden form input, if needed/requested.
param: boolean $append_session  0 = only if needed, 1 = always.

pformInput($append_session = 0)   X-Ref
Prints a hidden form input containing the session name and id.

param: boolean $append_session  0 = only if needed, 1 = always.

dispelMagicQuotes($var)   X-Ref
If magic_quotes_gpc is in use, run stripslashes() on $var.

return: mixed  $var, minus any magic quotes.
param: mixed $var  The string, or an array of strings, to un-quote.

getFormData($var, $default = null)   X-Ref
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.

return: string  The cleaned form variable, or $default.
param: string $var      The name of the form variable to look for.
param: string $default  The value to return if the variable is not

getGet($var, $default = null)   X-Ref
Gets a form variable from GET data, stripped of magic quotes if
necessary. This function will NOT return a POST variable.

return: string  The cleaned form variable, or $default.
param: string $var      The name of the form variable to look for.
param: string $default  The value to return if the variable is not

getPost($var, $default = null)   X-Ref
Gets a form variable from POST data, stripped of magic quotes if
necessary. This function will NOT return a GET variable.

return: string  The cleaned form variable, or $default.
param: string $var      The name of the form variable to look for.
param: string $default  The value to return if the variable is not

getTempFile($prefix = '', $delete = true, $dir = '',$secure = false)   X-Ref
Creates a temporary filename for the lifetime of the script, and
(optionally) registers it to be deleted at request shutdown.

return: string   Returns the full path-name to the temporary file.
param: string $prefix   Prefix to make the temporary name more
param: boolean $delete  Delete the file at the end of the request?
param: string $dir      Directory to create the temporary file in.
param: boolean $secure  If deleting the file, should we securely delete

getTempFileWithExtension($extension = '.tmp',$prefix = '',$delete = true, $dir = '',$secure = false)   X-Ref
Creates a temporary filename with a specific extension for the lifetime
of the script, and (optionally) registers it to be deleted at request
shutdown.

return: string   Returns the full path-name to the temporary file.
param: string $extension  The file extension to use.
param: string $prefix     Prefix to make the temporary name more
param: boolean $delete    Delete the file at the end of the request?
param: string $dir        Directory to create the temporary file in.
param: boolean $secure    If deleting file, should we securely delete

createTempDir($delete = true, $temp_dir = null)   X-Ref
Creates a temporary directory in the system's temporary directory.

return: string  The pathname to the new temporary directory.
param: boolean $delete   Delete the temporary directory at the end of
param: string $temp_dir  Use this temporary directory as the directory

realPath($path)   X-Ref
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).

return: string  The canonicalized file path.
param: string $path  A file path.

deleteAtShutdown($filename, $register = true,$secure = false)   X-Ref
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.

param: string $filename   The filename to be deleted at the end of the
param: boolean $register  If true, then register the element for
param: boolean $secure    If deleting file, should we securely delete

shutdown()   X-Ref
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

_secureDelete($file)   X-Ref
Securely delete the file by overwriting the data with a random
string.

param: string $file  Filename.

extensionExists($ext)   X-Ref
Caches the result of extension_loaded() calls.

return: boolean  Is the extension loaded?
param: string $ext  The extension name.

loadExtension($ext)   X-Ref
Tries to load a PHP extension, behaving correctly for all operating
systems.

return: boolean  True if the extension is now loaded, false if not.
param: string $ext  The extension to load.

getPathInfo()   X-Ref
Utility function to obtain PATH_INFO information.

return: string  The PATH_INFO string.