PHPDevShell 3.1.3-Stable
PHP OOP RAD Development Framework
fileManager Class Reference
Inheritance diagram for fileManager:
PHPDS_dependant

Public Member Functions

 safeFileName ($filename, $replace= '_')
 getFileExtension ($filename)
 getFileBase ($filename)
 iconType ($extension_lookup)
 deleteFilename ($filename=false)
 createDateDirectory ($directory= '', $cmod= '0777', $custom_dir=false)
 writeFile ($filename, $data, $directory=false, $safename=true)
 uploadFile ($uploaded_filename, $directory, $new_filename)
 renameUniqueFilename ($filename, $extension=false)
 autoUpload ($input_name, $file_overwrite_id=false, $file_description= '', $file_explained= '')
 displayFilesize ($filesize)
 deleteFiles ($file_id=0, $alias= '', $sub_id=0, $menu_id=0)
 countFiles ($alias= '', $sub_id=0, $menu_id=0)
 loadFiles ($file_id=0, $alias= '', $sub_id=0, $menu_id=0, $order= 'file_id DESC', $limit= '0, 5')
 returnImageCopies ($file, $nr=0, $directory='')
 downloadFile ($url, $copy_to)
 zipExtract ($file, $extractPath)
 smartCopy ($source, $dest, $options=array('folder_permission'=> 0755, 'file_permission'=> 0644))
 deleteDir ($dirname)
 establishFtp ($username='config', $password='config', $host='config', $port='config', $ssl='config', $timeout='config', $chdir='config')
 ftpRcopy ($conn_id, $src_dir, $dst_dir)
 getDirListing ($path= '.', $level=0)

Data Fields

 $logUploads = 'default'
 $defaultUploadDirectory = 'default'
 $cmod = 'default'
 $maxFilesize = 'default'
 $maxImagesize = 'default'
 $maxFileCount = 0
 $allowedExt = 'default'
 $doCreateThumb = 'default'
 $imageQuality = 'default'
 $thumbnailType = 'default'
 $resizeAdaptiveDimension = 'default'
 $resizeThumbDimension = 'default'
 $resizeThumbPercent = 'default'
 $cropThumbFromcenter = 'default'
 $cropThumbDimension = 'default'
 $doThumbReflect = 'default'
 $thumbReflectSettings = 'default'
 $doCreateResizeImage = 'default'
 $resizeImageDimension = 'default'
 $alias
 $menuId
 $subId
 $groupId
 $convertPdf = false
 $convertDensity = '300'
 $graphicsEngine = 'gd'
 $imageCopies = array()
 $uploadHistory = array()
 $d = 'core.lang'
 $setting

Detailed Description

This class handles file uploads in its simplest form.


Member Function Documentation

autoUpload ( input_name,
file_overwrite_id = false,
file_description = '',
file_explained = '' 
)

Simplifies the whole process of uploading files with type=file.

Parameters:
string$input_nameThe name of the <form type="file" name="???">
string$file_overwrite_idThe id of the log that needs to be overwritten.
string$file_descriptiona Simple file description for uploaded item.
string$file_explainedExplaining in text what this uploaded file is about.
Returns:
string Will return the complete uploaded directory with its filename.
countFiles ( alias = '',
sub_id = 0,
menu_id = 0 
)

Count uploaded files from the log database.

Parameters:
string$aliasLoad only files by this alias.
integer$sub_idLoad only files by this sub_id.
integer$menu_idLoad only files by this menu_id.
Returns:
int
createDateDirectory ( directory = '',
cmod = '0777',
custom_dir = false 
)

Creates directory according to month and year.

Parameters:
string$directoryWritable directory where new directories will be created and files stored.
integer$cmodExample: 0777
boolean$custome_dir
deleteDir ( dirname)

Will delete a whole directory recursively (directory muste be writable).

Parameters:
$dirnameDirectory to delete.
Returns:
boolean.
deleteFilename ( filename = false)

Deletes a filename.

Parameters:
string$filename
deleteFiles ( file_id = 0,
alias = '',
sub_id = 0,
menu_id = 0 
)

Delete file logs from database.

Parameters:
integer$file_idGet only a single file with a file_id.
string$aliasLoad only files by this alias.
integer$sub_idLoad only files by this sub_id.
integer$menu_idLoad only files by this menu_id.
Returns:
boolean Will return true if deleted.
displayFilesize ( filesize)

Convert numeric into file size.

Parameters:
numeric$filesize
Returns:
string
Author:
info@levaravel.com
downloadFile ( url,
copy_to 
)

Enables the caller to download a file to a local writable directory.

Parameters:
$urlThe url to download from
$copy_toThe location to copy to add the name to the file too, example: /var/www/test.zip
Returns:
mixed
establishFtp ( username = 'config',
password = 'config',
host = 'config',
port = 'config',
ssl = 'config',
timeout = 'config',
chdir = 'config' 
)

Connects to a normal ftp or secure server. If values left empty system will use PHPDevShell configuration values.

Parameters:
$username
$password
$host
$port
$ssl
$timeout
$chdir
Returns:
resource connection id.
ftpRcopy ( conn_id,
src_dir,
dst_dir 
)

