phpDocumentor GalleryCore
Classes
[ class tree: GalleryCore ] [ index: GalleryCore ] [ all elements ]

Class: GalleryPlatform

Source Location: /modules/core/classes/GalleryPlatform.class

Class GalleryPlatform

Direct descendents
Child Class Description
SizeLimitOptionTestPlatform Test platform
SetSizeOptionTestPlatform Test platform
SizeLimitHelperTestPlatform Test platform
RewriteHelperMockPlatform
ModRewriteHelperMockPlatform Test platform for this test
RewriteModuleMockPlatform Test platform for this test
RewriteParserMockPlatform
AdminRewriteMockPlatform Test platform for this test
IsapiRewriteHelperMockPlatform Test platform for this test
PathInfoHelperMockPlatform Test platform for this test
ItemAddFromServerTestPlatform Test platform
UnixPlatform An Unix version of the GalleryPlatform class
WinNtPlatform An WindowsNT based version of the GalleryPlatform class
EventTestPlatform Mock platform.
ModuleTestPlatform Test platform for this test
FileSystemTestPlatformForRename Mock platform for the rename method
ThemeTestPlatform Test platform for this test
ReuploadOptionTestPlatform Test platform
HttpAuthHelperTestPlatform
HttpAuthModuleTestPlatform
WebDavTestPlatform
WebDavModuleTestPlatform
WebDavHelperTestPlatform

[ Top ]
Property Summary
array   $_blacklistedFileExtensions   List of file extensions that are disallowed for server and/or client security reasons.

