Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

(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.

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

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

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

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.

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

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.

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

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.

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

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.

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

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.

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
return: string   Returns the full path-name to the temporary file.

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.

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
return: string   Returns the full path-name to the temporary file.

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

param: boolean $delete   Delete the temporary directory at the end of
param: string $temp_dir  Use this temporary directory as the directory
return: string  The pathname to the new temporary 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).

param: string $path  A file path.
return: string  The canonicalized 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.

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

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

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

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

return: string  The PATH_INFO string.