The following is a fully tested function (based on a previous note) that recursively puts files from a source directory to a destination directory. See http://rufy.com/tech/archives/000026.html for more information.

NOTE: Use full path name for the destination directory and the destination directory must already exist

Parameters:
resource$conn_id
string$src_dir
string$dst_dir
Returns:
void
getDirListing ( path = '.',
level = 0 
)

Lists a directories sub directories. Skips files.

Parameters:
stringThe absolute path to check. $path
intHow deep scanning should occur.
Returns:
array
getFileBase ( filename)

Get filename without extension.

Parameters:
string$filename
Returns:
string
getFileExtension ( filename)

Get a files extension.

Parameters:
string$filename
Returns:
string
iconType ( extension_lookup)

Takes a filename and checks what icon needs to go with it.

Author:
Adriaan Schoeman, Jason Schoeman
Parameters:
string$extension_lookup
loadFiles ( file_id = 0,
alias = '',
sub_id = 0,
menu_id = 0,
order = 'file_id DESC',
limit = '0,
5'   
)

Load uploaded files from the log database.

Parameters:
integer$file_idGet only a single file with a file_id.
string$aliasLoad only files by this alias.
integer$sub_idLoad only files by this sub_id.
integer$menu_idLoad only files by this menu_id.
string$orderWhat the query should be ordered by. allows you to order by any of these column values : file_id, sub_id, menu_id, alias, original_filename, new_filename, relative_path, thumbnail, resized, extention, mime_type, file_desc, group_id, user_id, date_stored
string$limithow many files should be returned in the array.
Returns:
array
renameUniqueFilename ( filename,
extension = false 
)

Creates unique and safe filename.

returnImageCopies ( file,
nr = 0,
directory = '' 
)

Check if multiple images exists converted from a pdf with multiple pages.

Parameters:
string$file
int$nrThe current file number in the loop.
stringAdd directy if you wish for only file to be returned.
safeFileName ( filename,
replace = '_' 
)

This method simply renames the file to unix standards.

Parameters:
string$filename
string$replaceReplace odd characters with what?
smartCopy ( source,
dest,
options = array('folder_permission' => 0755, 'file_permission' => 0644) 
)

Copy file or folder from source to destination, it can do recursive copy as well and is very smart It recursively creates the dest file or directory path if there weren't exists Situtaions :

  • Src:/home/test/file.txt ,Dst:/home/test/b ,Result:/home/test/b -> If source was file copy file.txt name with b as name to destination
  • Src:/home/test/file.txt ,Dst:/home/test/b/ ,Result:/home/test/b/file.txt -> If source was file Creates b directory if does not exsits and copy file.txt into it
  • Src:/home/test ,Dst:/home/ ,Result:/home/test/** -> If source was directory copy test directory and all of its content into dest
  • Src:/home/test/ ,Dst:/home/ ,Result:/home/**-> if source was direcotry copy its content to dest
  • Src:/home/test ,Dst:/home/test2 ,Result:/home/test2/** -> if source was directoy copy it and its content to dest with test2 as name
  • Src:/home/test/ ,Dst:/home/test2 ,Result:->/home/test2/** if source was directoy copy it and its content to dest with test2 as name
    Todo:
    - Should have rollback technique so it can undo the copy when it wasn't successful
  • Auto destination technique should be possible to turn off
  • Supporting callback function
  • May prevent some issues on shared enviroments : http://us3.php.net/umask
    Parameters:
    $source//file or folder
    $dest///file or folder
    $options//folderPermission,filePermission
    Returns:
    boolean
uploadFile ( uploaded_filename,
directory,
new_filename 
)

Move file from temp directory to specified directory.

Parameters:
string$uploaded_filename
string$directory
string$new_filename
writeFile ( filename,
data,
directory = false,
safename = true 
)

Binary-safe file create, write and return filename path.

Parameters:
string$filename
string$data
string$directory
Returns:
string
zipExtract ( file,
extractPath 
)

Extracts a ZIP archive to the specified extract path

Parameters:
string$fileThe ZIP archive to extract (including the path)
string$extractPathThe path to extract the ZIP archive to
Returns:
boolean TURE if the ZIP archive is successfully extracted, FALSE if there was an errror

Field Documentation

$alias
$allowedExt = 'default'
$cmod = 'default'
$convertDensity = '300'
$convertPdf = false
$cropThumbDimension = 'default'
$cropThumbFromcenter = 'default'
$d = 'core.lang'
$defaultUploadDirectory = 'default'
$doCreateResizeImage = 'default'
$doCreateThumb = 'default'
$doThumbReflect = 'default'
$graphicsEngine = 'gd'
$groupId
$imageCopies = array()
$imageQuality = 'default'
$logUploads = 'default'
$maxFileCount = 0
$maxFilesize = 'default'
$maxImagesize = 'default'
$menuId
$resizeAdaptiveDimension = 'default'
$resizeImageDimension = 'default'
$resizeThumbDimension = 'default'
$resizeThumbPercent = 'default'
$setting
$subId
$thumbnailType = 'default'
$thumbReflectSettings = 'default'
$uploadHistory = array()

The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables Enumerations