Class filemanager

Description

This class handles file uploads in its simplest form.

  • deprecated:

Located in /legacy/filemanager.class.php (line 18)


	
			
Variable Summary
Method Summary
string auto_upload (string $input_name, [string $file_overwrite_id = false], [string $file_description = false])
void create_date_directory ([string $directory = false], [integer $cmod = false])
boolean. delete_dir ($dirname $dirname)
void delete_filename ([string $filename = false])
boolean delete_files ([integer $file_id = false], [string $alias = false], [integer $sub_id = false], [integer $menu_id = false])
string display_filesize (numeric $filesize)
mixed download_file ($url $url, $copy_to $copy_to)
resource establish_ftp ([$username $username = 'config'], [$password $password = 'config'], [$host $host = 'config'], [$port $port = 'config'], [$ssl $ssl = 'config'], [$timeout $timeout = 'config'], [$chdir $chdir = 'config'])
void ftp_rcopy (resource $conn_id, string $src_dir, string $dst_dir)
string get_file_base (string $filename)
string get_file_extension (string $filename)
void icon_type (string $extension_lookup)
array load_files ([integer $file_id = false], [string $alias = false], [integer $sub_id = false], [integer $menu_id = false], [string $order = 'file_id DESC'], [string $limit = '0,5'])
void rename_unique_filename ( $filename, [ $extension = false])
void return_image_copies (string $file, [int $nr = 0])
void safe_file_name (string $filename, [string $replace = '_'])
boolean smartCopy ($source $source, $dest $dest, [$options $options = array('folderPermission'=>0755,'filePermission'=>0644)])
void upload_file (string $uploaded_filename, string $directory, string $new_filename)
boolean zip_extract (string $file, string $extractPath)
Variables
string $alias (line 165)

An alias to group the images with in a certain application.

Will use active plugin name if left empty.

  • access: public
string $allowed_ext = 'default' (line 66)

The allowed extentions for uploads.

Default will load settings from database. Example : jpg,png,gif

  • access: public
int $cmod = 'default' (line 42)

Set permission for newly uploaded files.

Default will load settings from database. Example : 0777

  • access: public
integer $convert_density = '300' (line 199)

Choose the density image will be converted to from pdf.

  • access: public
boolean $convert_pdf = false (line 193)

Convert pdf to image using convert in Linux.

Please note imagemagick needs to be installed on Linux server.

  • access: public
string $crop_thumb_dimension = 'default' (line 129)

Crop by measure.

Default will load settings from database. [startX, startY, width, height] example (create a 100x50 pixel crop from the top left corner of an image) : 0,0,100,50

  • access: public
string $crop_thumb_fromcenter = 'default' (line 121)

Crop from center.

Default will load settings from database. [Crop Size] example (create a 100x100 pixel crop from the center of an image) : 100

  • access: public
string $default_upload_directory = 'default' (line 34)

The default upload relative path for files.

Default will load settings from database. Example : myupload

  • access: public
boolean $do_create_resize_image = 'default' (line 151)

This option will shrink a large image to a smaller then original viewable image. This should be larger then a thumbnail in most cases as this is the image the user can see when clicking on a thumbnail.

Default will load settings from database.

  • access: public
boolean $do_create_thumb = 'default' (line 73)

Should thumbnails be created on image uploads.

Default will load settings from database.

  • access: public
boolean $do_thumb_reflect = 'default' (line 136)

Add thumb reflections.

Default will load settings from database.

  • access: public
string $graphics_engine = 'gd' (line 206)

Graphics Engine.

Supports gd, imagick

  • access: public
int $group_id (line 186)

The group a file batch belongs to.

Will use uploaders primary group id if left empty.

  • access: public
array $image_copies = array() (line 212)

When converting to pdf with multiple pages, image copies will be stored here.

  • access: public
int $image_quality = 'default' (line 81)

Image quality of converted images.

Default will load settings from database. Example : 80

  • access: public
boolean $log_uploads = 'default' (line 26)

Should file uploads be logged to the database.

Default will load settings from database.

  • access: public
int $max_filesize = 'default' (line 50)

The maximum allowed file upload size.

Default will load settings from database. Example : 1000 (1kb)

  • access: public
int $max_imagesize = 'default' (line 58)

The maximum allowed image upload size.

Default will load settings from database. Example : 1000 (1kb)

  • access: public
int $menu_id (line 172)

Groups file upload by menu id.

Will use active menu id if left empty.

  • access: public
string $resize_adaptive_dimension = 'default' (line 97)

Adaptive adjust resizing.

Default will load settings from database. [Max Width, Max Height] example (resize image to no wider than 250 pixels wide and 250 pixels high thumbnails to be uniformly sized) : 250,250

  • access: public
string $resize_image_dimension = 'default' (line 158)

[Max Width, Max Height] example (resize image to no wider than 500 pixels wide and 500 pixels high) : 500,500 Default will load settings from database.

  • access: public
string $resize_thumb_dimension = 'default' (line 105)

Resize by pixels.

Default will load settings from database. [Max Width, Max Height] example (resize image to no wider than 250 pixels wide and 250 pixels high) : 250,250

  • access: public
string $resize_thumb_percent = 'default' (line 113)

Resize by percentage.

Default will load settings from database. [Percentage] example (reduce the image by 50%) : 50

  • access: public
int $sub_id (line 179)

Groups file uploads to a specific document.

Will use active menu id if left empty.

  • access: public
