/lib/external/class.upload/class.upload.php
PHP | 5000 lines | 2883 code | 349 blank | 1768 comment | 987 complexity | 6d150dc576d8058d87544c4fd1a4f1c0 MD5 | raw file
Possible License(s): GPL-2.0, MIT, LGPL-2.1, BSD-3-Clause, AGPL-3.0, Apache-2.0
Large files files are truncated, but you can click here to view the full file
- <?php
- // +------------------------------------------------------------------------+
- // | class.upload.php |
- // +------------------------------------------------------------------------+
- // | Copyright (c) Colin Verot 2003-2014. All rights reserved. |
- // | Email colin@verot.net |
- // | Web http://www.verot.net |
- // +------------------------------------------------------------------------+
- // | This program is free software; you can redistribute it and/or modify |
- // | it under the terms of the GNU General Public License version 2 as |
- // | published by the Free Software Foundation. |
- // | |
- // | This program is distributed in the hope that it will be useful, |
- // | but WITHOUT ANY WARRANTY; without even the implied warranty of |
- // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
- // | GNU General Public License for more details. |
- // | |
- // | You should have received a copy of the GNU General Public License |
- // | along with this program; if not, write to the |
- // | Free Software Foundation, Inc., 59 Temple Place, Suite 330, |
- // | Boston, MA 02111-1307 USA |
- // | |
- // | Please give credit on sites that use class.upload and submit changes |
- // | of the script so other people can use them as well. |
- // | This script is free to use, don't abuse. |
- // +------------------------------------------------------------------------+
- /**
- * Class upload
- *
- * @author Colin Verot <colin@verot.net>
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- * @copyright Colin Verot
- */
- class upload {
- /**
- * Class version
- *
- * @access public
- * @var string
- */
- var $version;
- /**
- * Uploaded file name
- *
- * @access public
- * @var string
- */
- var $file_src_name;
- /**
- * Uploaded file name body (i.e. without extension)
- *
- * @access public
- * @var string
- */
- var $file_src_name_body;
- /**
- * Uploaded file name extension
- *
- * @access public
- * @var string
- */
- var $file_src_name_ext;
- /**
- * Uploaded file MIME type
- *
- * @access public
- * @var string
- */
- var $file_src_mime;
- /**
- * Uploaded file size, in bytes
- *
- * @access public
- * @var double
- */
- var $file_src_size;
- /**
- * Holds eventual PHP error code from $_FILES
- *
- * @access public
- * @var string
- */
- var $file_src_error;
- /**
- * Uloaded file name, including server path
- *
- * @access public
- * @var string
- */
- var $file_src_pathname;
- /**
- * Uloaded file name temporary copy
- *
- * @access private
- * @var string
- */
- var $file_src_temp;
- /**
- * Destination file name
- *
- * @access public
- * @var string
- */
- var $file_dst_path;
- /**
- * Destination file name
- *
- * @access public
- * @var string
- */
- var $file_dst_name;
- /**
- * Destination file name body (i.e. without extension)
- *
- * @access public
- * @var string
- */
- var $file_dst_name_body;
- /**
- * Destination file extension
- *
- * @access public
- * @var string
- */
- var $file_dst_name_ext;
- /**
- * Destination file name, including path
- *
- * @access public
- * @var string
- */
- var $file_dst_pathname;
- /**
- * Source image width
- *
- * @access public
- * @var integer
- */
- var $image_src_x;
- /**
- * Source image height
- *
- * @access public
- * @var integer
- */
- var $image_src_y;
- /**
- * Source image color depth
- *
- * @access public
- * @var integer
- */
- var $image_src_bits;
- /**
- * Number of pixels
- *
- * @access public
- * @var long
- */
- var $image_src_pixels;
- /**
- * Type of image (png, gif, jpg or bmp)
- *
- * @access public
- * @var string
- */
- var $image_src_type;
- /**
- * Destination image width
- *
- * @access public
- * @var integer
- */
- var $image_dst_x;
- /**
- * Destination image height
- *
- * @access public
- * @var integer
- */
- var $image_dst_y;
- /**
- * Destination image type (png, gif, jpg or bmp)
- *
- * @access public
- * @var integer
- */
- var $image_dst_type;
- /**
- * Supported image formats
- *
- * @access private
- * @var array
- */
- var $image_supported;
- /**
- * Flag to determine if the source file is an image
- *
- * @access public
- * @var boolean
- */
- var $file_is_image;
- /**
- * Flag set after instanciating the class
- *
- * Indicates if the file has been uploaded properly
- *
- * @access public
- * @var bool
- */
- var $uploaded;
- /**
- * Flag stopping PHP upload checks
- *
- * Indicates whether we instanciated the class with a filename, in which case
- * we will not check on the validity of the PHP *upload*
- *
- * This flag is automatically set to true when working on a local file
- *
- * Warning: for uploads, this flag MUST be set to false for security reason
- *
- * @access public
- * @var bool
- */
- var $no_upload_check;
- /**
- * Flag set after calling a process
- *
- * Indicates if the processing, and copy of the resulting file went OK
- *
- * @access public
- * @var bool
- */
- var $processed;
- /**
- * Holds eventual error message in plain english
- *
- * @access public
- * @var string
- */
- var $error;
- /**
- * Holds an HTML formatted log
- *
- * @access public
- * @var string
- */
- var $log;
- // overiddable processing variables
- /**
- * Set this variable to replace the name body (i.e. without extension)
- *
- * @access public
- * @var string
- */
- var $file_new_name_body;
- /**
- * Set this variable to append a string to the file name body
- *
- * @access public
- * @var string
- */
- var $file_name_body_add;
- /**
- * Set this variable to prepend a string to the file name body
- *
- * @access public
- * @var string
- */
- var $file_name_body_pre;
- /**
- * Set this variable to change the file extension
- *
- * @access public
- * @var string
- */
- var $file_new_name_ext;
- /**
- * Set this variable to format the filename (spaces changed to _)
- *
- * @access public
- * @var boolean
- */
- var $file_safe_name;
- /**
- * Forces an extension if the source file doesn't have one
- *
- * If the file is an image, then the correct extension will be added
- * Otherwise, a .txt extension will be chosen
- *
- * @access public
- * @var boolean
- */
- var $file_force_extension;
- /**
- * Set this variable to false if you don't want to check the MIME against the allowed list
- *
- * This variable is set to true by default for security reason
- *
- * @access public
- * @var boolean
- */
- var $mime_check;
- /**
- * Set this variable to false in the init() function if you don't want to check the MIME
- * with Fileinfo PECL extension. On some systems, Fileinfo is known to be buggy, and you
- * may want to deactivate it in the class code directly.
- *
- * You can also set it with the path of the magic database file.
- * If set to true, the class will try to read the MAGIC environment variable
- * and if it is empty, will default to the system's default
- * If set to an empty string, it will call finfo_open without the path argument
- *
- * This variable is set to true by default for security reason
- *
- * @access public
- * @var boolean
- */
- var $mime_fileinfo;
- /**
- * Set this variable to false in the init() function if you don't want to check the MIME
- * with UNIX file() command
- *
- * This variable is set to true by default for security reason
- *
- * @access public
- * @var boolean
- */
- var $mime_file;
- /**
- * Set this variable to false in the init() function if you don't want to check the MIME
- * with the magic.mime file
- *
- * The function mime_content_type() will be deprecated,
- * and this variable will be set to false in a future release
- *
- * This variable is set to true by default for security reason
- *
- * @access public
- * @var boolean
- */
- var $mime_magic;
- /**
- * Set this variable to false in the init() function if you don't want to check the MIME
- * with getimagesize()
- *
- * The class tries to get a MIME type from getimagesize()
- * If no MIME is returned, it tries to guess the MIME type from the file type
- *
- * This variable is set to true by default for security reason
- *
- * @access public
- * @var boolean
- */
- var $mime_getimagesize;
- /**
- * Set this variable to false if you don't want to turn dangerous scripts into simple text files
- *
- * @access public
- * @var boolean
- */
- var $no_script;
- /**
- * Set this variable to true to allow automatic renaming of the file
- * if the file already exists
- *
- * Default value is true
- *
- * For instance, on uploading foo.ext,<br>
- * if foo.ext already exists, upload will be renamed foo_1.ext<br>
- * and if foo_1.ext already exists, upload will be renamed foo_2.ext<br>
- *
- * Note that this option doesn't have any effect if {@link file_overwrite} is true
- *
- * @access public
- * @var bool
- */
- var $file_auto_rename;
- /**
- * Set this variable to true to allow automatic creation of the destination
- * directory if it is missing (works recursively)
- *
- * Default value is true
- *
- * @access public
- * @var bool
- */
- var $dir_auto_create;
- /**
- * Set this variable to true to allow automatic chmod of the destination
- * directory if it is not writeable
- *
- * Default value is true
- *
- * @access public
- * @var bool
- */
- var $dir_auto_chmod;
- /**
- * Set this variable to the default chmod you want the class to use
- * when creating directories, or attempting to write in a directory
- *
- * Default value is 0777 (without quotes)
- *
- * @access public
- * @var bool
- */
- var $dir_chmod;
- /**
- * Set this variable tu true to allow overwriting of an existing file
- *
- * Default value is false, so no files will be overwritten
- *
- * @access public
- * @var bool
- */
- var $file_overwrite;
- /**
- * Set this variable to change the maximum size in bytes for an uploaded file
- *
- * Default value is the value <i>upload_max_filesize</i> from php.ini
- *
- * Value in bytes (integer) or shorthand byte values (string) is allowed.
- * The available options are K (for Kilobytes), M (for Megabytes) and G (for Gigabytes)
- *
- * @access public
- * @var double
- */
- var $file_max_size;
- /**
- * Set this variable to true to resize the file if it is an image
- *
- * You will probably want to set {@link image_x} and {@link image_y}, and maybe one of the ratio variables
- *
- * Default value is false (no resizing)
- *
- * @access public
- * @var bool
- */
- var $image_resize;
- /**
- * Set this variable to convert the file if it is an image
- *
- * Possibles values are : ''; 'png'; 'jpeg'; 'gif'; 'bmp'
- *
- * Default value is '' (no conversion)<br>
- * If {@link resize} is true, {@link convert} will be set to the source file extension
- *
- * @access public
- * @var string
- */
- var $image_convert;
- /**
- * Set this variable to the wanted (or maximum/minimum) width for the processed image, in pixels
- *
- * Default value is 150
- *
- * @access public
- * @var integer
- */
- var $image_x;
- /**
- * Set this variable to the wanted (or maximum/minimum) height for the processed image, in pixels
- *
- * Default value is 150
- *
- * @access public
- * @var integer
- */
- var $image_y;
- /**
- * Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y}
- *
- * Default value is false
- *
- * @access public
- * @var bool
- */
- var $image_ratio;
- /**
- * Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y}
- *
- * The image will be resized as to fill the whole space, and excedent will be cropped
- *
- * Value can also be a string, one or more character from 'TBLR' (top, bottom, left and right)
- * If set as a string, it determines which side of the image is kept while cropping.
- * By default, the part of the image kept is in the center, i.e. it crops equally on both sides
- *
- * Default value is false
- *
- * @access public
- * @var mixed
- */
- var $image_ratio_crop;
- /**
- * Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y}
- *
- * The image will be resized to fit entirely in the space, and the rest will be colored.
- * The default color is white, but can be set with {@link image_default_color}
- *
- * Value can also be a string, one or more character from 'TBLR' (top, bottom, left and right)
- * If set as a string, it determines in which side of the space the image is displayed.
- * By default, the image is displayed in the center, i.e. it fills the remaining space equally on both sides
- *
- * Default value is false
- *
- * @access public
- * @var mixed
- */
- var $image_ratio_fill;
- /**
- * Set this variable to a number of pixels so that {@link image_x} and {@link image_y} are the best match possible
- *
- * The image will be resized to have approximatively the number of pixels
- * The aspect ratio wil be conserved
- *
- * Default value is false
- *
- * @access public
- * @var mixed
- */
- var $image_ratio_pixels;
- /**
- * Set this variable to calculate {@link image_x} automatically , using {@link image_y} and conserving ratio
- *
- * Default value is false
- *
- * @access public
- * @var bool
- */
- var $image_ratio_x;
- /**
- * Set this variable to calculate {@link image_y} automatically , using {@link image_x} and conserving ratio
- *
- * Default value is false
- *
- * @access public
- * @var bool
- */
- var $image_ratio_y;
- /**
- * (deprecated) Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y},
- * but only if original image is bigger
- *
- * This setting is soon to be deprecated. Instead, use {@link image_ratio} and {@link image_no_enlarging}
- *
- * Default value is false
- *
- * @access public
- * @var bool
- */
- var $image_ratio_no_zoom_in;
- /**
- * (deprecated) Set this variable to keep the original size ratio to fit within {@link image_x} x {@link image_y},
- * but only if original image is smaller
- *
- * Default value is false
- *
- * This setting is soon to be deprecated. Instead, use {@link image_ratio} and {@link image_no_shrinking}
- *
- * @access public
- * @var bool
- */
- var $image_ratio_no_zoom_out;
- /**
- * Cancel resizing if the resized image is bigger than the original image, to prevent enlarging
- *
- * Default value is false
- *
- * @access public
- * @var bool
- */
- var $image_no_enlarging;
- /**
- * Cancel resizing if the resized image is smaller than the original image, to prevent shrinking
- *
- * Default value is false
- *
- * @access public
- * @var bool
- */
- var $image_no_shrinking;
- /**
- * Set this variable to set a maximum image width, above which the upload will be invalid
- *
- * Default value is null
- *
- * @access public
- * @var integer
- */
- var $image_max_width;
- /**
- * Set this variable to set a maximum image height, above which the upload will be invalid
- *
- * Default value is null
- *
- * @access public
- * @var integer
- */
- var $image_max_height;
- /**
- * Set this variable to set a maximum number of pixels for an image, above which the upload will be invalid
- *
- * Default value is null
- *
- * @access public
- * @var long
- */
- var $image_max_pixels;
- /**
- * Set this variable to set a maximum image aspect ratio, above which the upload will be invalid
- *
- * Note that ratio = width / height
- *
- * Default value is null
- *
- * @access public
- * @var float
- */
- var $image_max_ratio;
- /**
- * Set this variable to set a minimum image width, below which the upload will be invalid
- *
- * Default value is null
- *
- * @access public
- * @var integer
- */
- var $image_min_width;
- /**
- * Set this variable to set a minimum image height, below which the upload will be invalid
- *
- * Default value is null
- *
- * @access public
- * @var integer
- */
- var $image_min_height;
- /**
- * Set this variable to set a minimum number of pixels for an image, below which the upload will be invalid
- *
- * Default value is null
- *
- * @access public
- * @var long
- */
- var $image_min_pixels;
- /**
- * Set this variable to set a minimum image aspect ratio, below which the upload will be invalid
- *
- * Note that ratio = width / height
- *
- * Default value is null
- *
- * @access public
- * @var float
- */
- var $image_min_ratio;
- /**
- * Compression level for PNG images
- *
- * Between 1 (fast but large files) and 9 (slow but smaller files)
- *
- * Default value is null (Zlib default)
- *
- * @access public
- * @var integer
- */
- var $png_compression;
- /**
- * Quality of JPEG created/converted destination image
- *
- * Default value is 85
- *
- * @access public
- * @var integer
- */
- var $jpeg_quality;
- /**
- * Determines the quality of the JPG image to fit a desired file size
- *
- * The JPG quality will be set between 1 and 100%
- * The calculations are approximations.
- *
- * Value in bytes (integer) or shorthand byte values (string) is allowed.
- * The available options are K (for Kilobytes), M (for Megabytes) and G (for Gigabytes)
- *
- * Default value is null (no calculations)
- *
- * @access public
- * @var integer
- */
- var $jpeg_size;
- /**
- * Turns the interlace bit on
- *
- * This is actually used only for JPEG images, and defaults to false
- *
- * @access public
- * @var boolean
- */
- var $image_interlace;
- /**
- * Flag set to true when the image is transparent
- *
- * This is actually used only for transparent GIFs
- *
- * @access public
- * @var boolean
- */
- var $image_is_transparent;
- /**
- * Transparent color in a palette
- *
- * This is actually used only for transparent GIFs
- *
- * @access public
- * @var boolean
- */
- var $image_transparent_color;
- /**
- * Background color, used to paint transparent areas with
- *
- * If set, it will forcibly remove transparency by painting transparent areas with the color
- * This setting will fill in all transparent areas in PNG and GIF, as opposed to {@link image_default_color}
- * which will do so only in BMP, JPEG, and alpha transparent areas in transparent GIFs
- * This setting overrides {@link image_default_color}
- *
- * Default value is null
- *
- * @access public
- * @var string
- */
- var $image_background_color;
- /**
- * Default color for non alpha-transparent images
- *
- * This setting is to be used to define a background color for semi transparent areas
- * of an alpha transparent when the output format doesn't support alpha transparency
- * This is useful when, from an alpha transparent PNG image, or an image with alpha transparent features
- * if you want to output it as a transparent GIFs for instance, you can set a blending color for transparent areas
- * If you output in JPEG or BMP, this color will be used to fill in the previously transparent areas
- *
- * The default color white
- *
- * @access public
- * @var boolean
- */
- var $image_default_color;
- /**
- * Flag set to true when the image is not true color
- *
- * @access public
- * @var boolean
- */
- var $image_is_palette;
- /**
- * Corrects the image brightness
- *
- * Value can range between -127 and 127
- *
- * Default value is null
- *
- * @access public
- * @var integer
- */
- var $image_brightness;
- /**
- * Corrects the image contrast
- *
- * Value can range between -127 and 127
- *
- * Default value is null
- *
- * @access public
- * @var integer
- */
- var $image_contrast;
- /**
- * Changes the image opacity
- *
- * Value can range between 0 and 100
- *
- * Default value is null
- *
- * @access public
- * @var integer
- */
- var $image_opacity;
- /**
- * Applies threshold filter
- *
- * Value can range between -127 and 127
- *
- * Default value is null
- *
- * @access public
- * @var integer
- */
- var $image_threshold;
- /**
- * Applies a tint on the image
- *
- * Value is an hexadecimal color, such as #FFFFFF
- *
- * Default value is null
- *
- * @access public
- * @var string;
- */
- var $image_tint_color;
- /**
- * Applies a colored overlay on the image
- *
- * Value is an hexadecimal color, such as #FFFFFF
- *
- * To use with {@link image_overlay_opacity}
- *
- * Default value is null
- *
- * @access public
- * @var string;
- */
- var $image_overlay_color;
- /**
- * Sets the opacity for the colored overlay
- *
- * Value is a percentage, as an integer between 0 (transparent) and 100 (opaque)
- *
- * Unless used with {@link image_overlay_color}, this setting has no effect
- *
- * Default value is 50
- *
- * @access public
- * @var integer
- */
- var $image_overlay_opacity;
- /**
- * Inverts the color of an image
- *
- * Default value is FALSE
- *
- * @access public
- * @var boolean;
- */
- var $image_negative;
- /**
- * Turns the image into greyscale
- *
- * Default value is FALSE
- *
- * @access public
- * @var boolean;
- */
- var $image_greyscale;
- /**
- * Pixelate an image
- *
- * Value is integer, represents the block size
- *
- * Default value is null
- *
- * @access public
- * @var integer;
- */
- var $image_pixelate;
- /**
- * Applies an unsharp mask, with alpha transparency support
- *
- * Beware that this unsharp mask is quite resource-intensive
- *
- * Default value is FALSE
- *
- * @access public
- * @var boolean;
- */
- var $image_unsharp;
- /**
- * Sets the unsharp mask amount
- *
- * Value is an integer between 0 and 500, typically between 50 and 200
- *
- * Unless used with {@link image_unsharp}, this setting has no effect
- *
- * Default value is 80
- *
- * @access public
- * @var integer
- */
- var $image_unsharp_amount;
- /**
- * Sets the unsharp mask radius
- *
- * Value is an integer between 0 and 50, typically between 0.5 and 1
- * It is not recommended to change it, the default works best
- *
- * Unless used with {@link image_unsharp}, this setting has no effect
- *
- * From PHP 5.1, imageconvolution is used, and this setting has no effect
- *
- * Default value is 0.5
- *
- * @access public
- * @var integer
- */
- var $image_unsharp_radius;
- /**
- * Sets the unsharp mask threshold
- *
- * Value is an integer between 0 and 255, typically between 0 and 5
- *
- * Unless used with {@link image_unsharp}, this setting has no effect
- *
- * Default value is 1
- *
- * @access public
- * @var integer
- */
- var $image_unsharp_threshold;
- /**
- * Adds a text label on the image
- *
- * Value is a string, any text. Text will not word-wrap, although you can use breaklines in your text "\n"
- *
- * If set, this setting allow the use of all other settings starting with image_text_
- *
- * Replacement tokens can be used in the string:
- * <pre>
- * gd_version src_name src_name_body src_name_ext
- * src_pathname src_mime src_x src_y
- * src_type src_bits src_pixels
- * src_size src_size_kb src_size_mb src_size_human
- * dst_path dst_name_body dst_pathname
- * dst_name dst_name_ext dst_x dst_y
- * date time host server ip
- * </pre>
- * The tokens must be enclosed in square brackets: [dst_x] will be replaced by the width of the picture
- *
- * Default value is null
- *
- * @access public
- * @var string;
- */
- var $image_text;
- /**
- * Sets the text direction for the text label
- *
- * Value is either 'h' or 'v', as in horizontal and vertical
- *
- * Note that if you use a TrueType font, you can use {@link image_text_angle} instead
- *
- * Default value is h (horizontal)
- *
- * @access public
- * @var string;
- */
- var $image_text_direction;
- /**
- * Sets the text color for the text label
- *
- * Value is an hexadecimal color, such as #FFFFFF
- *
- * Default value is #FFFFFF (white)
- *
- * @access public
- * @var string;
- */
- var $image_text_color;
- /**
- * Sets the text opacity in the text label
- *
- * Value is a percentage, as an integer between 0 (transparent) and 100 (opaque)
- *
- * Default value is 100
- *
- * @access public
- * @var integer
- */
- var $image_text_opacity;
- /**
- * Sets the text background color for the text label
- *
- * Value is an hexadecimal color, such as #FFFFFF
- *
- * Default value is null (no background)
- *
- * @access public
- * @var string;
- */
- var $image_text_background;
- /**
- * Sets the text background opacity in the text label
- *
- * Value is a percentage, as an integer between 0 (transparent) and 100 (opaque)
- *
- * Default value is 100
- *
- * @access public
- * @var integer
- */
- var $image_text_background_opacity;
- /**
- * Sets the text font in the text label
- *
- * Value is a an integer between 1 and 5 for GD built-in fonts. 1 is the smallest font, 5 the biggest
- * Value can also be a string, which represents the path to a GDF or TTF font (TrueType).
- *
- * Default value is 5
- *
- * @access public
- * @var mixed;
- */
- var $image_text_font;
- /**
- * Sets the text font size for TrueType fonts
- *
- * Value is a an integer, and represents the font size in pixels (GD1) or points (GD1)
- *
- * Note that this setting is only applicable to TrueType fonts, and has no effects with GD fonts
- *
- * Default value is 16
- *
- * @access public
- * @var integer;
- */
- var $image_text_size;
- /**
- * Sets the text angle for TrueType fonts
- *
- * Value is a an integer between 0 and 360, in degrees, with 0 degrees being left-to-right reading text.
- *
- * Note that this setting is only applicable to TrueType fonts, and has no effects with GD fonts
- * For GD fonts, you can use {@link image_text_direction} instead
- *
- * Default value is null (so it is determined by the value of {@link image_text_direction})
- *
- * @access public
- * @var integer;
- */
- var $image_text_angle;
- /**
- * Sets the text label position within the image
- *
- * Value is one or two out of 'TBLR' (top, bottom, left, right)
- *
- * The positions are as following:
- * <pre>
- * TL T TR
- * L R
- * BL B BR
- * </pre>
- *
- * Default value is null (centered, horizontal and vertical)
- *
- * Note that is {@link image_text_x} and {@link image_text_y} are used, this setting has no effect
- *
- * @access public
- * @var string;
- */
- var $image_text_position;
- /**
- * Sets the text label absolute X position within the image
- *
- * Value is in pixels, representing the distance between the left of the image and the label
- * If a negative value is used, it will represent the distance between the right of the image and the label
- *
- * Default value is null (so {@link image_text_position} is used)
- *
- * @access public
- * @var integer
- */
- var $image_text_x;
- /**
- * Sets the text label absolute Y position within the image
- *
- * Value is in pixels, representing the distance between the top of the image and the label
- * If a negative value is used, it will represent the distance between the bottom of the image and the label
- *
- * Default value is null (so {@link image_text_position} is used)
- *
- * @access public
- * @var integer
- */
- var $image_text_y;
- /**
- * Sets the text label padding
- *
- * Value is in pixels, representing the distance between the text and the label background border
- *
- * Default value is 0
- *
- * This setting can be overriden by {@link image_text_padding_x} and {@link image_text_padding_y}
- *
- * @access public
- * @var integer
- */
- var $image_text_padding;
- /**
- * Sets the text label horizontal padding
- *
- * Value is in pixels, representing the distance between the text and the left and right label background borders
- *
- * Default value is null
- *
- * If set, this setting overrides the horizontal part of {@link image_text_padding}
- *
- * @access public
- * @var integer
- */
- var $image_text_padding_x;
- /**
- * Sets the text label vertical padding
- *
- * Value is in pixels, representing the distance between the text and the top and bottom label background borders
- *
- * Default value is null
- *
- * If set, his setting overrides the vertical part of {@link image_text_padding}
- *
- * @access public
- * @var integer
- */
- var $image_text_padding_y;
- /**
- * Sets the text alignment
- *
- * Value is a string, which can be either 'L', 'C' or 'R'
- *
- * Default value is 'C'
- *
- * This setting is relevant only if the text has several lines.
- *
- * Note that this setting is only applicable to GD fonts, and has no effects with TrueType fonts
- *
- * @access public
- * @var string;
- */
- var $image_text_alignment;
- /**
- * Sets the text line spacing
- *
- * Value is an integer, in pixels
- *
- * Default value is 0
- *
- * This setting is relevant only if the text has several lines.
- *
- * Note that this setting is only applicable to GD fonts, and has no effects with TrueType fonts
- *
- * @access public
- * @var integer
- */
- var $image_text_line_spacing;
- /**
- * Sets the height of the reflection
- *
- * Value is an integer in pixels, or a string which format can be in pixels or percentage.
- * For instance, values can be : 40, '40', '40px' or '40%'
- *
- * Default value is null, no reflection
- *
- * @access public
- * @var mixed;
- */
- var $image_reflection_height;
- /**
- * Sets the space between the source image and its relection
- *
- * Value is an integer in pixels, which can be negative
- *
- * Default value is 2
- *
- * This setting is relevant only if {@link image_reflection_height} is set
- *
- * @access public
- * @var integer
- */
- var $image_reflection_space;
- /**
- * Sets the initial opacity of the reflection
- *
- * Value is an integer between 0 (no opacity) and 100 (full opacity).
- * The reflection will start from {@link image_reflection_opacity} and end up at 0
- *
- * Default value is 60
- *
- * This setting is relevant only if {@link image_reflection_height} is set
- *
- * @access public
- * @var integer
- */
- var $image_reflection_opacity;
- /**
- * Automatically rotates the image according to EXIF data (JPEG only)
- *
- * Default value is true
- *
- * @access public
- * @var boolean;
- */
- var $image_auto_rotate;
- /**
- * Flips the image vertically or horizontally
- *
- * Value is either 'h' or 'v', as in horizontal and vertical
- *
- * Default value is null (no flip)
- *
- * @access public
- * @var string;
- */
- var $image_flip;
- /**
- * Rotates the image by increments of 45 degrees
- *
- * Value is either 90, 180 or 270
- *
- * Default value is null (no rotation)
- *
- * @access public
- * @var string;
- */
- var $image_rotate;
- /**
- * Crops an image
- *
- * Values are four dimensions, or two, or one (CSS style)
- * They represent the amount cropped top, right, bottom and left.
- * These values can either be in an array, or a space separated string.
- * Each value can be in pixels (with or without 'px'), or percentage (of the source image)
- *
- * For instance, are valid:
- * <pre>
- * $foo->image_crop = 20 OR array(20);
- * $foo->image_crop = '20px' OR array('20px');
- * $foo->image_crop = '20 40' OR array('20', 40);
- * $foo->image_crop = '-20 25%' OR array(-20, '25%');
- * $foo->image_crop = '20px 25%' OR array('20px', '25%');
- * $foo->image_crop = '20% 25%' OR array('20%', '25%');
- * $foo->image_crop = '20% 25% 10% 30%' OR array('20%', '25%', '10%', '30%');
- * $foo->image_crop = '20px 25px 2px 2px' OR array('20px', '25%px', '2px', '2px');
- * $foo->image_crop = '20 25% 40px 10%' OR array(20, '25%', '40px', '10%');
- * </pre>
- *
- * If a value is negative, the image will be expanded, and the extra parts will be filled with black
- *
- * Default value is null (no cropping)
- *
- * @access public
- * @var string OR array;
- */
- var $image_crop;
- /**
- * Crops an image, before an eventual resizing
- *
- * See {@link image_crop} for valid formats
- *
- * Default value is null (no cropping)
- *
- * @access public
- * @var string OR array;
- */
- var $image_precrop;
- /**
- * Adds a bevel border on the image
- *
- * Value is a positive integer, representing the thickness of the bevel
- *
- * If the bevel colors are the same as the background, it makes a fade out effect
- *
- * Default value is null (no bevel)
- *
- * @access public
- * @var integer
- */
- var $image_bevel;
- /**
- * Top and left bevel color
- *
- * Value is a color, in hexadecimal format
- * This setting is used only if {@link image_bevel} is set
- *
- * Default value is #FFFFFF
- *
- * @access public
- * @var string;
- */
- var $image_bevel_color1;
- /**
- * Right and bottom bevel color
- *
- * Value is a color, in hexadecimal format
- * This setting is used only if {@link image_bevel} is set
- *
- * Default value is #000000
- *
- * @access public
- * @var string;
- */
- var $image_bevel_color2;
- /**
- * Adds a single-color border on the outer of the image
- *
- * Values are four dimensions, or two, or one (CSS style)
- * They represent the border thickness top, right, bottom and left.
- * These values can either be in an array, or a space separated string.
- * Each value can be in pixels (with or without 'px'), or percentage (of the source image)
- *
- * See {@link image_crop} for valid formats
- *
- * If a value is negative, the image will be cropped.
- * Note that the dimensions of the picture will be increased by the borders' thickness
- *
- * Default value is null (no border)
- *
- * @access public
- * @var integer
- */
- var $image_border;
- /**
- * Border color
- *
- * Value is a color, in hexadecimal format.
- * This setting is used only if {@link image_border} is set
- *
- * Default value is #FFFFFF
- *
- * @access public
- * @var string;
- */
- var $image_border_color;
- /**
- * Sets the opacity for the borders
- *
- * Value is a percentage, as an integer between 0 (transparent) and 100 (opaque)
- *
- * Unless used with {@link image_border}, this setting has no effect
- *
- * Default value is 100
- *
- * @access public
- * @var integer
- */
- var $image_border_opacity;
- /**
- * Adds a fading-to-transparent border on the image
- *
- * Values are four dimensions, or two, or one (CSS style)
- * They represent the border thickness top, right, bottom and left.
- * These values can either be in an array, or a space separated string.
- * Each value can be in pixels (with or without 'px'), or percentage (of the source image)
- *
- * See {@link image_crop} for valid formats
- *
- * Note that the dimensions of the picture will not be increased by the borders' thickness
- *
- * Default value is null (no border)
- *
- * @access public
- * @var integer
- */
- var $image_border_transparent;
- /**
- * Adds a multi-color frame on the outer of the image
- *
- * Value is an integer. Two values are possible for now:
- * 1 for flat border, meaning that the frame is mirrored horizontally and vertically
- * 2 for crossed border, meaning that the frame will be inversed, as in a bevel effect
- *
- * The frame will be composed of colored lines set in {@link image_frame_colors}
- *
- * Note that the dimensions of the picture will be increased by the borders' thickness
- *
- * Default value is null (no frame)
- *
- * @access public
- * @var integer
- */
- var $image_frame;
- /**
- * Sets the colors used to draw a frame
- *
- * Values is a list of n colors in hexadecimal format.
- * These values can either be in an array, or a space separated string.
- *
- * The colors are listed in the following order: from the outset of the image to its center
- *
- * For instance, are valid:
- * <pre>
- * $foo->image_frame_colors = '#FFFFFF #999999 #666666 #000000';
- * $foo->image_frame_colors = array('#FFFFFF', '#999999', '#666666', '#000000');
- * </pre>
- *
- * This setting is used only if {@link image_frame} is set
- *
- * Default value is '#FFFFFF #999999 #666666 #000000'
- *
- * @access public
- * @var string OR array;
- */
- var $image_frame_colors;
- /**
- * Sets the opacity for the frame
- *
- * Value is a percentage, as an integer between 0 (transparent) and 100 (opaque)
- *
- * Unless used with {@link image_frame}, this setting has no effect
- *
- * Default value is 100
- *
- * @access public
- * @var integer
- */
- var $image_frame_opacity;
- /**
- * Adds a watermark on the image
- *
- * Value is a local image filename, relative or absolute. GIF, JPG, BMP and PNG are supported, as well as PNG alpha.
- *
- * If set, this setting allow the use of all other settings starting with image_watermark_
- *
- * Default value is null
- *
- * @access public
- * @var string;
- */
- var $image_watermark;
- /**
- * Sets the watermarkposition within the image
- *
- * Value is one or two out of 'TBLR' (top, bottom, left, right)
- *
- * The positions are as following: TL T TR
- * L R
- * BL B BR
- *
- * Default value is null (centered, horizontal and vertical)
- *
- * Note that is {@link image_watermark_x} and {@link image_watermark_y} are used, this setting has no effect
- *
- * @access public
- * @var string;
- */
- var $image_watermark_position;
- /**
- * Sets the watermark absolute X position within the image
- *
- * Value is in pixels, representing the distance between the top of the image and the watermark
- * If a negative value is used, it will represent the distance between the bottom of the image and the watermark
- *
- * Default value is null (so {@link image_watermark_position} is used)
- *
- * @access public
- * @var integer
- */
- var $image_watermark_x;
- /**
- * Sets the twatermark absolute Y position within the image
- *
- * Value is in pixels, representing the distance between the left of the image and the watermark
- * If a negative value is used, it will represent the distance between the right of the image and the watermark
- *
- * Default value is null (so {@link image_watermark_position} is used)
- *
- * @access public
- * @var integer
- */
- var $image_watermark_y;
- /**
- * Prevents the watermark to be resized up if it is smaller than the image
- *
- * If the watermark if smaller than the destination image, taking in account the desired watermark position
- * then it will be resized up to fill in the image (minus the {@link image_watermark_x} or {@link image_watermark_y} values)
- *
- * If you don't want your watermark to be resized in any way, then
- * set {@link image_watermark_no_zoom_in} and {@link image_watermark_no_zoom_out} to true
- * If you want your watermark to be resized up or doan to fill in the image better, then
- * set {@link image_watermark_no_zoom_in} and {@link image_watermark_no_zoom_out} to false
- *
- * Default value is true (so the watermark will not be resized up, which is the behaviour most people expect)
- *
- * @access public
- * @var integer
- */
- var $image_watermark_no_zoom_in;
- /**
- * Prevents the watermark to be resized down if it is bigger than the image
- *
- * If the watermark if bigger than the destination image, taking in account the desired watermark position
- * then it will be resized down to fit in the image (minus the {@link image_watermark_x} or {@link image_watermark_y} values)
- *
- * If you don't want your watermark to be resized in any way, then
- * set {@link image_watermark_no_zoom_in} and {@link image_watermark_no_zoom_out} to true
- * If you want your watermark to be resized up or doan to fill in the image better, then
- * set {@link image_watermark_no_zoom_in} and {@link image_watermark_no_zoom_out} to false
- *
- * Default value is false (so the watermark may be shrinked to fit in the image)
- *
- * @access public
- * @var integer
- */
- var $image_watermark_no_zoom_out;
- /**
- * List of MIME types per extension
- *
- * @access private
- * @var array
- */
- var $mime_types;
- /**
- * Allowed MIME types
- *
- * Default is a selection of safe mime-types, but you might want to change it
- *
- * Simple wildcards are allowed, such as image/* or application/*
- * If there is only one MIME type allowed, then it can be a string instead of an array
- *
- * @access public
- * @var array OR string
- */
- var $allowed;
- /**
- * Forbidden MIME types
- *
- * Default is a selection of safe mime-types, but you might want to change it
- * To only check for forbidden MIME types, and allow everything else, set {@link allowed} to array('* / *') without the spaces
- *
- * Simple wildcards are allowed, such as image/* or application/*
- * If there is only one MIME type forbidden, then it can be a string instead of an array
- *
- * @access public
- * @var array OR string
- */
- var $forbidden;
- /**
- * Array of translated error messages
- *
- * By default, the language is english (en_GB)
- * Translations can be in separate files, in a lang/ subdirectory
- *
- * @access public
- * @var array
- */
- var $translation;
- /**
- * Language selected for the translations
- *
- * By default, the language is english ("en_GB")
- *
- * @access public
- * @var array
- */
- var $lang;
- /**
- * Init or re-init all the processing variables to their default values
- *
- * This function is called in the constructor, and after each call of {@link process}
- *
- * @access private
- */
- function init() {
- // overiddable variables
- $this->file_new_name_body = null; // replace the name body
- $this->file_name_body_add = null; // append to the name body
- $this->file_name_body_pre = null; // prepend to the name body
- $this->file_new_name_ext = null; // replace the file extension
- $this->file_safe_name = true; // format safely the filename
- $this->file_force_extension = true; // forces extension if there isn't one
- $this->file_overwrite = false; // allows overwritting if the file already exists
- $this->file_auto_rename = true; // auto-rename if the file already exists
- $this->dir_auto_create = true; // auto-creates directory if missing
- $this->dir_auto_chmod = true; // auto-chmod directory if not writeable
- $this->dir_chmod = 0777; // default chmod to use
- $this->no_script = true; // turns scripts into test files
- $this->mime_check = true; // checks the mime type against the allowed list
- // these are the different MIME detection methods. if one of these method doesn't work on your
- // system, you can deactivate it here; just set it to false
- $this->mime_fileinfo = true; // MIME detection with Fileinfo PECL extension
- $this->mime_file = true; // MIME detection with UNIX file() command
- $this->mime_magic = true; // MIME detection with mime_magic (mime_content_type())
- $this->mime_getimagesize = true; // MIME detection with getimagesize()
- // get the default max size from php.ini
- $this->file_max_size_raw = trim(ini_get('upload_max_filesize'));
- $this->file_max_size = $this->getsize($this->file_max_size_raw);
- $this->image_resize = false; // resize the image
- $this->image_convert = ''; // convert. values :''; 'png'; 'jpeg'; 'gif'; 'bmp'
- $this->image_x = 150;
- $this->image_y = 150;
- $this->image_ratio = false; // keeps aspect ratio with x and y dimensions
- $this->image_ratio_crop = false; // keeps aspect ratio with x and y dimensions, filling the space
- $this->image_ratio_fill = false; // keeps aspect ratio with x and y dimensions, fitting the image in the space, and coloring the rest
- $this->image_ratio_pixels = false; // keeps aspect ratio, calculating x and y so that the image is approx the set number of pixels
- $this->image_ratio_x = false; // calculate the $image_x if true
- $this->image_ratio_y = false; // calculate the $image_y if true
- $this->image_ratio_no_zoom_in = false;
- $this->image_ratio_no_zoom_out = false;
- $this->image_no_enlarging = false;
- $this->image_no_shrinking = false;
- $this->png_compression = null;
- $this->jpeg_quality = 85;
- $this->jpeg_size = null;
- $this->image_interlace = false;
- $this->image_is_transparent = false;
- $this->image_transparent_color = null;
- $this->image_background_color = null;
- $this->image_default_color = '#ffffff';
- $this->image_is_palette = false;
- $this->image_max_width = null;
- $this->image_max_height = null;
- $this->image_max_pixels = null;
- $this->image_max_ratio = null;
- $this->image_min_width = null;
- $this->image_min_height = null;
- $this->image_min_pixels = null;
- $this->image_min_ratio = null;
- $this->image_brightness = null;
- $this->image_contrast = null;
- $this->image_opacity = null;
- $this->image_threshold = null;
- $this->image_tint_color = null;
- $this->image_overlay_color = null;
- $this->image_overlay_opacity = null;
- …
Large files files are truncated, but you can click here to view the full file