class Path

A Path handling class

Methods

static  boolean
canChmod( string $path)

Checks if a path's permissions can be changed.

static  boolean
setPermissions( string $path, string $filemode = '0644', string $foldermode = '0755')

Chmods files and directories recursively to given permissions.

static  string
getPermissions( string $path)

Get the permissions of the file/folder at a given path.

static  string
check( string $path)

Checks for snooping outside of the file system root.

static  string
clean( string $path, string $ds = DIRECTORY_SEPARATOR)

Function to strip additional / or \ in a path name.

static  boolean
isOwner( string $path)

Method to determine if script owns the path.

static  mixed
find( mixed $paths, string $file)

Searches the directory paths for a given file.

Details

static boolean canChmod( string $path)

Checks if a path's permissions can be changed.

Parameters

string $path Path to check.

Return Value

boolean True if path can have mode changed.

static boolean setPermissions( string $path, string $filemode = '0644', string $foldermode = '0755')

Chmods files and directories recursively to given permissions.

Parameters

string $path Root path to begin changing mode [without trailing slash].
string $filemode Octal representation of the value to change file mode to [null = no change].
string $foldermode Octal representation of the value to change folder mode to [null = no change].

Return Value

boolean True if successful [one fail means the whole operation failed].

static string getPermissions( string $path)

Get the permissions of the file/folder at a given path.

Parameters

string $path The path of a file/folder.

Return Value

string Filesystem permissions.

static string check( string $path)

Checks for snooping outside of the file system root.

Parameters

string $path A file system path to check.

Return Value

string A cleaned version of the path or exit on error.

Exceptions

Exception

static string clean( string $path, string $ds = DIRECTORY_SEPARATOR)

Function to strip additional / or \ in a path name.

Parameters

string $path The path to clean.
string $ds Directory separator (optional).

Return Value

string The cleaned path.

Exceptions

UnexpectedValueException

static boolean isOwner( string $path)

Method to determine if script owns the path.

Parameters

string $path Path to check ownership.

Return Value

boolean True if the php script owns the path passed.

static mixed find( mixed $paths, string $file)

Searches the directory paths for a given file.

Parameters

mixed $paths An path string or array of path strings to search in
string $file The file name to look for.

Return Value

mixed The full path and file name for the target file, or boolean false if the file is not found in any of the paths.