[ Top ]
Method Summary
boolean   atomicWrite()   Perform an atomic write to a file. This guarantees that the data written is not corrupted (but it does not prevent another process from immediately replacing the file with its own version).
boolean   chdir()   chdir -- change working directory.
boolean   chmod()   Set filesystem permissions; mode defaults to system preference for file/dir permissions.
void   clearstatcache()   Clear the stat cache.
void   closedir()   Close a directory resource.
boolean   copy()   Copy a file.
array(boolean   exec()   Execute a command and record the results and status.
boolean   fclose()   Closes an open file pointer.
boolean   feof()   Tests for end-of-file on a file pointer.
boolean   fflush()   Flush an open file pointer.
the   fgets()   Gets line from file pointer.
array   file()   Return a file as an array.
int   filesize()   How large is the given file?
boolean   file_exists()   Does the given file exist?
string   file_get_contents()   Reads the entire contents of the specified file into a string.
boolean   file_put_contents()   Writes specified data to file. Uses PHP's file_put_contents() function if it is available.
true   flock()   flock -- Portable advisory file locking.
resource   fopen()   Open a file or URL.
string   fread()   Reads data from an open file handle.
int   fseek()   Seeks on a file pointer.
resource   fsockopen()   Initiates a socket connection to the resource specified by target.
boolean   ftruncate()   Truncates a file to a given length.
int   fwrite()   Write the contents of string to the file stream pointed to by handle.
the   getcwd()   getcwd -- gets the current working directory.
string   getDirectorySeparator()   Return the filesystem specific directory separator.
array   getimagesize()   Get size information about an image.
string   getLegalPathCharacters()   Legal characters on all systems: A-Z a-z 0-9 # _ . -
string   getLineEnding()   Return the string of characters which represent the line ending on this platform.
array   glob()   The glob() function searches for all the pathnames matching pattern according to the rules used by the libc glob() function, which is similar to the rules used by common shells. No tilde expansion or parameter substitution is done.
true   isLegalPathComponent()   Return true if the path component specified is composed of legal characters.
true   isRestrictedByOpenBaseDir()   Return true if the path provided is not allowed by the current open_basedir configuration.
boolean   isSymlinkSupported()   Return a boolean specifying whether or not this platform can perform a symbolic link (symlink) command.
boolean   is_dir()   Is the given path a directory?
boolean   is_executable()   Is the given path an executable file?
boolean   is_file()   Is the given path a normal file?
boolean   is_link()   Is the given path a symbolic link?
boolean   is_readable()   Is the given path a readable file?
boolean   is_uploaded_file()   Is the given path an uploaded file?
boolean   is_writeable()   Is the given path a writeable file?
string   legalizePathComponent()   Remove any illegal characters from the path component.
boolean   mail()   mail -- Send an email. Lines in the headers and body should be terminated with \r\n in accordance with RFC2821.
boolean   mkdir()   Create a new directory.
string   move_uploaded_file()   Move an uploaded file to a new location and return the new location. If the second filename is not provided, a new file is created in the Gallery temporary directory.
resource   opendir()   Open a file or URL.
void   readdir()   Return the next file resource from a directory.
int   readfile()   Output a file.
false   realpath()   Expand all symbolic links and resolve references to '/./', '/../' and extra '/' characters in
boolean   recursiveChmod()   Recursively set filesystem permissions. Modes default to system preferences for file/dir permissions.
boolean   recursiveFixDirPermissions()   Fixes the directory permissions (as eg. unzip creates them with file permissions because of the umask).
boolean   recursiveRmdir()   Delete a directory, and all its contents.
boolean   rename()   Rename a file/dir.
void   resetPlatform()   Clear any cached saved state in this platform.
boolean   rmdir()   Delete a directory.
array   splitPath()   Split path into component elements. Include root path for absolute paths.
array   stat()   Get information about a file.
string   strftime()   Format a local time/date according to locale settings. Converts any text output from strftime tokens to UTF-8.
boolean   symlink()   Symlink a file.
void   tempnam()   Create a file with a unique file name.
void   touch()   touch -- Sets access and modification time of file.
boolean   unlink()   Delete a file.
void   _isRestrictedByOpenBaseDir()   Check if path is allowed by open_basedir, given platform path separator & case sensitivity.
void   _loadPermissionPreferences()   Load preferences for file/dir permissions and calculate umask.
void   _recursiveChmod()   Helper for recursiveChmod.

[ Top ]
Properties
array   $_blacklistedFileExtensions = array(
'php', 'php2', 'php3', 'php4', 'php5', 'php6', 'cgi', 'inc', 'phps', 'pwml', 'phtml',
'html', 'js', 'htm', 'shtml', 'vbs', 'dll', 'jsp' , 'cfm', 'reg', 'shtm', 'phtm', 'exe',
'bat', 'sh', 'cmd', 'install', 'pl', 'tcl', 'py', 'com', 'rb', 'asp', 'aspx', 'ascx')
[line 44]

List of file extensions that are disallowed for server and/or client security reasons.

API Tags:
Deprecated:  This list will be made configurable by merging it into the mime-map data.


[ Top ]
Methods
atomicWrite  [line 371]

  boolean atomicWrite( string $filename, string $data  )

Perform an atomic write to a file. This guarantees that the data written is not corrupted (but it does not prevent another process from immediately replacing the file with its own version).

Parameters:
string   $filename: 
string   $data:  data to be written

API Tags:
Return:  success or failure


[ Top ]
chdir  [line 1070]

  boolean chdir( string $path  )

chdir -- change working directory.

Parameters:
string   $path:  directory

API Tags:
Return:  true on success


[ Top ]
chmod  [line 1126]

  boolean chmod( string $path, [int $mode = null]  )

Set filesystem permissions; mode defaults to system preference for file/dir permissions.

Parameters:
string   $path:  path to file or directory
int   $mode:  (optional) mode; defaults to system preference

API Tags:
Return:  true on success


Redefined in descendants as:

[ Top ]
clearstatcache  [line 284]

  void clearstatcache( )

Clear the stat cache.



[ Top ]
closedir  [line 433]

  void closedir( resource $resource  )

Close a directory resource.

Parameters:
resource   $resource:  a directory resource


Redefined in descendants as:

[ Top ]
copy  [line 55]

  boolean copy( string $source, string $dest  )

Copy a file.

Parameters:
string   $source:  the source file
string   $dest:  the destination file

API Tags:
Return:  true if the copy succeeded, false otherwise


Redefined in descendants as:

[ Top ]
exec  [line 689]

  array(boolean exec( array $cmdArray  )

Execute a command and record the results and status.

Parameters:
array   $cmdArray:  array(array('cmd', 'arg'), ...)

API Tags:
Return:  true if the command succeeded, false otherwise, array standard output from the command array error output from the command)


Redefined in descendants as:

[ Top ]
fclose  [line 827]

  boolean fclose( resource $handle  )

Closes an open file pointer.

Parameters:
resource   $handle: 

API Tags:
Return:  true on success, false on failure


Redefined in descendants as:

[ Top ]
feof  [line 855]

  boolean feof( resource $handle  )

Tests for end-of-file on a file pointer.

Parameters:
resource   $handle: 

API Tags:
Return:  true if the file pointer is at EOF


Redefined in descendants as:

[ Top ]
fflush  [line 841]

  boolean fflush( resource $handle  )

Flush an open file pointer.

Parameters:
resource   $handle: 

API Tags:
Return:  true on success, false on failure


Redefined in descendants as:

[ Top ]
fgets  [line 924]

  the fgets( resource $handle, [int $length = 0]  )

Gets line from file pointer.

Parameters:
resource   $handle: 
int   $length:  the optional max line length

API Tags:
Return:  string or false on eof


Redefined in descendants as:

[ Top ]
file  [line 299]

  array file( string $filename, [int $use_include_path = false]  )

Return a file as an array.

Parameters:
string   $filename:  a file path or URL
int   $use_include_path:  if this is set to 1, search the include path also

API Tags:
Return:  of lines


Redefined in descendants as:

[ Top ]
filesize  [line 272]

  int filesize( string $filename  )

How large is the given file?

Parameters:
string   $filename:  full filesystem path to a file

API Tags:
Return:  the size in bytes


Redefined in descendants as:

[ Top ]
file_get_contents  [line 327]

  string file_get_contents( string $path  )

Reads the entire contents of the specified file into a string.

Parameters:
string   $path:  file path

API Tags:
Return:  file contents or boolean false on failure


[ Top ]
file_put_contents  [line 810]

  boolean file_put_contents( string $path, string $data  )

Writes specified data to file. Uses PHP's file_put_contents() function if it is available.

Parameters:
string   $path:  output file path
string   $data:  data to write

API Tags:
Return:  true on success, false on failure


[ Top ]
flock  [line 354]

  true flock( resource $handle, int $operation, &$wouldblock, boolean $wouldblock  )

flock -- Portable advisory file locking.

Parameters:
resource   $handle:  a file handle
int   $operation:  (LOCK_SH, LOCK_EX, LOCK_UN) [ | LOCK_NB]
boolean   $wouldblock:  set to true if the operation would have blocked
   &$wouldblock: 

API Tags:
Return:  or false


[ Top ]
fopen  [line 338]

  resource fopen( string $filename, string $mode, [int $use_include_path = 0]  )

Open a file or URL.

Parameters:
string   $filename:  a file path or URL
string   $mode:  a file mode
int   $use_include_path:  if this is set to 1, search the include path also

API Tags:
Return:  a file descriptor


Redefined in descendants as:

[ Top ]
fread  [line 870]

  string fread( resource $handle, int $length  )

Reads data from an open file handle.

Parameters:
resource   $handle: 
int   $length: 

API Tags:
Return:  the bytes read


Redefined in descendants as:

[ Top ]
fseek  [line 886]

  int fseek( resource $handle, int $offset, [int $whence = SEEK_SET]  )

Seeks on a file pointer.

Parameters:
resource   $handle: 
int   $offset: 
int   $whence: 

API Tags:
Return:  0 upon success, otherwise -1


[ Top ]
fsockopen  [line 775]

  resource fsockopen( string $target, int $port, &$errno, &$errstr, int $timeout, int $errno, string $errstr  )

Initiates a socket connection to the resource specified by target.

Parameters:
string   $target:  the hostname
int   $port:  the port
int   $errno:  the error number (out)
string   $errstr:  the error string (out)
int   $timeout:  the timeout
   &$errno: 
   &$errstr: 

API Tags:
Return:  a file descriptor
See:  http://php.net/fsockopen


Redefined in descendants as:

[ Top ]
ftruncate  [line 901]

  boolean ftruncate( resource $handle, int $size  )

Truncates a file to a given length.

Parameters:
resource   $handle: 
int   $size: 

API Tags:
Return:  success?


[ Top ]
fwrite  [line 791]

  int fwrite( resource $handle, string $string, [int $length = null]  )

Write the contents of string to the file stream pointed to by handle.

Parameters:
resource   $handle:  the handle
string   $string:  the buffer
int   $length:  how many bytes to write (optional)

API Tags:
Return:  the number of bytes written


Redefined in descendants as:

[ Top ]
getcwd  [line 1082]

  the getcwd( )

getcwd -- gets the current working directory.


API Tags:
Return:  current working directory, or false on failure.


Redefined in descendants as:

[ Top ]
getimagesize  [line 485]

  array getimagesize( string $filename  )

Get size information about an image.

Parameters:
string   $filename:  the image file name

API Tags:
Return:  with 4 elements. Index 0 contains the width of the image in pixels. Index 1 contains the height. Index 2 is a flag indicating the type of the image: 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF. These values correspond to the IMAGETYPE constants that were added in PHP 4.3. Index 3 is a text string with the correct height="yyy" width="xxx" string that can be used directly in an IMG tag.


Redefined in descendants as:

[ Top ]
getLegalPathCharacters  [line 612]

  string getLegalPathCharacters( )

Legal characters on all systems: A-Z a-z 0-9 # _ . -

Specific platform implementations can override this.


API Tags:
Return:  a string composed of all legal path characters


[ Top ]
getLineEnding  [line 1060]

  string getLineEnding( )

Return the string of characters which represent the line ending on this platform.


API Tags:
Return:  Line ending


Redefined in descendants as:

[ Top ]
glob  [line 1271]

  array glob( mixed $pattern, [mixed $flags = null]  )

The glob() function searches for all the pathnames matching pattern according to the rules used by the libc glob() function, which is similar to the rules used by common shells. No tilde expansion or parameter substitution is done.


API Tags:
Return:  containing the matched files/directories or FALSE on error.


[ Top ]
isLegalPathComponent  [line 601]

  true isLegalPathComponent( string $component, [boolean $forDirectory = false]  )

Return true if the path component specified is composed of legal characters.

Parameters:
string   $component:  the path component (must not contain path separators)
boolean   $forDirectory:  (optional) Whether the path component is for a directory. Defaults to false. Periods are allowed anywhere in directories.

API Tags:
Return:  if yes


[ Top ]
isRestrictedByOpenBaseDir  [line 706]

  true isRestrictedByOpenBaseDir( $path  )

Return true if the path provided is not allowed by the current open_basedir configuration.

Parameters:
   $path: 

API Tags:
Return:  if the path is restricted


Redefined in descendants as:

[ Top ]
isSymlinkSupported  [line 1051]

  boolean isSymlinkSupported( )

Return a boolean specifying whether or not this platform can perform a symbolic link (symlink) command.


API Tags:
Return:  true if the platform supports symlinks


Redefined in descendants as:

[ Top ]
is_dir  [line 188]

  boolean is_dir( string $filename  )

Is the given path a directory?

Parameters:
string   $filename:  a filesystem path

API Tags:
Return:  true if the path is a directory, false otherwise


Redefined in descendants as:

[ Top ]
is_executable  [line 258]

  boolean is_executable( string $filename  )

Is the given path an executable file?

Parameters:
string   $filename:  a filesystem path

API Tags:
Return:  true if the path is an executable file, false otherwise


Redefined in descendants as:

[ Top ]
is_file  [line 202]

  boolean is_file( string $filename  )

Is the given path a normal file?

Parameters:
string   $filename:  a filesystem path

API Tags:
Return:  true if the path is a file, false otherwise


Redefined in descendants as:

[ Top ]
is_link  [line 174]

  boolean is_link( string $filename  )

Is the given path a symbolic link?

Parameters:
string   $filename:  a filesystem path

API Tags:
Return:  true if the file is a link, false otherwise


[ Top ]
is_readable  [line 230]

  boolean is_readable( string $filename  )

Is the given path a readable file?

Parameters:
string   $filename:  a filesystem path

API Tags:
Return:  true if the path is readable, false otherwise


Redefined in descendants as:

[ Top ]
is_uploaded_file  [line 244]

  boolean is_uploaded_file( string $filename  )

Is the given path an uploaded file?

Parameters:
string   $filename:  a filesystem path

API Tags:
Return:  true if the path is an uploaded file, false otherwise


Redefined in descendants as:

[ Top ]
is_writeable  [line 216]

  boolean is_writeable( string $filename  )

Is the given path a writeable file?

Parameters:
string   $filename:  a filesystem path

API Tags:
Return:  true if the path is writeable, false otherwise


Redefined in descendants as:

[ Top ]
legalizePathComponent  [line 627]

  string legalizePathComponent( string $component, [boolean $forDirectory = false]  )

Remove any illegal characters from the path component.

Parameters:
string   $component:  the path component (must not contain path separators)
boolean   $forDirectory:  (optional) Whether the path component is for a directory. Defaults to false. Periods are allowed anywhere in directories.

API Tags:
Return:  the legalized path component


[ Top ]
mail  [line 990]

  boolean mail( string $to, string $subject, string $body, [string $headers = null]  )

mail -- Send an email. Lines in the headers and body should be terminated with \r\n in accordance with RFC2821.

Parameters:
string   $to:  to address(es) (comma separated)
string   $subject: 
string   $body: 
string   $headers:  (optional) additional headers (\r\n separated)

API Tags:
Return:  true on success


Redefined in descendants as:

[ Top ]
mkdir  [line 572]

  boolean mkdir( string $path, [string $stringPerms = null]  )

Create a new directory.

Parameters:
string   $path:  a filesystem path
string   $stringPerms:  permissions of the newly created directory

API Tags:
Return:  true on success, false on failure


[ Top ]
move_uploaded_file  [line 106]

  string move_uploaded_file( $filename, [ $newFilename = null]  )

Move an uploaded file to a new location and return the new location. If the second filename is not provided, a new file is created in the Gallery temporary directory.

Parameters:
   $filename: 
   $newFilename: 

API Tags:
Return:  the new file name, if the move was successful


[ Top ]
opendir  [line 407]

  resource opendir( string $path  )

Open a file or URL.

Parameters:
string   $path:  a file path

API Tags:
Return:  a directory descriptor


Redefined in descendants as:

[ Top ]
readdir  [line 420]

  void readdir( resource $resource  )

Return the next file resource from a directory.

Parameters:
resource   $resource:  a directory resource


Redefined in descendants as:

[ Top ]
readfile  [line 314]

  int readfile( string $filename, [int $use_include_path = false]  )

Output a file.

Parameters:
string   $filename:  a file path or URL
int   $use_include_path:  if this is set to 1, search the include path also

API Tags:
Return:  the number of bytes read from the file


[ Top ]
realpath  [line 939]

  false realpath( $file  )

Expand all symbolic links and resolve references to '/./', '/../' and extra '/' characters in

the input path and return the canonicalized absolute pathname. The resulting path will have no symbolic link, '/./' or '/../' components. [cribbed from http://php.net/realpath]

Parameters:
   $file: 

API Tags:
Return:  on failure, eg. if the file does not exists


Redefined in descendants as:

[ Top ]
recursiveChmod  [line 1149]

  boolean recursiveChmod( string $path, [int $dirMode = null], [int $fileMode = null]  )

Recursively set filesystem permissions. Modes default to system preferences for file/dir permissions.

Parameters:
string   $path:  path to directory
int   $dirMode:  (optional) mode for dirs or -1 to skip chmod of dirs
int   $fileMode:  (optional) mode for files or -1 to skip chmod of files

API Tags:
Return:  true on success


[ Top ]
recursiveFixDirPermissions  [line 1205]

  boolean recursiveFixDirPermissions( string $path  )

Fixes the directory permissions (as eg. unzip creates them with file permissions because of the umask).

Parameters:
string   $path:  $path the directory which should be fixed

API Tags:
Return:  true if all went well, false if there was an error.
Deprecated:  -- TODO: remove at the next major version bump of core API


[ Top ]
recursiveRmdir  [line 531]

  boolean recursiveRmdir( string $dirname  )

Delete a directory, and all its contents.

Parameters:
string   $dirname:  directory name

API Tags:
Return:  true on success, false on failure


Redefined in descendants as:

[ Top ]
rename  [line 451]

  boolean rename( string $oldname, string $newname  )

Rename a file/dir.

As a side bonus, create a backup of the original file.

Parameters:
string   $oldname:  original file/dir name
string   $newname:  new file/dir name

API Tags:
Return:  true on success, false on failure


Redefined in descendants as:

[ Top ]
resetPlatform  [line 1287]

  void resetPlatform( )

Clear any cached saved state in this platform.



[ Top ]
rmdir  [line 517]

  boolean rmdir( string $filename  )

Delete a directory.

Parameters:
string   $filename:  directory name

API Tags:
Return:  true on success, false on failure


[ Top ]
splitPath  [line 1040]

  array splitPath( string $path  )

Split path into component elements. Include root path for absolute paths.

eg. /tmp -> array('/', 'tmp') rela/tive/path -> array('rela', 'tive', 'path') C:\Test\File.txt -> array('C:\', 'Test', 'File.txt')

Parameters:
string   $path: 

API Tags:
Return:  (path elements) first item is "root" if path is absolute


Redefined in descendants as:

[ Top ]
stat  [line 465]

  array stat( string $filename  )

Get information about a file.

Parameters:
string   $filename:  file/dir name

API Tags:
Return:  the statistics of the file


[ Top ]
strftime  [line 1238]

  string strftime( string $format, [int $timestamp = null]  )

Format a local time/date according to locale settings. Converts any text output from strftime tokens to UTF-8.

Parameters:
string   $format: 
int   $timestamp:  (optional)


Redefined in descendants as:

[ Top ]
symlink  [line 85]

  boolean symlink( string $source, string $dest  )

Symlink a file.

Parameters:
string   $source:  the source file
string   $dest:  the destination file

API Tags:
Return:  true if the copy succeeded, false otherwise


Redefined in descendants as:

[ Top ]
tempnam  [line 135]

  void tempnam( string $dir, string $prefix  )

Create a file with a unique file name.

Parameters:
string   $dir:  target dir
string   $prefix:  file prefix


Redefined in descendants as:

[ Top ]
touch  [line 961]

  void touch( string $file, [int $time = null], [int $atime = null]  )

touch -- Sets access and modification time of file.

Attempts to set the access and modification time of the file named by filename to the value given by time. If the option time is not given, uses the present time. This is equivalent to what utime (sometimes referred to as utimes) does. If the third option atime is present, the access time of the given filename is set to the value of atime. Note that the access time is always modified, regardless of the number of parameters.

Parameters:
string   $file:  the file path
int   $time:  (optional) the modification time
int   $atime:  (optional) the access time


[ Top ]
unlink  [line 503]

  boolean unlink( string $filename  )

Delete a file.

Parameters:
string   $filename: 

API Tags:
Return:  true on success, false on failure


Redefined in descendants as:

[ Top ]
_isRestrictedByOpenBaseDir  [line 719]

  void _isRestrictedByOpenBaseDir( $path, $separator, $caseSensitive  )

Check if path is allowed by open_basedir, given platform path separator & case sensitivity.

Parameters:
   $path: 
   $separator: 
   $caseSensitive: 

API Tags:
Access:  protected


[ Top ]
_loadPermissionPreferences  [line 1094]

  void _loadPermissionPreferences( )

Load preferences for file/dir permissions and calculate umask.


API Tags:
Access:  private


[ Top ]
_recursiveChmod  [line 1171]

  void _recursiveChmod( $path, $dirMode, $fileMode  )

Helper for recursiveChmod.

Parameters:
   $path: 
   $dirMode: 
   $fileMode: 

API Tags:
Access:  private


[ Top ]

Documentation generated on Fri, 08 Oct 2010 05:02:10 -0700 by phpDocumentor 1.3.0RC6