check_extension (line 278)
Check uploaded file extensions for possible malicious intent, and if some is found, an error is put out, and the hackattack logged.
boolean
check_extension
(string $name, [boolean $skip_server_side_security_check = false], [?string $file_to_delete = NULL], [boolean $accept_errors = false])
-
string
$name: The filename
-
boolean
$skip_server_side_security_check: Whether to skip the server side security check
-
?string
$file_to_delete: Delete this file if we have to exit (NULL: no file to delete)
-
boolean
$accept_errors: Whether to allow errors without dying
check_shared_bandwidth_usage (line 378)
Check bandwidth usage against page view ratio for shared hosting.
void
check_shared_bandwidth_usage
(integer $extra)
-
integer
$extra: The extra bandwidth requested
check_shared_space_usage (line 405)
Check disk space usage against page view ratio for shared hosting.
void
check_shared_space_usage
(integer $extra)
-
integer
$extra: The extra space in bytes requested
delete_upload (line 348)
Delete an uploaded file from disk, if it's URL has changed (i.e. it's been replaced, leaving a redundant disk file).
void
delete_upload
(string $upload_path, ID_TEXT $table, ID_TEXT $field, mixed $id_field, mixed $id, [?string $new_url = NULL])
-
string
$upload_path: The path to the upload directory
-
ID_TEXT
$table: The table name
-
ID_TEXT
$field: The table field name
-
mixed
$id_field: The table ID field name, or a map array
-
mixed
$id: The table ID
-
?string
$new_url: The new URL to use (NULL: deleting without replacing: no change check)
get_directory_contents (line 160)
Get the contents of a directory, recursively. It is assumed that the directory exists.
array
get_directory_contents
(PATH $path, [PATH $rel_path = ''], [boolean $special_too = false])
-
PATH
$path: The path to search
-
PATH
$rel_path: The path we prepend to everything we find (intended to be used inside the recursion)
-
boolean
$special_too: Whether to also get special files
get_directory_size (line 190)
Get the size in bytes of a directory. It is assumed that the directory exists.
integer
get_directory_size
(PATH $path)
-
PATH
$path: The path to search
get_max_file_size (line 235)
Get the maximum allowed upload filesize, as specified in the configuration
integer
get_max_file_size
([?MEMBER $source_member = NULL], [?object $connection = NULL])
-
?MEMBER
$source_member: Member we consider quota for (NULL: do not consider quota)
-
?object
$connection: Database connection to get quota from (NULL: site DB)
get_upload_limit_config_url (line 216)
Get the URL to the config option group for editing limits
?URLPATH
get_upload_limit_config_url
()
init__files2 (line 24)
Standard code module initialisation function.
void
init__files2
()
make_csv (line 105)
Output data to a CSV file.
string
make_csv
(array $data, [ID_TEXT $filename = 'data.csv'], [boolean $headers = true], [boolean $output_and_exit = true])
-
array
$data: List of maps, each map representing a row
-
ID_TEXT
$filename: Filename to output
-
boolean
$headers: Whether to output CSV headers
-
boolean
$output_and_exit: Whether to output/exit when we're done instead of return
_deldir_contents (line 67)
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
_http_download_file (line 449)
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.
?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)
_sync_file_move (line 43)
Provides a hook for file-move synchronisation between mirrored servers. Called after any rename or move action.
void
_sync_file_move
(PATH $old, PATH $new)
-
PATH
$old: File/directory name to move from (may be full or relative path)
-
PATH
$new: File/directory name to move to (may be full or relative path)