Tuskfish API V1.1.2
  • Package
  • Class

Packages

  • content
  • core
  • database
  • installation
  • security
  • user
  • utilities

Classes

  • TfCache
  • TfFileHandler
  • TfLogger
  • TfMetadata
  • TfPaginationControl
  • TfPreference
  • TfPreferenceHandler
  • TfTemplate
  • TfTree

Traits

  • TfLanguage
  • TfMagicMethods
  • TfMimetypes
  • TfRights

Functions

  • checkPasswordStrength
  • hashPassword
  • tf_autoload
  • tfContentModuleAutoload

Class TfFileHandler

Provides methods for handling common file operations.

In some cases, sensitive operations are restricted to a particular directory (for example, file uploads).

TfFileHandler uses TfMimetypes
Package: core
Copyright: Simon Wilkinson 2013+ (https://tuskfish.biz)
License: GNU General Public License (GPL) V2
Author: Simon Wilkinson simon@isengard.biz
Version: Release: 1.0
Since: 1.0
Uses: trait TfMimetypes Access a list of known / acceptable file mimetypes.
Var: TfValidator $validator Instance of the Tuskfish data validator class.
Located at trust_path/libraries/tuskfish/class/TfFileHandler.php

Methods summary

public
# __construct( TfValidator $validator )

Constructor.

Constructor.

Parameters

$validator
An instance of the Tuskfish data validator class.
public boolean
# appendToFile( string $filepath, string $contents )

Append a string to a file.

Append a string to a file.

Do not set the $filepath using untrusted data sources, such as user input.

Parameters

$filepath
Path to the target file.
$contents
Content to append to the target file.

Returns

boolean
True on success false on failure.
public boolean
# clearDirectory( string $filepath )

Deletes the contents of a specific directory, subdirectories are unaffected.

Deletes the contents of a specific directory, subdirectories are unaffected.

Do not set the $filepath using untrusted data sources, such as user input.

Parameters

$filepath
Path to the target directory.

Returns

boolean
True on success false on failure.
public boolean
# deleteDirectory( string $filepath )

Destroys a directory and all contents recursively relative to the data_file directory.

Destroys a directory and all contents recursively relative to the data_file directory.

Do not set the $filepath using untrusted data sources, such as user input.

Parameters

$filepath
Path relative to data_file directory.

Returns

boolean
True on success, false on failure.
public boolean
# deleteFile( string $filepath )

Destroys an individual file in the data_file directory.

Destroys an individual file in the data_file directory.

Do not set the $filepath using untrusted data sources, such as user input.

Parameters

$filepath
Path relative to the data_file directory.

Returns

boolean
True on success, false on failure.
public string|boolean
# uploadFile( string $filename, string $fieldname )

Upload a file to the uploads/image or uploads/media directory and set permissions to 644.

Upload a file to the uploads/image or uploads/media directory and set permissions to 644.

Parameters

$filename
Filename.
$fieldname
Name of form field associated with this upload ('image' or 'media').

Returns

string|boolean
Filename on success, false on failure.

Methods used from TfMimetypes

getListOfPermittedUploadMimetypes()

Properties summary

protected $validator
#
Tuskfish API V1.1.2 API documentation generated by ApiGen