updated KCFinder to current development version

parent 38586998
......@@ -4,7 +4,7 @@
*
* @desc Browser calling script
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......
......@@ -4,7 +4,7 @@
*
* @desc This file is included first, before each other
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......@@ -26,11 +26,6 @@ if (substr(PHP_VERSION, 0, strpos(PHP_VERSION, '.')) < 5)
die("You are using PHP " . PHP_VERSION . " when KCFinder require at least version 5! Some systems has an option to change the active PHP version. Please refer to your hosting provider or upgrade your PHP distribution.");
// GD EXTENSION CHECK
if (!function_exists("imagecopyresampled"))
die("The GD PHP extension is not available! It's required to run KCFinder.");
// SAFE MODE CHECK
if (ini_get("safe_mode"))
die("The \"safe_mode\" PHP ini setting is turned on! You cannot run KCFinder in safe mode.");
......
......@@ -4,7 +4,7 @@
*
* @desc Browser actions class
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......@@ -151,19 +151,19 @@ class browser extends uploader {
$file = "{$this->config['uploadDir']}/{$this->type}/{$this->get['dir']}/" . basename($file);
if (!is_file($file) || !is_readable($file))
$this->sendDefaultThumb($file);
$image = new gd($file);
if ($image->init_error)
$image = image::factory($this->imageDriver, $file);
if ($image->initError)
$this->sendDefaultThumb($file);
$browsable = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG);
if (in_array($image->type, $browsable) &&
($image->get_width() <= $this->config['thumbWidth']) &&
($image->get_height() <= $this->config['thumbHeight'])
list($tmp, $tmp, $type) = getimagesize($file);
if (in_array($type, array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)) &&
($image->width <= $this->config['thumbWidth']) &&
($image->height <= $this->config['thumbHeight'])
) {
$type =
($image->type == IMAGETYPE_GIF) ? "gif" : (
($image->type == IMAGETYPE_PNG) ? "png" : "jpeg");
$type = "image/$type";
httpCache::file($file, $type);
$mime =
($type == IMAGETYPE_GIF) ? "gif" : (
($type == IMAGETYPE_PNG) ? "png" : "jpeg");
$mime = "image/$mime";
httpCache::file($file, $mime);
} else
$this->sendDefaultThumb($file);
}
......
......@@ -2,9 +2,9 @@
/** This file is part of KCFinder project
*
* @desc GD image detection class
* @desc Image detection class
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......@@ -15,9 +15,15 @@
class type_img {
public function checkFile($file, array $config) {
$gd = new gd($file);
if ($gd->init_error)
$driver = isset($config['imageDriversPriority'])
? image::getDriver(explode(" ", $config['imageDriversPriority'])) : "gd";
$img = image::factory($driver, $file);
if ($img->initError)
return "Unknown image format/encoding.";
return true;
}
}
......
......@@ -4,7 +4,7 @@
*
* @desc MIME type detection class
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......
......@@ -4,7 +4,7 @@
*
* @desc Uploader class
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......@@ -15,12 +15,16 @@
class uploader {
/** Release version */
const VERSION = "2.51";
const VERSION = "2.52-dev";
/** Config session-overrided settings
* @var array */
protected $config = array();
/** Default image driver
* @var string */
protected $imageDriver = "gd";
/** Opener applocation properties
* $opener['name'] Got from $_GET['opener'];
* $opener['CKEditor']['funcNum'] CKEditor function number (got from $_GET)
......@@ -48,7 +52,7 @@ class uploader {
/** Settings which can override default settings if exists as keys in $config['types'][$type] array
* @var array */
protected $typeSettings = array('disabled', 'theme', 'dirPerms', 'filePerms', 'denyZipDownload', 'maxImageWidth', 'maxImageHeight', 'thumbWidth', 'thumbHeight', 'jpegQuality', 'access', 'filenameChangeChars', 'dirnameChangeChars', 'denyExtensionRename', 'deniedExts');
protected $typeSettings = array('disabled', 'theme', 'dirPerms', 'filePerms', 'denyZipDownload', 'maxImageWidth', 'maxImageHeight', 'thumbWidth', 'thumbHeight', 'jpegQuality', 'access', 'filenameChangeChars', 'dirnameChangeChars', 'denyExtensionRename', 'deniedExts', 'watermark');
/** Got from language file
* @var string */
......@@ -157,6 +161,23 @@ class uploader {
} else
$this->session = &$_SESSION;
// IMAGE DRIVER INIT
if (isset($this->config['imageDriversPriority'])) {
$this->config['imageDriversPriority'] =
text::clearWhitespaces($this->config['imageDriversPriority']);
$driver = image::getDriver(explode(' ', $this->config['imageDriversPriority']));
if ($driver !== false)
$this->imageDriver = $driver;
}
if ((!isset($driver) || ($driver === false)) &&
(image::getDriver(array($this->imageDriver)) === false)
)
die("Cannot find any of the supported PHP image extensions!");
// WATERMARK INIT
if (isset($this->config['watermark']) && is_string($this->config['watermark']))
$this->config['watermark'] = array('file' => $this->config['watermark']);
// GET TYPE DIRECTORY
$this->types = &$this->config['types'];
$firstType = array_keys($this->types);
......@@ -421,8 +442,8 @@ class uploader {
}
// IMAGE RESIZE
$gd = new gd($file['tmp_name']);
if (!$gd->init_error && !$this->imageResize($gd, $file['tmp_name']))
$img = image::factory($this->imageDriver, $file['tmp_name']);
if (!$img->initError && !$this->imageResize($img, $file['tmp_name']))
return $this->label("The image is too big and/or cannot be resized.");
return true;
......@@ -490,51 +511,105 @@ class uploader {
}
protected function imageResize($image, $file=null) {
if (!($image instanceof gd)) {
$gd = new gd($image);
if ($gd->init_error) return false;
if (!($image instanceof image)) {
$img = image::factory($this->imageDriver, $image);
if ($img->initError) return false;
$file = $image;
} elseif ($file === null)
return false;
else
$gd = $image;
$img = $image;
$orientation = 1;
if (function_exists("exif_read_data")) {
$orientation = @exif_read_data($file);
$orientation = isset($orientation['Orientation']) ? $orientation['Orientation'] : 1;
}
if ((!$this->config['maxImageWidth'] && !$this->config['maxImageHeight']) ||
(
($gd->get_width() <= $this->config['maxImageWidth']) &&
($gd->get_height() <= $this->config['maxImageHeight'])
)
// IMAGE WILL NOT BE RESIZED WHEN NO WATERMARK AND SIZE IS ACCEPTABLE
if ((
!isset($this->config['watermark']['file']) ||
(!strlen(trim($this->config['watermark']['file'])))
) && (
(
!$this->config['maxImageWidth'] &&
!$this->config['maxImageHeight']
) || (
($img->width <= $this->config['maxImageWidth']) &&
($img->height <= $this->config['maxImageHeight'])
)
) &&
($orientation == 1)
)
return true;
// PROPORTIONAL RESIZE
if ((!$this->config['maxImageWidth'] || !$this->config['maxImageHeight'])) {
if ($this->config['maxImageWidth']) {
if ($this->config['maxImageWidth'] >= $gd->get_width())
return true;
if ($this->config['maxImageWidth'] &&
($this->config['maxImageWidth'] < $img->width)
) {
$width = $this->config['maxImageWidth'];
$height = $gd->get_prop_height($width);
} else {
if ($this->config['maxImageHeight'] >= $gd->get_height())
return true;
$height = $img->getPropHeight($width);
} elseif (
$this->config['maxImageHeight'] &&
($this->config['maxImageHeight'] < $img->height)
) {
$height = $this->config['maxImageHeight'];
$width = $gd->get_prop_width($height);
$width = $img->getPropWidth($height);
}
if (!$gd->resize($width, $height))
if (isset($width) && isset($height) && !$img->resize($width, $height))
return false;
} elseif (!$gd->resize_fit(
$this->config['maxImageWidth'], $this->config['maxImageHeight']
))
// RESIZE TO FIT
} elseif (
$this->config['maxImageWidth'] && $this->config['maxImageHeight'] &&
!$img->resizeFit($this->config['maxImageWidth'], $this->config['maxImageHeight'])
)
return false;
return $gd->imagejpeg($file, $this->config['jpegQuality']);
// AUTO FLIP AND ROTATE FROM EXIF
if ((($orientation == 2) && !$img->flipHorizontal()) ||
(($orientation == 3) && !$img->rotate(180)) ||
(($orientation == 4) && !$img->flipVertical()) ||
(($orientation == 5) && (!$img->flipVertical() || !$img->rotate(90))) ||
(($orientation == 6) && !$img->rotate(90)) ||
(($orientation == 7) && (!$img->flipHorizontal() || !$img->rotate(90))) ||
(($orientation == 8) && !$img->rotate(270))
)
return false;
if (($orientation >= 2) && ($orientation <= 8) && ($this->imageDriver == "imagick"))
try {
$img->image->setImageProperty('exif:Orientation', "1");
} catch (Exception $e) {}
// WATERMARK
if (isset($this->config['watermark']['file']) &&
is_file($this->config['watermark']['file'])
) {
$left = isset($this->config['watermark']['left'])
? $this->config['watermark']['left'] : false;
$top = isset($this->config['watermark']['top'])
? $this->config['watermark']['top'] : false;
$img->watermark($this->config['watermark']['file'], $left, $top);
}
// WRITE TO FILE
return $img->output("jpeg", array(
'file' => $file,
'quality' => $this->config['jpegQuality']
));
}
protected function makeThumb($file, $overwrite=true) {
$gd = new gd($file);
$img = image::factory($this->imageDriver, $file);
// Drop files which are not GD handled images
if ($gd->init_error)
// Drop files which are not images
if ($img->initError)
return true;
$thumb = substr($file, strlen($this->config['uploadDir']));
......@@ -548,20 +623,23 @@ class uploader {
return true;
// Images with smaller resolutions than thumbnails
if (($gd->get_width() <= $this->config['thumbWidth']) &&
($gd->get_height() <= $this->config['thumbHeight'])
if (($img->width <= $this->config['thumbWidth']) &&
($img->height <= $this->config['thumbHeight'])
) {
$browsable = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG);
list($tmp, $tmp, $type) = @getimagesize($file);
// Drop only browsable types
if (in_array($gd->type, $browsable))
if (in_array($type, array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)))
return true;
// Resize image
} elseif (!$gd->resize_fit($this->config['thumbWidth'], $this->config['thumbHeight']))
} elseif (!$img->resizeFit($this->config['thumbWidth'], $this->config['thumbHeight']))
return false;
// Save thumbnail
return $gd->imagejpeg($thumb, $this->config['jpegQuality']);
return $img->output("jpeg", array(
'file' => $thumb,
'quality' => $this->config['jpegQuality']
));
}
protected function localize($langCode) {
......
......@@ -4,7 +4,7 @@
*
* @desc Base CSS definitions
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......
......@@ -4,7 +4,7 @@
*
* @desc CMS integration code: Drupal
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Dany Alejandro Cabrera <otello2040@gmail.com>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......
......@@ -4,7 +4,7 @@
*
* @desc Base JavaScript object properties
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......
......@@ -4,7 +4,7 @@
*
* @desc Clipboard functionality
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......
......@@ -4,7 +4,7 @@
*
* @desc Upload files using drag and drop
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Forum user (updated by Pavel Tzonkov)
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......@@ -216,10 +216,11 @@ browser.initDropUpload = function() {
filesCount = 0;
var loop = setInterval(function() {
if (uploadInProgress) return;
boundary = '------multipartdropuploadboundary' + (new Date).getTime();
uploadQueue = [];
clearInterval(loop);
if (currentFile.thisTargetDir == browser.dir)
browser.refresh();
boundary = '------multipartdropuploadboundary' + (new Date).getTime();
if (errors.length) {
browser.alert(errors.join('\n'));
errors = [];
......
......@@ -4,7 +4,7 @@
*
* @desc File related functionality
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......
......@@ -4,7 +4,7 @@
*
* @desc Folder related functionality
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......
......@@ -4,7 +4,7 @@
*
* @desc Object initializations
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......
......@@ -4,7 +4,7 @@
*
* @desc Join all JavaScript files in current directory
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......@@ -12,7 +12,7 @@
* @link http://kcfinder.sunhater.com
*/
chdir(".."); // For compatibality
chdir(".."); // For compatibility
chdir("..");
require "lib/helper_httpCache.php";
require "lib/helper_dir.php";
......
......@@ -4,7 +4,7 @@
*
* @desc Miscellaneous functionality
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......
......@@ -4,7 +4,7 @@
*
* @desc Settings panel functionality
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......
......@@ -4,7 +4,7 @@
*
* @desc Toolbar functionality
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......
......@@ -2,7 +2,7 @@
*
* @desc Helper object
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......
......@@ -4,7 +4,7 @@
*
* @desc Load language labels into JavaScript
* @package KCFinder
* @version 2.51
* @version 2.52-dev
* @author Pavel Tzonkov <pavelc@users.sourceforge.net>
* @copyright 2010, 2011 KCFinder Project
* @license http://www.opensource.org/licenses/gpl-2.0.php GPLv2
......
<?php
/** Afrikaans localization file for KCFinder
*/
$lang = array(
'_locale' => "af-ZA.UTF-8",
'_charset' => "utf-8",
// Date time formats. See http://www.php.net/manual/en/function.strftime.php
'_dateTimeFull' => "%d %B %Y %H:%M",
'_dateTimeMid' => "%d %b %Y %H:%M",
'_dateTimeSmall' => "%d %b %Y %H:%M",
"You don't have permissions to upload files." =>
"Jy het nie toestemming om lêers op te laai nie oplaai nie.",
"You don't have permissions to browse server." =>
"Jy het nie toestemming tot die bediener nie.",
"Cannot move uploaded file to target folder." =>
"Jy kannie die lêer beweeg na die gids toe nie.",
"Unknown error." =>
"Onbekende fout.",
"The uploaded file exceeds {size} bytes." =>
"Die foto's lêer oorskry {size} grepe.",
"The uploaded file was only partially uploaded." =>
"Die foto's lêer is slegs gedeeltelik opgelaai.",
"No file was uploaded." =>
"Geen lêer is opgelaai.",
"Missing a temporary folder." =>
"'N tydelike gids ontbreek.",
"Failed to write file." =>
"Misluk om lêer te kryf.",
"Denied file extension." =>
"Lêer uitbreiding verloën.",
"Unknown image format/encoding." =>
"Onbekende prentjie-formaat / kodering.",
"The image is too big and/or cannot be resized." =>
"Die beeld is te groot en / of kan nie verander word nie.",
"Cannot create {dir} folder." =>
"Kan nie {dir} gids skep nie.",
"Cannot write to upload folder." =>
"Kan nie skryf na die oplaai gids nie.",
"Cannot read .htaccess" =>
"Kan nie .htaccess lees nie.",
"Incorrect .htaccess file. Cannot rewrite it!" =>
"Verkeerde .htaccess lêer. Kan nie herskryf dit!",
"Cannot fetch content of {dir} folder." =>
"Kan nie haal inhoud van {dir} gids nie.",
"Cannot read upload folder." =>
"Kan nie oplaai gids lees nie.",
"Cannot access or create thumbnails folder." =>
"Kan nie toegang tot of duimnaels gids skep.",
"Cannot access or write to upload folder." =>
"Kan nie toegang tot of skryf na oplaai gids nie.",
"Please enter new folder name." =>
"Gee die nuwe gidsnaam.",
"Unallowed characters in folder name." =>
"Ongeoorloofd karakters in gidsnaam.",
"Folder name shouldn't begins with '.'" =>
"Gidsnaam moet nie begin met '.'",
"Please enter new file name." =>
"Gee nuwe lêernaam.",
"Unallowed characters in file name." =>
"Ongeoorloofd karakters in die lêernaam.",
"File name shouldn't begins with '.'" =>
"Lêer naam moet nie begin met '.'",
"Are you sure you want to delete this file?" =>
"Is jy seker jy wil hierdie lêer te verwyder ?",
"Are you sure you want to delete this folder and all its content?" =>
"Is jy seker jy wil hierdie gids en al die inhoud daarin te verwyder ?",
"Unexisting directory type." =>
"Nie Bestaande gids tipe.",
"Undefined MIME types." =>
"Ongedefinieerd MIME-tipes.",
"Fileinfo PECL extension is missing." =>
"Fileinfo PECL uitbreiding is weg.",
"Opening fileinfo database failed." =>
"Opening van fileinfo databasis het misluk.",
"You can't upload such files." =>
"Jy kan nie sulke lêers oplaai.",
"The file '{file}' does not exist." =>
"Die lêer '{file}' bestaan ​​nie.",
"Cannot read '{file}'." =>
"Kan nie '{lêer}' lees nie.",
"Cannot copy '{file}'." =>
"Kan nie '{lêer}' kopieer nie.",
"Cannot move '{file}'." =>
"Kan nie '{lêer}' beweeg nie.",
"Cannot delete '{file}'." =>
"Kan nie '{lêer}' verwyder .",
"Click to remove from the Clipboard" =>
"Klik om te verwyder van die Klembord",
"This file is already added to the Clipboard." =>
"Hierdie lêer is reeds aan die Klembord bygevoeg.",
"Copy files here" =>
"Kopieer lêers hier",
"Move files here" =>
"Skuif lêers hier",
"Delete files" =>
"Verwyder lêers ",
"Clear the Clipboard" => //
"Vee Klembord Skoon",
"Are you sure you want to delete all files in the Clipboard?" =>
"Is jy seker jy wil al die lêers in die Klembord te verwyder?",
"Copy {count} files" =>
"Kopieer {count} lêers",
"Move {count} files" =>
"Beweeg {count} lêers",
"Add to Clipboard" =>
"Voeg na klembord",
"New folder name:" => "Nuwe gids naam:",
"New file name:" => "Nuwe lêer naam:",
"Folders" => "Gidse",
"Upload" => "Oplaai",
"Refresh" => "Herlaai",
"Settings" => "Stellings",
"Maximize" => "Maksimaliseer",
"About" => "About",
"files" => "lêers",
"View:" => "Bekyk:",
"Show:" => "Wys:",
"Order by:" => "Sorteer volgens:",
"Thumbnails" => "Duimnaels",
"List" => "Lys",
"Name" => "Naam",
"Size" => "Grootte",
"Date" => "Datum",
"Descending" => "Aflopend",
"Uploading file..." => "Lêer Besig Met Oplaai...",
"Loading image..." => "Besig om beeld te laai...",
"Loading folders..." => "Besig om Gidse te laai...",
"Loading files..." => "Besig om Lêers te laai...",
"New Subfolder..." => "Nuwe subgids...",
"Rename..." => "Naam verander...",
"Delete" => "Verwyder",
"OK" => "REG",
"Cancel" => "Kanselleer",
"Select" => "Kies",
"Select Thumbnail" => "Kies Duimnaelskets",
"View" => "Bekyk",
"Download" => "Aflaai",
'Clipboard' => "Klembord",
// VERSION 2 NEW LABELS
"Cannot rename the folder." =>
"Kan nie die gids naam vernader nie.",
"Non-existing directory type." =>
"Nie-bestaande gids tipe.",
"Cannot delete the folder." =>