string $thumbnail_type = 'default' (line 89)

Typical resize type for thumbnails.

Default will load settings from database. Options : resize | resizepercent | cropfromcenter | crop | adaptive

  • access: public
string $thumb_reflect_settings = 'default' (line 144)

Reflection options.

Default will load settings from database. Data fields expected are [[Percentage of image], [Reflection percentage], [Transparency of reflection], [Set Border], [Border Color]. Example : 40,40,80,true,#a4a4a4

  • access: public
array $upload_history = array() (line 218)

Holds a record of recently uploaded files.

  • access: public
Methods
auto_upload (line 461)

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

  • return: Will return the complete uploaded directory with its filename.
  • access: public
string auto_upload (string $input_name, [string $file_overwrite_id = false], [string $file_description = false])
  • string $input_name: The name of the <form type="file" name="???" />
  • string $file_overwrite_id: The id of the log that needs to be overwritten.
  • string $file_description: a Simple file description for uploaded item.
create_date_directory (line 379)

Creates directory according to month and year.

  • access: public
void create_date_directory ([string $directory = false], [integer $cmod = false])
  • string $directory: Writable directory where new directories will be created and files stored.
  • integer $cmod
delete_dir (line 1055)

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

  • access: public
boolean. delete_dir ($dirname $dirname)
  • $dirname $dirname: Directory to delete.
delete_filename (line 358)

Deletes a filename.

  • access: public
void delete_filename ([string $filename = false])
  • string $filename
delete_files (line 787)

Delete file logs from database.

  • return: Will return true if deleted.
  • access: public
boolean delete_files ([integer $file_id = false], [string $alias = false], [integer $sub_id = false], [integer $menu_id = false])
  • integer $file_id: Get only a single file with a file_id.
  • string $alias: Load only files by this alias.
  • integer $sub_id: Load only files by this sub_id.
  • integer $menu_id: Load only files by this menu_id.
display_filesize (line 686)

Convert numeric into file size.

  • author: info@levaravel.com
  • access: public
string display_filesize (numeric $filesize)
  • numeric $filesize
download_file (line 918)

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

  • access: public
mixed download_file ($url $url, $copy_to $copy_to)
  • $url $url: The url to download from
  • $copy_to $copy_to: The location to copy to add the name to the file too, example: /var/www/test.zip
establish_ftp (line 1087)

Connects to a normal ftp or secure server.

If values left empty system will use PHPDevShell configuration values.

  • return: connection id.
  • access: public
resource establish_ftp ([$username $username = 'config'], [$password $password = 'config'], [$host $host = 'config'], [$port $port = 'config'], [$ssl $ssl = 'config'], [$timeout $timeout = 'config'], [$chdir $chdir = 'config'])
  • $username $username
  • $password $password
  • $host $host
  • $port $port
  • $ssl $ssl
  • $timeout $timeout
  • $chdir $chdir
ftp_rcopy (line 1140)

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

  • access: public
void ftp_rcopy (resource $conn_id, string $src_dir, string $dst_dir)
  • resource $conn_id
  • string $src_dir
  • string $dst_dir
get_file_base (line 249)

Get filename without extension.

  • access: public
string get_file_base (string $filename)
  • string $filename
get_file_extension (line 238)

Get a files extension.

  • access: public
string get_file_extension (string $filename)
  • string $filename
icon_type (line 260)

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

  • access: public
void icon_type (string $extension_lookup)
  • string $extension_lookup
load_files (line 837)

Load uploaded files from the log database.

  • access: public
array load_files ([integer $file_id = false], [string $alias = false], [integer $sub_id = false], [integer $menu_id = false], [string $order = 'file_id DESC'], [string $limit = '0,5'])
  • integer $file_id: Get only a single file with a file_id.
  • string $alias: Load only files by this alias.
  • integer $sub_id: Load only files by this sub_id.
  • integer $menu_id: Load only files by this menu_id.
  • string $order: What 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 $limit: how many files should be returned in the array.
rename_unique_filename (line 436)

Creates unique and safe filename.

  • access: public
void rename_unique_filename ( $filename, [ $extension = false])
  • $filename
  • $extension
return_image_copies (line 900)

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

  • access: public
void return_image_copies (string $file, [int $nr = 0])
  • string $file
  • int $nr: The current file number in the loop.
safe_file_name (line 226)

This method simply renames the file to unix standards.

  • access: public
void safe_file_name (string $filename, [string $replace = '_'])
  • string $filename
  • string $replace: Replace odd characters with what?
smartCopy (line 989)

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
  • access: public
boolean smartCopy ($source $source, $dest $dest, [$options $options = array('folderPermission'=>0755,'filePermission'=>0644)])
  • $source $source: //file or folder
  • $dest $dest: ///file or folder
  • $options $options: //folderPermission,filePermission
upload_file (line 423)

Move file from temp directory to specified directory.

  • access: public
void upload_file (string $uploaded_filename, string $directory, string $new_filename)
  • string $uploaded_filename
  • string $directory
  • string $new_filename
zip_extract (line 954)

Extracts a ZIP archive to the specified extract path

  • return: TURE if the ZIP archive is successfully extracted, FALSE if there was an errror
  • access: public
boolean zip_extract (string $file, string $extractPath)
  • string $file: The ZIP archive to extract (including the path)
  • string $extractPath: The path to extract the ZIP archive to

Documentation generated on Tue, 09 Aug 2011 09:04:49 +0200 by phpDocumentor 1.4.3