/sources/files.php

Description
Functions
better_parse_ini_file (line 99)

Parse the specified INI file, and get an array of what it found.

  • return: A map of the contents of the ini files
array better_parse_ini_file (?PATH $filename, [?string $file = NULL])
  • ?PATH $filename: The path to the ini file to open (NULL: given contents in $file instead)
  • ?string $file: The contents of the file (NULL: the file needs opening)
clean_file_size (line 67)

Format the specified filesize.

  • return: The formatted-string file size
string clean_file_size (integer $bytes)
  • integer $bytes: The number of bytes the file has
deldir_contents (line 149)

Delete all the contents of a directory, and any subdirectories of that specified directory (recursively).

void deldir_contents (PATH $dir, [boolean $default_preserve = false])
  • PATH $dir: The pathname to the directory to delete
  • boolean $default_preserve: Whether to preserve files there by default
fix_permissions (line 161)

Ensure that the specified file/folder is writeable for the FTP user (so that it can be deleted by the system), and should be called whenever a file is uploaded/created, or a folder is made. We call this function assuming we are giving world permissions

void fix_permissions (PATH $path, [integer $perms = 0666])
  • PATH $path: The full pathname to the file/directory
  • integer $perms: The permissions to make (not the permissions are reduced if the function finds that the file is owned by the web user [doesn't need world permissions then])
get_file_extension (line 85)

Get the file extension of the specified file. It returns without a dot.

  • return: The filename extension (no dot)
string get_file_extension (string $name)
  • string $name: The filename
get_file_size (line 47)

Get a formatted-string filesize for the specified file. It is formatted as such: x Mb/Kb/Bytes (or unknown). It is assumed that the file exists.

  • return: The formatted-string file size
string get_file_size (URLPATH $url)
  • URLPATH $url: The URL that the file size of is being worked out for. Should be local.
http_download_file (line 202)

Return the file in the URL by downloading it over HTTP. If a byte limit is given, it will only download that many bytes. It outputs warnings, returning NULL, on error.

  • return: The data downloaded (NULL: error)
?string http_download_file (URLPATH $url, [?integer $byte_limit = NULL], [boolean $trigger_error = true], [boolean $no_redirect = false], [string $ua = 'ocPortal'], [?array $post_params = NULL], [?array $cookies = NULL], [?string $accept = NULL], [?string $accept_charset = NULL], [?string $accept_language = NULL], [?resource $write_to_file = NULL], [?string $referer = NULL], [?array $auth = NULL], [float $timeout = 6.0], [boolean $is_xml = false], [?array $files = NULL])
  • URLPATH $url: The URL to download
  • ?integer $byte_limit: The number of bytes to download. This is not a guarantee, it is a minimum (NULL: all bytes)
  • boolean $trigger_error: Whether to throw an ocPortal error, on error
  • boolean $no_redirect: Whether to block redirects (returns NULL when found)
  • string $ua: The user-agent to identify as
  • ?array $post_params: An optional array of POST parameters to send; if this is NULL, a GET request is used (NULL: none)
  • ?array $cookies: An optional array of cookies to send (NULL: none)
  • ?string $accept: 'accept' header value (NULL: don't pass one)
  • ?string $accept_charset: 'accept-charset' header value (NULL: don't pass one)
  • ?string $accept_language: 'accept-language' header value (NULL: don't pass one)
  • ?resource $write_to_file: File handle to write to (NULL: do not do that)
  • ?string $referer: The HTTP referer (NULL: none)
  • ?array $auth: A pair: authentication username and password (NULL: none)
  • float $timeout: The timeout
  • boolean $is_xml: Whether to treat the POST parameters as a raw POST (rather than using MIME)
  • ?array $files: Files to send. Map between field to file path (NULL: none)
init__files (line 24)

Standard code module initialisation function.

void init__files ()
is_special_file (line 138)

Find whether a file should be ignored.

  • return: Whether it should be ignored
boolean is_special_file (string $file, [boolean $include_controls = false])
  • string $file: Filename
  • boolean $include_controls: Whether to include special ocPortal control files, index.html and .htaccess (which normally are skipped)
is_suexec_like (line 35)

Find whether we can get away with natural file access, not messing with AFMs, world-writability, etc.

  • return: Whether we have this
boolean is_suexec_like ()

Documentation generated on Sun, 02 Jan 2011 23:14:33 +0000 by phpDocumentor 1.4.3