primo commit

This commit is contained in:
2024-12-17 17:34:10 +01:00
commit e650f8df99
16435 changed files with 2451012 additions and 0 deletions

View File

@ -0,0 +1,204 @@
<?php
/**
* @package Phoca Gallery
* @author Jan Pavelka - https://www.phoca.cz
* @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later
* @cms Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Factory;
jimport( 'joomla.filesystem.folder' );
jimport( 'joomla.filesystem.file' );
phocagalleryimport('phocagallery.image.image');
phocagalleryimport('phocagallery.path.path');
class PhocaGalleryFile
{
public static function getTitleFromFile(&$filename, $displayExt = 0) {
if (!isset($filename)) {
$filename = '';
}
$filename = str_replace('//', '/', $filename);
$filename = str_replace('\\', '/', $filename);
$folderArray = explode('/', $filename);// Explode the filename (folder and file name)
$countFolderArray = count($folderArray);// Count this array
$lastArrayValue = $countFolderArray - 1;// The last array value is (Count array - 1)
$title = new stdClass();
$title->with_extension = $folderArray[$lastArrayValue];
$title->without_extension = PhocaGalleryFile::removeExtension($folderArray[$lastArrayValue]);
if ($displayExt == 1) {
return $title->with_extension;
} else if ($displayExt == 0) {
return $title->without_extension;
} else {
return $title;
}
}
public static function removeExtension($filename) {
return substr($filename, 0, strrpos( $filename, '.' ));
}
public static function getMimeType($filename) {
$ext = File::getExt($filename);
switch(strtolower($ext)) {
case 'png':
$mime = 'image/png';
break;
case 'jpg':
case 'jpeg':
$mime = 'image/jpeg';
break;
case 'gif':
$mime = 'image/gif';
break;
case 'webp':
$mime = 'image/webp';
break;
case 'avif':
$mime = 'image/avif';
break;
Default:
$mime = '';
break;
}
return $mime;
}
public static function getFileSize($filename, $readable = 1) {
$path = PhocaGalleryPath::getPath();
$fileNameAbs = Path::clean($path->image_abs . $filename);
if (!File::exists($fileNameAbs)) {
$fileNameAbs = $path->image_abs_front . 'phoca_thumb_l_no_image.png';
}
if ($readable == 1) {
return PhocaGalleryFile::getFileSizeReadable(filesize($fileNameAbs));
} else {
return filesize($fileNameAbs);
}
}
/*
* http://aidanlister.com/repos/v/function.size_readable.php
*/
public static function getFileSizeReadable ($size, $retstring = null, $onlyMB = false) {
if ($onlyMB) {
$sizes = array('B', 'kB', 'MB');
} else {
$sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
}
if ($retstring === null) { $retstring = '%01.2f %s'; }
$lastsizestring = end($sizes);
foreach ($sizes as $sizestring) {
if ($size < 1024) { break; }
if ($sizestring != $lastsizestring) { $size /= 1024; }
}
if ($sizestring == $sizes[0]) { $retstring = '%01d %s'; } // Bytes aren't normally fractional
return sprintf($retstring, $size, $sizestring);
}
public static function getFileOriginal($filename, $rel = 0) {
$path = PhocaGalleryPath::getPath();
if ($rel == 1) {
return str_replace('//', '/', $path->image_rel . $filename);
} else {
return Path::clean($path->image_abs . $filename);
}
}
public static function getFileFormat($filename) {
$path = PhocaGalleryPath::getPath();
$file = Path::clean($path->image_abs . $filename);
$size = getimagesize($file);
if (isset($size[0]) && isset($size[1]) && (int)$size[1] > (int)$size[0]) {
return 2;
} else {
return 1;
}
}
public static function existsFileOriginal($filename) {
$fileOriginal = PhocaGalleryFile::getFileOriginal($filename);
if (File::exists($fileOriginal)) {
return true;
} else {
return false;
}
}
public static function deleteFile ($filename) {
$fileOriginal = PhocaGalleryFile::getFileOriginal($filename);
if (File::exists($fileOriginal)){
File::delete($fileOriginal);
return true;
}
return false;
}
public static function existsCss($file, $type) {
$path = self::getCSSPath($type);
if (file_exists($path.$file) && $file != '') {
return $path.$file;
}
return false;
}
public static function getCSSPath($type, $rel = 0) {
$paths = PhocaGalleryPath::getPath();
if ($rel == 1) {
if ($type == 1) {
return $paths->media_css_rel . 'main/';
} else {
return $paths->media_css_rel . 'custom/';
}
} else {
if ($type == 1) {
return Path::clean($paths->media_css_abs . 'main/');
} else {
return Path::clean($paths->media_css_abs . 'custom/');
}
}
}
public static function getCSSFile($id = 0, $fullPath = 0) {
if ((int)$id > 0) {
$db = Factory::getDBO();
$query = 'SELECT a.filename as filename, a.type as type'
.' FROM #__phocagallery_styles AS a'
.' WHERE a.id = '.(int) $id
.' ORDER BY a.id';
$db->setQuery($query, 0, 1);
$filename = $db->loadObject();
if (isset($filename->filename) && $filename->filename != '') {
if ($fullPath == 1 && isset($filename->type)) {
return self::getCSSPath($filename->type). $filename->filename;
} else {
return $filename->filename;
}
}
}
return false;
}
}
?>

View File

@ -0,0 +1,124 @@
<?php
/**
* @package Phoca Gallery
* @author Jan Pavelka - https://www.phoca.cz
* @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later
* @cms Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Filesystem\File;
jimport( 'joomla.filesystem.folder' );
jimport( 'joomla.filesystem.file' );
class PhocaGalleryFileDownload
{
public static function download($item, $backLink, $extLink = 0) {
// If you comment or remove the following line, user will be able to download external images
// but it can happen that such will be stored on your server in root (the example is picasa images)
$extLink = 0;
$app = Factory::getApplication();
if (empty($item)) {
$msg = Text::_('COM_PHOCAGALLERY_ERROR_DOWNLOADING_FILE');
$app->enqueueMessage($msg, 'error');
$app->redirect($backLink);
return false;
} else {
if ($extLink == 0) {
phocagalleryimport('phocagallery.file.file');
$fileOriginal = PhocaGalleryFile::getFileOriginal($item->filenameno);
if (!File::exists($fileOriginal)) {
$msg = Text::_('COM_PHOCAGALLERY_ERROR_DOWNLOADING_FILE');
$app->enqueueMessage($msg, 'error');
$app->redirect($backLink);
return false;
}
$fileToDownload = $item->filenameno;
$fileNameToDownload = $item->filename;
} else {
$fileToDownload = $item->exto;
$fileNameToDownload = $item->title;
$fileOriginal = $item->exto;
}
// Clears file status cache
clearstatcache();
$fileOriginal = $fileOriginal;
$fileSize = @filesize($fileOriginal);
$mimeType = PhocaGalleryFile::getMimeType($fileToDownload);
$fileName = $fileNameToDownload;
if ($extLink > 0) {
$content = '';
if (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $fileOriginal);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$downloadedFile = fopen($fileName, 'w+');
curl_setopt($ch, CURLOPT_FILE, $downloadedFile);
$content = curl_exec ($ch);
$fileSize= strlen($content);
curl_close ($ch);
fclose($downloadedFile);
}
if ($content != '') {
// Clean the output buffer
ob_end_clean();
header("Cache-Control: public, must-revalidate");
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header("Pragma: no-cache");
header("Expires: 0");
header("Content-Description: File Transfer");
header("Expires: Sat, 30 Dec 1990 07:07:07 GMT");
header("Content-Type: " . (string)$mimeType);
header("Content-Length: ". (string)$fileSize);
header('Content-Disposition: attachment; filename="'.$fileName.'"');
header("Content-Transfer-Encoding: binary\n");
echo $content;
exit;
}
} else {
// Clean the output buffer
ob_end_clean();
header("Cache-Control: public, must-revalidate");
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
header("Pragma: no-cache");
header("Expires: 0");
header("Content-Description: File Transfer");
header("Expires: Sat, 30 Dec 1990 07:07:07 GMT");
header("Content-Type: " . (string)$mimeType);
// Problem with IE
if ($extLink == 0) {
header("Content-Length: ". (string)$fileSize);
}
header('Content-Disposition: attachment; filename="'.$fileName.'"');
header("Content-Transfer-Encoding: binary\n");
@readfile($fileOriginal);
exit;
}
}
return false;
}
}
?>

View File

@ -0,0 +1,147 @@
<?php
/**
* @package Phoca Gallery
* @author Jan Pavelka - https://www.phoca.cz
* @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later
* @cms Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Component\ComponentHelper;
jimport( 'joomla.filesystem.folder' );
jimport( 'joomla.filesystem.file' );
phocagalleryimport('phocagallery.image.image');
phocagalleryimport('phocagallery.path.path');
class PhocaGalleryFileFolder
{
/*
* Clear Thumbs folder - if there are files in the thumbs directory but not original files e.g.:
* phoca_thumbs_l_some.jpg exists in thumbs directory but some.jpg doesn't exists - delete it
*/
public static function cleanThumbsFolder() {
//Get folder variables from Helper
$path = PhocaGalleryPath::getPath();
// Initialize variables
$pathOrigImg = $path->image_abs;
$pathOrigImgServer = str_replace('\\', '/', $path->image_abs);
// Get the list of files and folders from the given folder
$fileList = Folder::files($pathOrigImg, '', true, true);
// Iterate over the files if they exist
if ($fileList !== false) {
foreach ($fileList as $file) {
if (File::exists($file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') {
//Clean absolute path
$file = str_replace('\\', '/', Path::clean($file));
$positions = strpos($file, "phoca_thumb_s_");//is there small thumbnail
$positionm = strpos($file, "phoca_thumb_m_");//is there medium thumbnail
$positionl = strpos($file, "phoca_thumb_l_");//is there large thumbnail
//Clean small thumbnails if original file doesn't exist
if ($positions === false) {}
else {
$filenameThumbs = $file;//only thumbnails will be listed
$fileNameOrigs = str_replace ('thumbs/phoca_thumb_s_', '', $file);//get fictive original files
//There is Thumbfile but not Originalfile - we delete it
if (File::exists($filenameThumbs) && !File::exists($fileNameOrigs)) {
File::delete($filenameThumbs);
}
// Reverse
// $filenameThumb = PhocaGalleryHelper::getTitleFromFilenameWithExt($file);
// $fileNameOriginal = PhocaGalleryHelper::getTitleFromFilenameWithExt($file);
// $filenameThumb = str_replace ($fileNameOriginal, 'thumbs/phoca_thumb_m_' . $fileNameOriginal, $file);
}
//Clean medium thumbnails if original file doesn't exist
if ($positionm === false) {}
else {
$filenameThumbm = $file;//only thumbnails will be listed
$fileNameOrigm = str_replace ('thumbs/phoca_thumb_m_', '', $file);//get fictive original files
//There is Thumbfile but not Originalfile - we delete it
if (File::exists($filenameThumbm) && !File::exists($fileNameOrigm)) {
File::delete($filenameThumbm);
}
}
//Clean large thumbnails if original file doesn't exist
if ($positionl === false) {}
else {
$filenameThumbl = $file;//only thumbnails will be listed
$fileNameOrigl = str_replace ('thumbs/phoca_thumb_l_', '', $file);//get fictive original files
//There is Thumbfile but not Originalfile - we delete it
if (File::exists($filenameThumbl) && !File::exists($fileNameOrigl)) {
File::delete($filenameThumbl);
}
}
}
}
}
}
public static function createFolder($folder, &$errorMsg) {
$paramsC = ComponentHelper::getParams('com_phocagallery');
$folder_permissions = $paramsC->get( 'folder_permissions', 0755 );
// Doesn't work on some servers
//$folder_permissions = octdec((int)$folder_permissions);
$path = PhocaGalleryPath::getPath();
$folder = Path::clean($path->image_abs . $folder);
if (strlen($folder) > 0) {
if (!Folder::exists($folder) && !File::exists($folder)) {
// Because of problems on some servers:
// It is temporary solution
switch((int)$folder_permissions) {
case 777:
Folder::create($folder, 0777 );
break;
case 705:
Folder::create($folder, 0705 );
break;
case 666:
Folder::create($folder, 0666 );
break;
case 644:
Folder::create($folder, 0644 );
break;
case 755:
Default:
Folder::create($folder, 0755 );
break;
}
//JFolder::create($folder, $folder_permissions );
if (isset($folder)) {
$data = "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>";
File::write($folder. '/'. "index.html", $data);
}
// folder was not created
if (!Folder::exists($folder)) {
$errorMsg = "CreatingFolder";
return false;
}
} else {
$errorMsg = "FolderExists";
return false;
}
} else {
$errorMsg = "FolderNameEmpty";
return false;
}
return true;
}
}
?>

View File

@ -0,0 +1,127 @@
<?php
/**
* @package Phoca Gallery
* @author Jan Pavelka - https://www.phoca.cz
* @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later
* @cms Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Object\CMSObject;
jimport( 'joomla.filesystem.folder' );
jimport( 'joomla.filesystem.file' );
phocagalleryimport('phocagallery.image.image');
phocagalleryimport('phocagallery.path.path');
phocagalleryimport('phocagallery.file.filefolder');
setlocale(LC_ALL, 'C.UTF-8', 'C');
class PhocaGalleryFileFolderList
{
public static function getList($small = 0, $medium = 0, $large = 0, $refreshUrl = '') {
static $list;
$params = ComponentHelper::getParams( 'com_phocagallery' );
$clean_thumbnails = $params->get( 'clean_thumbnails', 0 );
// Only process the list once per request
if (is_array($list)) {
return $list;
}
// Get current path from request
$current = Factory::getApplication()->input->get('folder', '', 'path');
// If undefined, set to empty
if ($current == 'undefined') {
$current = '';
}
//Get folder variables from Helper
$path = PhocaGalleryPath::getPath();
// Initialize variables
if (strlen($current) > 0) {
$origPath = Path::clean($path->image_abs.$current);
} else {
$origPath = $path->image_abs;
}
$origPathServer = str_replace('\\', '/', $path->image_abs);
$images = array ();
$folders = array ();
// Get the list of files and folders from the given folder
$fileList = Folder::files($origPath);
$folderList = Folder::folders($origPath, '', false, false, array(0 => 'thumbs'));
if(is_array($fileList) && !empty($fileList)) {
natcasesort($fileList);
}
$field = Factory::getApplication()->input->get('field');;
$refreshUrl = $refreshUrl . '&folder='.$current.'&field='.$field;
// Iterate over the files if they exist
//file - abc.img, file_no - folder/abc.img
if ($fileList !== false) {
foreach ($fileList as $file) {
$ext = strtolower(File::getExt($file));
// Don't display thumbnails from defined files (don't save them into a database)...
$dontCreateThumb = PhocaGalleryFileThumbnail::dontCreateThumb($file);
if ($dontCreateThumb == 1) {
$ext = '';// WE USE $ext FOR NOT CREATE A THUMBNAIL CLAUSE
}
if ($ext == 'jpg' || $ext == 'png' || $ext == 'gif' || $ext == 'jpeg' || $ext == 'webp' || $ext == 'avif') {
if (File::exists($origPath. '/'. $file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') {
//Create thumbnails small, medium, large
$fileNo = $current . "/" . $file;
$fileThumb = PhocaGalleryFileThumbnail::getOrCreateThumbnail($fileNo, $refreshUrl, $small, $medium, $large);
$tmp = new CMSObject();
$tmp->name = $fileThumb['name'];
$tmp->nameno = $fileThumb['name_no'];
$tmp->linkthumbnailpath = $fileThumb['thumb_name_m_no_rel'];
$tmp->linkthumbnailpathabs = $fileThumb['thumb_name_m_no_abs'];
$images[] = $tmp;
}
}
}
}
//Clean Thumbs Folder if there are thumbnail files but not original file
if ($clean_thumbnails == 1) {
PhocaGalleryFileFolder::cleanThumbsFolder();
}
// - - - - - - - - - - - -
// Iterate over the folders if they exist
if ($folderList !== false) {
foreach ($folderList as $folder) {
$tmp = new CMSObject();
$tmp->name = basename($folder);
$tmp->path_with_name = str_replace('\\', '/', Path::clean($origPath . '/'. $folder));
$tmp->path_without_name_relative= $path->image_abs . str_replace($origPathServer, '', $tmp->path_with_name);
$tmp->path_with_name_relative_no= str_replace($origPathServer, '', $tmp->path_with_name);
$folders[] = $tmp;
}
}
$list = array('folders' => $folders, 'Images' => $images);
return $list;
}
}
?>

View File

@ -0,0 +1,675 @@
<?php
/**
* @package Phoca Gallery
* @author Jan Pavelka - https://www.phoca.cz
* @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later
* @cms Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Filesystem\Folder;
jimport( 'joomla.filesystem.folder' );
jimport( 'joomla.filesystem.file' );
phocagalleryimport('phocagallery.path.path');
phocagalleryimport('phocagallery.file.file');
class PhocaGalleryFileThumbnail
{
/*
*Get thumbnailname
*/
public static function getThumbnailName($filename, $size) {
$path = PhocaGalleryPath::getPath();
$title = PhocaGalleryFile::getTitleFromFile($filename , 1);
$thumbName = new CMSObject();
switch ($size) {
case 'large':
$fileNameThumb = 'phoca_thumb_l_'. $title;
$thumbName->abs = Path::clean(str_replace($title, 'thumbs'. '/'. $fileNameThumb, $path->image_abs . $filename));
$thumbName->rel = str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename);
break;
case 'large1':
$fileNameThumb = 'phoca_thumb_l1_'. $title;
$thumbName->abs = Path::clean(str_replace($title, 'thumbs'. '/'. $fileNameThumb, $path->image_abs . $filename));
$thumbName->rel = str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename);
break;
case 'medium1':
$fileNameThumb = 'phoca_thumb_m1_'. $title;
$thumbName->abs = Path::clean(str_replace($title, 'thumbs' . '/'. $fileNameThumb, $path->image_abs . $filename));
$thumbName->rel = str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename);
break;
case 'medium2':
$fileNameThumb = 'phoca_thumb_m2_'. $title;
$thumbName->abs = Path::clean(str_replace($title, 'thumbs' . '/'. $fileNameThumb, $path->image_abs . $filename));
$thumbName->rel = str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename);
break;
case 'medium3':
$fileNameThumb = 'phoca_thumb_m3_'. $title;
$thumbName->abs = Path::clean(str_replace($title, 'thumbs' . '/'. $fileNameThumb, $path->image_abs . $filename));
$thumbName->rel = str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename);
break;
case 'medium':
$fileNameThumb = 'phoca_thumb_m_'. $title;
$thumbName->abs = Path::clean(str_replace($title, 'thumbs'. '/'. $fileNameThumb, $path->image_abs . $filename));
$thumbName->rel = str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename);
break;
case 'small1':
$fileNameThumb = 'phoca_thumb_s1_'. $title;
$thumbName->abs = Path::clean(str_replace($title, 'thumbs' . '/'. $fileNameThumb, $path->image_abs . $filename));
$thumbName->rel = str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename);
break;
case 'small2':
$fileNameThumb = 'phoca_thumb_s2_'. $title;
$thumbName->abs = Path::clean(str_replace($title, 'thumbs' . '/'. $fileNameThumb, $path->image_abs . $filename));
$thumbName->rel = str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename);
break;
case 'small3':
$fileNameThumb = 'phoca_thumb_s3_'. $title;
$thumbName->abs = Path::clean(str_replace($title, 'thumbs' . '/'. $fileNameThumb, $path->image_abs . $filename));
$thumbName->rel = str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename);
break;
default:
case 'small':
$fileNameThumb = 'phoca_thumb_s_'. $title;
$thumbName->abs = Path::clean(str_replace($title, 'thumbs' . '/'. $fileNameThumb, $path->image_abs . $filename));
$thumbName->rel = str_replace ($title, 'thumbs/' . $fileNameThumb, $path->image_rel . $filename);
break;
}
$thumbName->rel = str_replace('//', '/', $thumbName->rel);
return $thumbName;
}
public static function deleteFileThumbnail ($filename, $small=0, $medium=0, $large=0) {
if ($small == 1) {
$fileNameThumbS = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'small');
if (File::exists($fileNameThumbS->abs)) {
File::delete($fileNameThumbS->abs);
}
$fileNameThumbS = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'small1');
if (File::exists($fileNameThumbS->abs)) {
File::delete($fileNameThumbS->abs);
}
$fileNameThumbS = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'small2');
if (File::exists($fileNameThumbS->abs)) {
File::delete($fileNameThumbS->abs);
}
$fileNameThumbS = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'small3');
if (File::exists($fileNameThumbS->abs)) {
File::delete($fileNameThumbS->abs);
}
}
if ($medium == 1) {
$fileNameThumbM = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'medium');
if (File::exists($fileNameThumbM->abs)) {
File::delete($fileNameThumbM->abs);
}
$fileNameThumbM = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'medium1');
if (File::exists($fileNameThumbM->abs)) {
File::delete($fileNameThumbM->abs);
}
$fileNameThumbM = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'medium2');
if (File::exists($fileNameThumbM->abs)) {
File::delete($fileNameThumbM->abs);
}
$fileNameThumbM = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'medium3');
if (File::exists($fileNameThumbM->abs)) {
File::delete($fileNameThumbM->abs);
}
}
if ($large == 1) {
$fileNameThumbL = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'large');
if (File::exists($fileNameThumbL->abs)) {
File::delete($fileNameThumbL->abs);
}
$fileNameThumbL = PhocaGalleryFileThumbnail::getThumbnailName ($filename, 'large1');
if (File::exists($fileNameThumbL->abs)) {
File::delete($fileNameThumbL->abs);
}
}
return true;
}
/*
* Main Thumbnail creating function
*
* file = abc.jpg
* fileNo = folder/abc.jpg
* if small, medium, large = 1, create small, medium, large thumbnail
*/
public static function getOrCreateThumbnail($fileNo, $refreshUrl, $small = 0, $medium = 0, $large = 0, $frontUpload = 0) {
if ($frontUpload) {
$returnFrontMessage = '';
}
$onlyThumbnailInfo = 0;
if ($small == 0 && $medium == 0 && $large == 0) {
$onlyThumbnailInfo = 1;
}
$paramsC = ComponentHelper::getParams('com_phocagallery');
$additional_thumbnails = $paramsC->get( 'additional_thumbnails',0 );
$path = PhocaGalleryPath::getPath();
$origPathServer = str_replace('//', '/', $path->image_abs);
$file['name'] = PhocaGalleryFile::getTitleFromFile($fileNo, 1);
$file['name_no'] = ltrim($fileNo, '/');
$file['name_original_abs'] = PhocaGalleryFile::getFileOriginal($fileNo);
$file['name_original_rel'] = PhocaGalleryFile::getFileOriginal($fileNo, 1);
$file['path_without_file_name_original']= str_replace($file['name'], '', $file['name_original_abs']);
$file['path_without_file_name_thumb'] = str_replace($file['name'], '', $file['name_original_abs'] . 'thumbs' . '/');
//$file['path_without_name'] = str_replace('\\', '/', JPath::clean($origPathServer));
//$file['path_with_name_relative_no'] = str_replace($origPathServer, '', $file['name_original']);
/*
$file['path_with_name_relative'] = $path['orig_rel_ds'] . str_replace($origPathServer, '', $file['name_original']);
$file['path_with_name_relative_no'] = str_replace($origPathServer, '', $file['name_original']);
$file['path_without_name'] = str_replace('\\', '/', Path::clean($origPath.'/'));
$file['path_without_name_relative'] = $path['orig_rel_ds'] . str_replace($origPathServer, '', $file['path_without_name']);
$file['path_without_name_relative_no'] = str_replace($origPathServer, '', $file['path_without_name']);
$file['path_without_name_thumbs'] = $file['path_without_name'] .'thumbs';
$file['path_without_file_name_original'] = str_replace($file['name'], '', $file['name_original']);
$file['path_without_name_thumbs_no'] = str_replace($file['name'], '', $file['name_original'] .'thumbs');*/
$ext = strtolower(File::getExt($file['name']));
switch ($ext) {
case 'jpg':
case 'png':
case 'gif':
case 'jpeg':
case 'webp':
case 'avif':
//Get File thumbnails name
$thumbNameS = PhocaGalleryFileThumbnail::getThumbnailName ($fileNo, 'small');
$file['thumb_name_s_no_abs'] = $thumbNameS->abs;
$file['thumb_name_s_no_rel'] = $thumbNameS->rel;
$thumbNameM = PhocaGalleryFileThumbnail::getThumbnailName ($fileNo, 'medium');
$file['thumb_name_m_no_abs'] = $thumbNameM->abs;
$file['thumb_name_m_no_rel'] = $thumbNameM->rel;
$thumbNameL = PhocaGalleryFileThumbnail::getThumbnailName ($fileNo, 'large');
$file['thumb_name_l_no_abs'] = $thumbNameL->abs;
$file['thumb_name_l_no_rel'] = $thumbNameL->rel;
// Don't create thumbnails from watermarks...
$dontCreateThumb = PhocaGalleryFileThumbnail::dontCreateThumb($file['name']);
if ($dontCreateThumb == 1) {
$onlyThumbnailInfo = 1; // WE USE $onlyThumbnailInfo FOR NOT CREATE A THUMBNAIL CLAUSE
}
// We want only information from the pictures OR
if ( $onlyThumbnailInfo == 0 ) {
$thumbInfo = $fileNo;
//Create thumbnail folder if not exists
$errorMsg = 'ErrorCreatingFolder';
$creatingFolder = PhocaGalleryFileThumbnail::createThumbnailFolder($file['path_without_file_name_original'], $file['path_without_file_name_thumb'], $errorMsg );
switch ($errorMsg) {
case 'Success':
//case 'ThumbnailExists':
case 'DisabledThumbCreation':
//case 'OnlyInformation':
break;
Default:
// BACKEND OR FRONTEND
if ($frontUpload !=1) {
PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl, $errorMsg, $frontUpload);
exit;
} else {
$returnFrontMessage = $errorMsg;
}
break;
}
// Folder must exist
if (Folder::exists($file['path_without_file_name_thumb'])) {
// Thumbnails real size
$tRS = array();
$errorMsgS = $errorMsgM = $errorMsgL = '';
//Small thumbnail
if ($small == 1) {
$createSmall = PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], $thumbNameS->abs, 'small', $frontUpload, $errorMsgS);
if ($additional_thumbnails == 2 || $additional_thumbnails == 3 || $additional_thumbnails == 7) {
PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_s_', 'phoca_thumb_s1_', $thumbNameS->abs), 'small1', $frontUpload, $errorMsgS);
PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_s_', 'phoca_thumb_s2_', $thumbNameS->abs), 'small2', $frontUpload, $errorMsgS);
PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_s_', 'phoca_thumb_s3_', $thumbNameS->abs), 'small3', $frontUpload, $errorMsgS);
}
// Thumbnail real size
if ($createSmall && File::exists($thumbNameS->abs)) {
$size = getimagesize($thumbNameS->abs);
if (isset($size[0])) {
$tRS['s']['w'] = $size[0];
}
if (isset($size[1])) {
$tRS['s']['h'] = $size[1];
}
}
} else {
$errorMsgS = 'ThumbnailExists';// in case we only need medium or large, because of if clause bellow
}
//Medium thumbnail
if ($medium == 1) {
$createMedium = PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], $thumbNameM->abs, 'medium', $frontUpload, $errorMsgM);
if ($additional_thumbnails == 1 || $additional_thumbnails == 3 || $additional_thumbnails == 7) {
PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_m_', 'phoca_thumb_m1_', $thumbNameM->abs), 'medium1', $frontUpload, $errorMsgM);
PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_m_', 'phoca_thumb_m2_', $thumbNameM->abs), 'medium2', $frontUpload, $errorMsgM);
PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_m_', 'phoca_thumb_m3_', $thumbNameM->abs), 'medium3', $frontUpload, $errorMsgM);
}
// Thumbnail real size
if ($createMedium && File::exists($thumbNameM->abs)) {
$size = getimagesize($thumbNameM->abs);
if (isset($size[0])) {
$tRS['m']['w'] = $size[0];
}
if (isset($size[1])) {
$tRS['m']['h'] = $size[1];
}
}
} else {
$errorMsgM = 'ThumbnailExists'; // in case we only need small or large, because of if clause bellow
}
//Large thumbnail
if ($large == 1) {
$createLarge = PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], $thumbNameL->abs, 'large', $frontUpload, $errorMsgL);
if ($additional_thumbnails == 7) {
PhocaGalleryFileThumbnail::createFileThumbnail($file['name_original_abs'], str_replace('phoca_thumb_l_', 'phoca_thumb_l1_', $thumbNameL->abs), 'large1', $frontUpload, $errorMsgL);
}
// Thumbnail real size
if ($createLarge && File::exists($thumbNameL->abs)) {
$size = getimagesize($thumbNameL->abs);
if (isset($size[0])) {
$tRS['l']['w'] = $size[0];
}
if (isset($size[1])) {
$tRS['l']['h'] = $size[1];
}
}
} else {
$errorMsgL = 'ThumbnailExists'; // in case we only need small or medium, because of if clause bellow
}
// Error messages for all 3 thumbnails (if the message contains error string, we got error
// Other strings can be:
// - ThumbnailExists - do not display error message nor success page
// - OnlyInformation - do not display error message nor success page
// - DisabledThumbCreation - do not display error message nor success page
$creatingSError = $creatingMError = $creatingLError = false;
$creatingSError = preg_match("/Error/i", $errorMsgS);
$creatingMError = preg_match("/Error/i", $errorMsgM);
$creatingLError = preg_match("/Error/i", $errorMsgL);
// Add info about real thumbnail sizes into database
if ($creatingSError || $creatingMError || $creatingLError) {
} else {
if ((isset($createSmall) && $createSmall) || (isset($createMedium) && $createMedium) || (isset($createLarge) && $createLarge)) {
// Set it only when really new thumbnail was created
PhocaGalleryImage::updateRealThumbnailSizes($file['name_original_rel'], $tRS);
}
}
// BACKEND OR FRONTEND
if ($frontUpload != 1) {
// There is an error while creating thumbnail in m or in s or in l
if ($creatingSError || $creatingMError || $creatingLError) {
// if all or two errors appear, we only display the last error message
// because the errors in this case is the same
if ($errorMsgS != '') {
$creatingError = $errorMsgS;
}
if ($errorMsgM != '') {
$creatingError = $errorMsgM;
}
if ($errorMsgL != '') {
$creatingError = $errorMsgL;
}
PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl, $creatingError);exit;
} else if ($errorMsgS == '' && $errorMsgM == '' && $errorMsgL == '') {
PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl);exit;
} else if ($errorMsgS == '' && $errorMsgM == '' && $errorMsgL == 'ThumbnailExists') {
PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl);exit;
} else if ($errorMsgS == '' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == 'ThumbnailExists') {
PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl);exit;
} else if ($errorMsgS == '' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == '') {
PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl);exit;
} else if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == '') {
PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl);exit;
} else if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == '' && $errorMsgL == '') {
PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl);exit;
} else if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == '' && $errorMsgL == 'ThumbnailExists') {
PhocaGalleryRenderProcess::getProcessPage( $file['name'], $thumbInfo, $refreshUrl);exit;
}
} else {
// There is an error while creating thumbnail in m or in s or in l
if ($creatingSError || $creatingMError || $creatingLError) {
// if all or two errors appear, we only display the last error message
// because the errors in this case is the same
if ($errorMsgS != '') {
$creatingError = $errorMsgS;
}
if ($errorMsgM != '') {
$creatingError = $errorMsgM;
}
if ($errorMsgL != '') {
$creatingError = $errorMsgL;
} // because the errors in this case is the same
$returnFrontMessage = $creatingError;
} else if ($errorMsgS == '' && $errorMsgM == '' && $errorMsgL == '') {
$returnFrontMessage = 'Success';
} else if ($errorMsgS == '' && $errorMsgM == '' && $errorMsgL == 'ThumbnailExists') {
$returnFrontMessage = 'Success';
} else if ($errorMsgS == '' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == 'ThumbnailExists') {
$returnFrontMessage = 'Success';
} else if ($errorMsgS == '' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == '') {
$returnFrontMessage = 'Success';
} else if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == 'ThumbnailExists' && $errorMsgL == '') {
$returnFrontMessage = 'Success';
} else if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == '' && $errorMsgL == '') {
$returnFrontMessage = 'Success';
} else if ($errorMsgS == 'ThumbnailExists' && $errorMsgM == '' && $errorMsgL == 'ThumbnailExists') {
$returnFrontMessage = 'Success';
}
}
if ($frontUpload == 1) {
return $returnFrontMessage;
}
}
}
break;
}
return $file;
}
public static function dontCreateThumb ($filename) {
$dontCreateThumb = false;
$dontCreateThumbArray = array ('watermark-large.png', 'watermark-medium.png');
foreach ($dontCreateThumbArray as $key => $value) {
if (strtolower($filename) == strtolower($value)) {
return true;
}
}
return false;
}
public static function createThumbnailFolder($folderOriginal, $folderThumbnail, &$errorMsg) {
$paramsC = ComponentHelper::getParams('com_phocagallery');
$enable_thumb_creation = $paramsC->get( 'enable_thumb_creation', 1 );
$folder_permissions = $paramsC->get( 'folder_permissions', 0755 );
//$folder_permissions = octdec((int)$folder_permissions);
// disable or enable the thumbnail creation
if ($enable_thumb_creation == 1) {
if (Folder::exists($folderOriginal)) {
if (strlen($folderThumbnail) > 0) {
$folderThumbnail = Path::clean($folderThumbnail);
if (!Folder::exists($folderThumbnail) && !File::exists($folderThumbnail)) {
switch((int)$folder_permissions) {
case 777:
Folder::create($folderThumbnail, 0777 );
break;
case 705:
Folder::create($folderThumbnail, 0705 );
break;
case 666:
Folder::create($folderThumbnail, 0666 );
break;
case 644:
Folder::create($folderThumbnail, 0644 );
break;
case 755:
Default:
Folder::create($folderThumbnail, 0755 );
break;
}
//JFolder::create($folderThumbnail, $folder_permissions );
if (isset($folderThumbnail)) {
$data = "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>";
File::write($folderThumbnail. '/'. "index.html", $data);
}
// folder was not created
if (!Folder::exists($folderThumbnail)) {
$errorMsg = 'ErrorCreatingFolder';
return false;
}
}
}
}
$errorMsg = 'Success';
return true;
} else {
$errorMsg = 'DisabledThumbCreation';
return false; // User have disabled the thumbanil creation e.g. because of error
}
}
public static function createFileThumbnail($fileOriginal, $fileThumbnail, $size, $frontUpload=0, &$errorMsg = '') {
$paramsC = ComponentHelper::getParams('com_phocagallery');
$enable_thumb_creation = $paramsC->get( 'enable_thumb_creation', 1);
$watermarkParams['create'] = $paramsC->get( 'create_watermark', 0 );// Watermark
$watermarkParams['x'] = $paramsC->get( 'watermark_position_x', 'center' );
$watermarkParams['y'] = $paramsC->get( 'watermark_position_y', 'middle' );
$crop_thumbnail = $paramsC->get( 'crop_thumbnail', 5);// Crop or not
$crop = null;
switch ($size) {
case 'small1':
case 'small2':
case 'small3':
case 'medium1':
case 'medium2':
case 'medium3':
case 'large1':
$crop = 1;
break;
case 'small':
if ($crop_thumbnail == 3 || $crop_thumbnail == 5 || $crop_thumbnail == 6 || $crop_thumbnail == 7 ) {
$crop = 1;
}
break;
case 'medium':
if ($crop_thumbnail == 2 || $crop_thumbnail == 4 || $crop_thumbnail == 5 || $crop_thumbnail == 7 ) {
$crop = 1;
}
break;
case 'large':
default:
if ($crop_thumbnail == 1 || $crop_thumbnail == 4 || $crop_thumbnail == 6 || $crop_thumbnail == 7 ) {
$crop = 1;
}
break;
}
// disable or enable the thumbnail creation
if ($enable_thumb_creation == 1) {
$fileResize = PhocaGalleryFileThumbnail::getThumbnailResize($size);
if (File::exists($fileOriginal)) {
//file doesn't exist, create thumbnail
if (!File::exists($fileThumbnail)) {
$errorMsg = 'Error4';
//Don't do thumbnail if the file is smaller (width, height) than the possible thumbnail
list($width, $height) = GetImageSize($fileOriginal);
//larger
phocagalleryimport('phocagallery.image.imagemagic');
if ($width > $fileResize['width'] || $height > $fileResize['height']) {
$imageMagic = PhocaGalleryImageMagic::imageMagic($fileOriginal, $fileThumbnail, $fileResize['width'] , $fileResize['height'], $crop, null, $watermarkParams, $frontUpload, $errorMsg);
} else {
$imageMagic = PhocaGalleryImageMagic::imageMagic($fileOriginal, $fileThumbnail, $width , $height, $crop, null, $watermarkParams, $frontUpload, $errorMsg);
}
if ($imageMagic) {
return true;
} else {
return false;// error Msg will be taken from imageMagic
}
} else {
$errorMsg = 'ThumbnailExists';//thumbnail exists
return false;
}
} else {
$errorMsg = 'ErrorFileOriginalNotExists';
return false;
}
$errorMsg = 'Error3';
return false;
} else {
$errorMsg = 'DisabledThumbCreation'; // User have disabled the thumbanil creation e.g. because of error
return false;
}
}
public static function getThumbnailResize($size = 'all') {
// Get width and height from Default settings
$params = ComponentHelper::getParams('com_phocagallery') ;
$large_image_width = $params->get( 'large_image_width', 640 );
$large_image_height = $params->get( 'large_image_height', 480 );
$medium_image_width = $params->get( 'medium_image_width', 256 );
$medium_image_height= $params->get( 'medium_image_height', 192 );
$small_image_width = $params->get( 'small_image_width', 128 );
$small_image_height = $params->get( 'small_image_height', 96 );
$additional_thumbnail_margin = $params->get( 'additional_thumbnail_margin', 0 );
switch ($size) {
case 'large':
$fileResize['width'] = $large_image_width;
$fileResize['height'] = $large_image_height;
break;
case 'medium':
$fileResize['width'] = $medium_image_width;
$fileResize['height'] = $medium_image_height;
break;
case 'medium1':
$fileResize['width'] = $medium_image_width;
$fileResize['height'] = ((int)$medium_image_height * 2) + (int)$additional_thumbnail_margin;
break;
case 'medium2':
$fileResize['width'] = (int)$medium_image_width * 2;
$fileResize['height'] = $medium_image_height;
break;
case 'medium3':
$fileResize['width'] = (int)$medium_image_width * 2;
$fileResize['height'] = (int)$medium_image_height * 2;
break;
case 'small':
$fileResize['width'] = $small_image_width;
$fileResize['height'] = $small_image_height;
break;
case 'small1':
$fileResize['width'] = $small_image_width;
$fileResize['height'] = (int)$small_image_height * 2;
break;
case 'small2':
$fileResize['width'] = (int)$small_image_width * 2;
$fileResize['height'] = $small_image_height;
break;
case 'small3':
$fileResize['width'] = (int)$small_image_width * 2;
$fileResize['height'] = (int)$small_image_height * 2;
break;
case 'large1':
$fileResize['width'] = $large_image_width;
$scale = (int)$large_image_height / $medium_image_height;
$fileResize['height'] = ((int)$large_image_height * 2) + ((int)$additional_thumbnail_margin * $scale);
break;
default:
case 'all':
$fileResize['smallwidth'] = $small_width;
$fileResize['smallheight'] = $small_height;
$fileResize['mediumwidth'] = $medium_width;
$fileResize['mediumheight'] = $medium_height;
$fileResize['largewidth'] = $large_width;
$fileResize['largeheight'] = $large_height;
break;
}
return $fileResize;
}
}
?>

View File

@ -0,0 +1,815 @@
<?php
/**
* @package Phoca Gallery
* @author Jan Pavelka - https://www.phoca.cz
* @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later
* @cms Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
use Joomla\CMS\Filesystem\File;
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Client\ClientHelper;
use Joomla\CMS\Filesystem\Path;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\HTML\HTMLHelper;
jimport( 'joomla.filesystem.folder' );
jimport( 'joomla.filesystem.file' );
phocagalleryimport( 'phocagallery.image.image');
phocagalleryimport( 'phocagallery.file.fileuploadfront' );
class PhocaGalleryFileUpload
{
public static function realMultipleUpload( $frontEnd = 0) {
$paramsC = ComponentHelper::getParams('com_phocagallery');
$chunkMethod = $paramsC->get( 'multiple_upload_chunk', 0 );
$uploadMethod = $paramsC->get( 'multiple_upload_method', 4 );
$app = Factory::getApplication();
$app->allowCache(false);
// Chunk Files
header('Content-type: text/plain; charset=UTF-8');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
// Invalid Token
Session::checkToken( 'request' ) or jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 100,
'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ',
'details' => Text::_('COM_PHOCAGALLERY_INVALID_TOKEN'))));
// Set FTP credentials, if given
$ftp = ClientHelper::setCredentialsFromRequest('ftp');
$path = PhocaGalleryPath::getPath();
$file = Factory::getApplication()->input->files->get( 'file', null );
$chunk = Factory::getApplication()->input->get( 'chunk', 0, '', 'int' );
$chunks = Factory::getApplication()->input->get( 'chunks', 0, '', 'int' );
$folder = Factory::getApplication()->input->get( 'folder', '', '', 'path' );
// Make the filename safe
if (isset($file['name'])) {
$file['name'] = File::makeSafe($file['name']);
}
if (isset($folder) && $folder != '') {
$folder = $folder . '/';
}
$chunkEnabled = 0;
// Chunk only if is enabled and only if flash is enabled
if (($chunkMethod == 1 && $uploadMethod == 1) || ($frontEnd == 0 && $chunkMethod == 0 && $uploadMethod == 1)) {
$chunkEnabled = 1;
}
if (isset($file['name'])) {
// - - - - - - - - - -
// Chunk Method
// - - - - - - - - - -
// $chunkMethod = 1, for frontend and backend
// $chunkMethod = 0, only for backend
if ($chunkEnabled == 1) {
// If chunk files are used, we need to upload parts to temp directory
// and then we can run e.g. the condition to recognize if the file already exists
// We must upload the parts to temp, in other case we get everytime the info
// that the file exists (because the part has the same name as the file)
// so after first part is uploaded, in fact the file already exists
// Example: NOT USING CHUNK
// If we upload abc.jpg file to server and there is the same file
// we compare it and can recognize, there is one, don't upload it again.
// Example: USING CHUNK
// If we upload abc.jpg file to server and there is the same file
// the part of current file will overwrite the same file
// and then (after all parts will be uploaded) we can make the condition to compare the file
// and we recognize there is one - ok don't upload it BUT the file will be damaged by
// parts uploaded by the new file - so this is why we are using temp file in Chunk method
$stream = Factory::getStream();// Chunk Files
$tempFolder = 'pgpluploadtmpfolder/';
$filepathImgFinal = Path::clean($path->image_abs.$folder.strtolower($file['name']));
$filepathImgTemp = Path::clean($path->image_abs.$folder.$tempFolder.strtolower($file['name']));
$filepathFolderFinal = Path::clean($path->image_abs.$folder);
$filepathFolderTemp = Path::clean($path->image_abs.$folder.$tempFolder);
$maxFileAge = 60 * 60; // Temp file age in seconds
$lastChunk = $chunk + 1;
$realSize = 0;
// Get the real size - if chunk is uploaded, it is only a part size, so we must compute all size
// If there is last chunk we can computhe the whole size
if ($lastChunk == $chunks) {
if (File::exists($filepathImgTemp) && File::exists($file['tmp_name'])) {
$realSize = filesize($filepathImgTemp) + filesize($file['tmp_name']);
}
}
// 5 minutes execution time
@set_time_limit(5 * 60);// usleep(5000);
// If the file already exists on the server:
// - don't copy the temp file to final
// - remove all parts in temp file
// Because some parts are uploaded before we can run the condition
// to recognize if the file already exists.
if (File::exists($filepathImgFinal)) {
if($lastChunk == $chunks){
@Folder::delete($filepathFolderTemp);
}
jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 108,
'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ',
'details' => Text::_('COM_PHOCAGALLERY_FILE_ALREADY_EXISTS'))));
}
if (!PhocaGalleryFileUpload::canUpload( $file, $errUploadMsg, $frontEnd, $chunkEnabled, $realSize )) {
// If there is some error, remove the temp folder with temp files
if($lastChunk == $chunks){
@Folder::delete($filepathFolderTemp);
}
jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 104,
'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ',
'details' => Text::_($errUploadMsg))));
}
// Ok create temp folder and add chunks
if (!Folder::exists($filepathFolderTemp)) {
@Folder::create($filepathFolderTemp);
}
// Remove old temp files
if (Folder::exists($filepathFolderTemp)) {
$dirFiles = Folder::files($filepathFolderTemp);
if (!empty($dirFiles)) {
foreach ($dirFiles as $fileS) {
$filePathImgS = $filepathFolderTemp . $fileS;
// Remove temp files if they are older than the max age
if (preg_match('/\\.tmp$/', $fileS) && (filemtime($filepathImgTemp) < time() - $maxFileAge)) {
@File::delete($filePathImgS);
}
}
}
} else {
jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 100,
'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ',
'details' => Text::_('COM_PHOCAGALLERY_ERROR_FOLDER_UPLOAD_NOT_EXISTS'))));
}
// Look for the content type header
if (isset($_SERVER["HTTP_CONTENT_TYPE"]))
$contentType = $_SERVER["HTTP_CONTENT_TYPE"];
if (isset($_SERVER["CONTENT_TYPE"]))
$contentType = $_SERVER["CONTENT_TYPE"];
if (strpos($contentType, "multipart") !== false) {
if (isset($file['tmp_name']) && is_uploaded_file($file['tmp_name'])) {
// Open temp file
$out = $stream->open($filepathImgTemp, $chunk == 0 ? "wb" : "ab");
//$out = fopen($filepathImgTemp, $chunk == 0 ? "wb" : "ab");
if ($out) {
// Read binary input stream and append it to temp file
$in = fopen($file['tmp_name'], "rb");
if ($in) {
while ($buff = fread($in, 4096)) {
$stream->write($buff);
//fwrite($out, $buff);
}
} else {
jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 101,
'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ',
'details' => Text::_('COM_PHOCAGALLERY_ERROR_OPEN_INPUT_STREAM'))));
}
$stream->close();
//fclose($out);
@File::delete($file['tmp_name']);
} else {
jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 102,
'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ',
'details' => Text::_('COM_PHOCAGALLERY_ERROR_OPEN_OUTPUT_STREAM'))));
}
} else {
jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 103,
'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ',
'details' => Text::_('COM_PHOCAGALLERY_ERROR_MOVE_UPLOADED_FILE'))));
}
} else {
// Open temp file
$out = $stream->open($filepathImgTemp, $chunk == 0 ? "wb" : "ab");
//$out = JFile::read($filepathImg);
if ($out) {
// Read binary input stream and append it to temp file
$in = fopen("php://input", "rb");
if ($in) {
while ($buff = fread($in, 4096)) {
$stream->write($buff);
}
} else {
jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 101,
'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ',
'details' => Text::_('COM_PHOCAGALLERY_ERROR_OPEN_INPUT_STREAM'))));
}
$stream->close();
//fclose($out);
} else {
jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 102,
'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ',
'details' => Text::_('COM_PHOCAGALLERY_ERROR_OPEN_OUTPUT_STREAM'))));
}
}
// Rename the Temp File to Final File
if($lastChunk == $chunks){
if(($imginfo = getimagesize($filepathImgTemp)) === FALSE) {
Folder::delete($filepathFolderTemp);
jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 110,
'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ',
'details' => Text::_('COM_PHOCAGALLERY_WARNING_INVALIDIMG'))));
}
if(!File::move($filepathImgTemp, $filepathImgFinal)) {
Folder::delete($filepathFolderTemp);
jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 109,
'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ',
'details' => Text::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_MOVE_FILE') .'<br />'
. Text::_('COM_PHOCAGALLERY_CHECK_PERMISSIONS_OWNERSHIP'))));
}
Folder::delete($filepathFolderTemp);
}
if ((int)$frontEnd > 0) {
return $file['name'];
}
jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'OK', 'code' => 200,
'message' => Text::_('COM_PHOCAGALLERY_SUCCESS').': ',
'details' => Text::_('COM_PHOCAGALLERY_IMAGES_UPLOADED'))));
} else {
// No Chunk Method
$filepathImgFinal = Path::clean($path->image_abs.$folder.strtolower($file['name']));
$filepathFolderFinal = Path::clean($path->image_abs.$folder);
if (!PhocaGalleryFileUpload::canUpload( $file, $errUploadMsg, $frontEnd, $chunkMethod, 0 )) {
jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 104,
'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ',
'details' => Text::_($errUploadMsg))));
}
if (File::exists($filepathImgFinal)) {
jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 108,
'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ',
'details' => Text::_('COM_PHOCAGALLERY_FILE_ALREADY_EXISTS'))));
}
if(!File::upload($file['tmp_name'], $filepathImgFinal, false, true)) {
jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 109,
'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ',
'details' => Text::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE') .'<br />'
. Text::_('COM_PHOCAGALLERY_CHECK_PERMISSIONS_OWNERSHIP'))));
}
if ((int)$frontEnd > 0) {
return $file['name'];
}
jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'OK', 'code' => 200,
'message' => Text::_('COM_PHOCAGALLERY_SUCCESS').': ',
'details' => Text::_('COM_PHOCAGALLERY_IMAGES_UPLOADED'))));
}
} else {
// No isset $file['name']
jexit(json_encode(array( 'jsonrpc' => '2.0', 'result' => 'error', 'code' => 104,
'message' => Text::_('COM_PHOCAGALLERY_ERROR').': ',
'details' => Text::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE'))));
}
}
public static function realSingleUpload( $frontEnd = 0 ) {
// $paramsC = JComponentHelper::getParams('com_phocagallery');
// $chunkMethod = $paramsC->get( 'multiple_upload_chunk', 0 );
// $uploadMethod = $paramsC->get( 'multiple_upload_method', 4 );
$app = Factory::getApplication();
Session::checkToken( 'request' ) or jexit( 'ERROR: '. Text::_('COM_PHOCAGALLERY_INVALID_TOKEN'));
$app->allowCache(false);
$path = PhocaGalleryPath::getPath();
$file = Factory::getApplication()->input->files->get( 'Filedata', null );
$folder = Factory::getApplication()->input->get( 'folder', '', '', 'path' );
$format = Factory::getApplication()->input->get( 'format', 'html', '', 'cmd');
$return = Factory::getApplication()->input->get( 'return-url', null, 'post', 'base64' );//includes field
$viewBack = Factory::getApplication()->input->get( 'viewback', '', '', '' );
$tab = Factory::getApplication()->input->get( 'tab', '', '', 'string' );
$field = Factory::getApplication()->input->get( 'field' );
$errUploadMsg = '';
$folderUrl = $folder;
$tabUrl = '';
$component = Factory::getApplication()->input->get( 'option', '', '', 'string' );
// In case no return value will be sent (should not happen)
if ($component != '' && $frontEnd == 0) {
$componentUrl = 'index.php?option='.$component;
} else {
$componentUrl = 'index.php';
}
if ($tab != '') {
$tabUrl = '&tab='.(string)$tab;
}
$ftp = ClientHelper::setCredentialsFromRequest('ftp');
// Make the filename safe
if (isset($file['name'])) {
$file['name'] = File::makeSafe($file['name']);
}
if (isset($folder) && $folder != '') {
$folder = $folder . '/';
}
// All HTTP header will be overwritten with js message
if (isset($file['name'])) {
$filepath = Path::clean($path->image_abs.$folder.strtolower($file['name']));
if (!PhocaGalleryFileUpload::canUpload( $file, $errUploadMsg, $frontEnd )) {
if ($errUploadMsg == 'COM_PHOCAGALLERY_WARNING_FILE_TOOLARGE') {
$errUploadMsg = Text::_($errUploadMsg) . ' ('.PhocaGalleryFile::getFileSizeReadable($file['size']).')';
} else if ($errUploadMsg == 'COM_PHOCAGALLERY_WARNING_FILE_TOOLARGE_RESOLUTION') {
$imgSize = PhocaGalleryImage::getImageSize($file['tmp_name']);
$errUploadMsg = Text::_($errUploadMsg) . ' ('.(int)$imgSize[0].' x '.(int)$imgSize[1].' px)';
} else {
$errUploadMsg = Text::_($errUploadMsg);
}
/*if ($return) {
$app->enqueueMessage( $errUploadMsg, 'error');
$app->redirect(base64_decode($return).'&folder='.$folderUrl);
exit;
} else {
$app->enqueueMessage( $errUploadMsg, 'error');
$app->redirect($componentUrl, $errUploadMsg, 'error');
exit;
}*/
if ($return) {
$app->enqueueMessage( $errUploadMsg, 'error');
if ($frontEnd > 0) {
$app->redirect(base64_decode($return));
} else {
$app->redirect(base64_decode($return).'&folder='.$folderUrl);
}
exit;
} else {
$app->enqueueMessage( $errUploadMsg, 'error');
$app->redirect($componentUrl);
exit;
}
}
if (File::exists($filepath)) {
if ($return) {
$app->enqueueMessage( Text::_('COM_PHOCAGALLERY_FILE_ALREADY_EXISTS'), 'error');
$app->redirect(base64_decode($return).'&folder='.$folderUrl);
exit;
} else {
$app->enqueueMessage(Text::_('COM_PHOCAGALLERY_FILE_ALREADY_EXISTS'), 'error');
$app->redirect($componentUrl);
exit;
}
}
if (!File::upload($file['tmp_name'], $filepath, false, true)) {
if ($return) {
$app->enqueueMessage( Text::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE'), 'error');
$app->redirect(base64_decode($return).'&folder='.$folderUrl);
exit;
} else {
$app->enqueueMessage( Text::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE'), 'error');
$app->redirect($componentUrl);
exit;
}
} else {
if ((int)$frontEnd > 0) {
return $file['name'];
}
if ($return) {
$app->enqueueMessage( Text::_('COM_PHOCAGALLERY_SUCCESS_FILE_UPLOAD'));
$app->redirect(base64_decode($return).'&folder='.$folderUrl);
exit;
} else {
$app->enqueueMessage( Text::_('COM_PHOCAGALLERY_SUCCESS_FILE_UPLOAD'));
$app->redirect($componentUrl);
exit;
}
}
} else {
$msg = Text::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE');
if ($return) {
$app->enqueueMessage( $msg);
$app->redirect(base64_decode($return).'&folder='.$folderUrl);
exit;
} else {
switch ($viewBack) {
case 'phocagalleryi':
$app->enqueueMessage( $msg, 'error');
$app->redirect('index.php?option=com_phocagallery&view=phocagalleryi&tmpl=component'.$tabUrl.'&folder='.$folder.'&field='.$field);
exit;
break;
case 'phocagallerym':
$app->enqueueMessage( $msg, 'error');
$app->redirect('index.php?option=com_phocagallery&view=phocagallerym&layout=form&hidemainmenu=1'.$tabUrl.'&folder='.$folder);
exit;
break;
default:
$app->enqueueMessage( $msg, 'error');
$app->redirect('index.php?option=com_phocagallery');
exit;
break;
}
}
}
}
public static function realJavaUpload( $frontEnd = 0 ) {
$app = Factory::getApplication();
Session::checkToken( 'request' ) or exit( 'ERROR: '. Text::_('COM_PHOCAGALLERY_INVALID_TOKEN'));
// $files = Factory::getApplication()->input->get( 'Filedata', '', 'files', 'array' );
$path = PhocaGalleryPath::getPath();
$folder = Factory::getApplication()->input->get( 'folder', '', '', 'path' );
if (isset($folder) && $folder != '') {
$folder = $folder . '/';
}
$errUploadMsg = '';
$ftp = ClientHelper::setCredentialsFromRequest('ftp');
foreach ($_FILES as $fileValue => $file) {
echo('File key: '. $fileValue . "\n");
foreach ($file as $item => $val) {
echo(' Data received: ' . $item.'=>'.$val . "\n");
}
// Make the filename safe
if (isset($file['name'])) {
$file['name'] = File::makeSafe($file['name']);
}
if (isset($file['name'])) {
$filepath = Path::clean($path->image_abs.$folder.strtolower($file['name']));
if (!PhocaGalleryFileUpload::canUpload( $file, $errUploadMsg, $frontEnd )) {
exit( 'ERROR: '.Text::_($errUploadMsg));
}
if (File::exists($filepath)) {
exit( 'ERROR: '.Text::_('COM_PHOCAGALLERY_FILE_ALREADY_EXISTS'));
}
if (!File::upload($file['tmp_name'], $filepath, false, true)) {
exit( 'ERROR: '.Text::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE'));
}
if ((int)$frontEnd > 0) {
return $file['name'];
}
exit( 'SUCCESS');
} else {
exit( 'ERROR: '.Text::_('COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE'));
}
}
return true;
}
/**
* can Upload
*
* @param array $file
* @param string $errorUploadMsg
* @param int $frontEnd - if it is called from frontend or backend (1 - category view, 2 user control panel)
* @param boolean $chunkMethod - if chunk method is used (multiple upload) then there are special rules
* @param string $realSize - if chunk method is used we get info about real size of file (not only the part)
* @return boolean True on success
* @since 1.5
*/
public static function canUpload( $file, &$errUploadMsg, $frontEnd = 0, $chunkEnabled = 0, $realSize = 0 ) {
$params = ComponentHelper::getParams( 'com_phocagallery' );
$paramsL = array();
$paramsL['upload_extensions'] = 'gif,jpg,png,jpeg,webp,avif';
$paramsL['image_extensions'] = 'gif,jpg,png,jpeg,webp,avif';
$paramsL['upload_mime'] = 'image/jpeg,image/gif,image/png,image/webp,image/avif';
$paramsL['upload_mime_illegal'] ='application/x-shockwave-flash,application/msword,application/excel,application/pdf,application/powerpoint,text/plain,application/x-zip,text/html';
// The file doesn't exist
if(empty($file['name'])) {
$errUploadMsg = 'COM_PHOCAGALLERY_ERROR_UNABLE_TO_UPLOAD_FILE';
return false;
}
// Not safe file
jimport('joomla.filesystem.file');
if ($file['name'] !== File::makesafe($file['name'])) {
$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_FILENAME';
return false;
}
$format = strtolower(File::getExt($file['name']));
// Allowable extension
$allowable = explode( ',', $paramsL['upload_extensions']);
if ($format == '' || $format == false || (!in_array($format, $allowable))) {
//if (!in_array($format, $allowable)) {
$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_FILETYPE';
return false;
}
// 'COM_PHOCAGALLERY_MAX_RESOLUTION'
$imgSize = PhocaGalleryImage::getImageSize($file['tmp_name']);
$maxResWidth = $params->get( 'upload_maxres_width', 3072 );
$maxResHeight = $params->get( 'upload_maxres_height', 2304 );
if (((int)$maxResWidth > 0 && (int)$maxResHeight > 0)
&& ((int)$imgSize[0] > (int)$maxResWidth || (int)$imgSize[1] > (int)$maxResHeight)) {
$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_FILE_TOOLARGE_RESOLUTION';
return false;
}
// User (only in ucp) - Check the size of all images by users
if ($frontEnd == 2) {
$user = Factory::getUser();
$maxUserImageSize = (int)$params->get( 'user_images_max_size', 20971520 );
if ($chunkEnabled == 1) {
$fileSize = $realSize;
} else {
$fileSize = $file['size'];
}
$allFileSize = PhocaGalleryFileUploadFront::getSizeAllOriginalImages($fileSize, $user->id);
if ((int)$maxUserImageSize > 0 && (int) $allFileSize > $maxUserImageSize) {
$errUploadMsg = Text::_('COM_PHOCAGALLERY_WARNING_USERIMAGES_TOOLARGE');
return false;
}
}
// Max size of image
// If chunk method is used, we need to get computed size
$maxSize = $params->get( 'upload_maxsize', 3145728 );
if ($chunkEnabled == 1) {
if ((int)$maxSize > 0 && (int)$realSize > (int)$maxSize) {
$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_FILE_TOOLARGE';
return false;
}
} else {
if ((int)$maxSize > 0 && (int)$file['size'] > (int)$maxSize) {
$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_FILE_TOOLARGE';
return false;
}
}
$user = Factory::getUser();
$imginfo = null;
// Image check
$images = explode( ',', $paramsL['image_extensions']);
if(in_array($format, $images)) { // if its an image run it through getimagesize
if ($chunkEnabled != 1) {
if(($imginfo = getimagesize($file['tmp_name'])) === FALSE) {
$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_INVALIDIMG';
return false;
}
}
} else if(!in_array($format, $images)) {
// if its not an image...and we're not ignoring it
$allowed_mime = explode(',', $paramsL['upload_mime']);
$illegal_mime = explode(',', $paramsL['upload_mime_illegal']);
if(function_exists('finfo_open')) {
// We have fileinfo
$finfo = finfo_open(FILEINFO_MIME);
$type = finfo_file($finfo, $file['tmp_name']);
if(strlen($type) && !in_array($type, $allowed_mime) && in_array($type, $illegal_mime)) {
$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_INVALIDMIME';
return false;
}
finfo_close($finfo);
} else if(function_exists('mime_content_type')) {
// we have mime magic
$type = mime_content_type($file['tmp_name']);
if(strlen($type) && !in_array($type, $allowed_mime) && in_array($type, $illegal_mime)) {
$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_INVALIDMIME';
return false;
}
}/* else if(!$user->authorize( 'login', 'administrator' )) {
$errUploadMsg = = 'WARNNOTADMIN';
return false;
}*/
}
// XSS Check
$xss_check = file_get_contents($file['tmp_name'], false, null, -1, 256);
$html_tags = array(
'abbr', 'acronym', 'address', 'applet', 'area', 'audioscope', 'base', 'basefont', 'bdo', 'bgsound', 'big', 'blackface', 'blink',
'blockquote', 'body', 'bq', 'br', 'button', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'comment', 'custom', 'dd', 'del',
'dfn', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'fn', 'font', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
'head', 'hr', 'html', 'iframe', 'ilayer', 'img', 'input', 'ins', 'isindex', 'keygen', 'kbd', 'label', 'layer', 'legend', 'li', 'limittext',
'link', 'listing', 'map', 'marquee', 'menu', 'meta', 'multicol', 'nobr', 'noembed', 'noframes', 'noscript', 'nosmartquotes', 'object',
'ol', 'optgroup', 'option', 'param', 'plaintext', 'pre', 'rt', 'ruby', 's', 'samp', 'script', 'select', 'server', 'shadow', 'sidebar',
'small', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'title',
'tr', 'tt', 'ul', 'var', 'wbr', 'xml', 'xmp', '!DOCTYPE', '!--',
);
foreach ($html_tags as $tag)
{
// A tag is '<tagname ', so we need to add < and a space or '<tagname>'
if (stripos($xss_check, '<' . $tag . ' ') !== false || stripos($xss_check, '<' . $tag . '>') !== false)
{
$errUploadMsg = 'COM_PHOCAGALLERY_WARNING_IEXSS';
return false;
}
}
return true;
}
/*
function uploader($id='file-upload', $params = array()) {
$path = 'media/com_phocagallery/js/upload/';
JHtml::script('swf.js', $path, false ); // mootools are loaded yet
JHtml::script('uploader.js', $path, false );// mootools are loaded yet
static $uploaders;
if (!isset($uploaders)) {
$uploaders = array();
}
if (isset($uploaders[$id]) && ($uploaders[$id])) {
return;
}
// Setup options object
$opt['url'] = (isset($params['targetURL'])) ? $params['targetURL'] : null ;
$opt['swf'] = (isset($params['swf'])) ? $params['swf'] : Uri::root(true).'/media/system/swf/uploader.swf';
$opt['multiple'] = (isset($params['multiple']) && !($params['multiple'])) ? '\\false' : '\\true';
$opt['queued'] = (isset($params['queued']) && !($params['queued'])) ? '\\false' : '\\true';
$opt['queueList'] = (isset($params['queueList'])) ? $params['queueList'] : 'upload-queue';
$opt['instantStart'] = (isset($params['instantStart']) && ($params['instantStart'])) ? '\\true' : '\\false';
$opt['allowDuplicates'] = (isset($params['allowDuplicates']) && !($params['allowDuplicates'])) ? '\\false' : '\\true';
$opt['limitSize'] = (isset($params['limitSize']) && ($params['limitSize'])) ? (int)$params['limitSize'] : null;
$opt['limitFiles'] = (isset($params['limitFiles']) && ($params['limitFiles'])) ? (int)$params['limitFiles'] : null;
$opt['optionFxDuration'] = (isset($params['optionFxDuration'])) ? (int)$params['optionFxDuration'] : null;
$opt['container'] = (isset($params['container'])) ? '\\$('.$params['container'].')' : '\\$(\''.$id.'\').getParent()';
$opt['types'] = (isset($params['types'])) ?'\\'.$params['types'] : '\\{\'All Files (*.*)\': \'*.*\'}';
// Optional functions
$opt['createReplacement'] = (isset($params['createReplacement'])) ? '\\'.$params['createReplacement'] : null;
$opt['onComplete'] = (isset($params['onComplete'])) ? '\\'.$params['onComplete'] : null;
$opt['onAllComplete'] = (isset($params['onAllComplete'])) ? '\\'.$params['onAllComplete'] : null;
/* types: Object with (description: extension) pairs, Default: Images (*.jpg; *.jpeg; *.gif; *.png)
*/
/*
$options = PhocaGalleryFileUpload::getJSObject($opt);
// Attach tooltips to document
$document =Factory::getDocument();
$uploaderInit = 'sBrowseCaption=\''.Text::_('Browse Files', true).'\';
sRemoveToolTip=\''.Text::_('Remove from queue', true).'\';
window.addEvent(\'load\', function(){
var Uploader = new FancyUpload($(\''.$id.'\'), '.$options.');
$(\'upload-clear\').adopt(new Element(\'input\', { type: \'button\', events: { click: Uploader.clearList.bind(Uploader, [false])}, value: \''.Text::_('Clear Completed').'\' })); });';
$document->addScriptDeclaration($uploaderInit);
// Set static array
$uploaders[$id] = true;
return;
}
protected static function getJSObject($array=array())
{
// Initialise variables.
$object = '{';
// Iterate over array to build objects
foreach ((array)$array as $k => $v)
{
if (is_null($v)) {
continue;
}
if (!is_array($v) && !is_object($v))
{
$object .= ' '.$k.': ';
$object .= (is_numeric($v) || strpos($v, '\\') === 0) ? (is_numeric($v)) ? $v : substr($v, 1) : "'".$v."'";
$object .= ',';
}
else {
$object .= ' '.$k.': '.PhocaGalleryFileUpload::getJSObject($v).',';
}
}
if (substr($object, -1) == ',') {
$object = substr($object, 0, -1);
}
$object .= '}';
return $object;
}*/
public static function renderFTPaccess() {
$ftpOutput = '<fieldset title="'.Text::_('COM_PHOCAGALLERY_FTP_LOGIN_LABEL'). '">'
.'<legend>'. Text::_('COM_PHOCAGALLERY_FTP_LOGIN_LABEL').'</legend>'
.Text::_('COM_PHOCAGALLERY_FTP_LOGIN_DESC')
.'<table class="adminform nospace">'
.'<tr>'
.'<td width="120"><label for="username">'. Text::_('JGLOBAL_USERNAME').':</label></td>'
.'<td><input type="text" id="username" name="username" class="input_box" size="70" value="" /></td>'
.'</tr>'
.'<tr>'
.'<td width="120"><label for="password">'. Text::_('JGLOBAL_PASSWORD').':</label></td>'
.'<td><input type="password" id="password" name="password" class="input_box" size="70" value="" /></td>'
.'</tr></table></fieldset>';
return $ftpOutput;
}
public static function renderCreateFolder($sessName, $sessId, $currentFolder, $viewBack, $attribs = '') {
if ($attribs != '') {
$attribs = '&amp;'.$attribs;
}
$folderOutput = '<form action="'. Uri::base()
.'index.php?option=com_phocagallery&task=phocagalleryu.createfolder&amp;'. $sessName.'='.$sessId.'&amp;'
.Session::getFormToken().'=1&amp;viewback='.$viewBack.'&amp;'
.'folder='.PhocaGalleryText::filterValue($currentFolder, 'folderpath').$attribs .'" name="folderForm" id="folderForm" method="post">'
//.'<fieldset id="folderview">'
//.'<legend>'.JText::_('COM_PHOCAGALLERY_FOLDER').'</legend>'
.'<div class="ph-in"><div class="ph-head-form">'.Text::_('COM_PHOCAGALLERY_CREATE_FOLDER').'</div>'
.'<dl class="dl-horizontal ph-input">'
.'<dt><input class="form-control" type="text" id="foldername" name="foldername" /></dt>'
.'<input class="update-folder" type="hidden" name="folderbase" id="folderbase" value="'.PhocaGalleryText::filterValue($currentFolder, 'folderpath').'" />'
.'<dd><button class="btn btn-success" type="submit">'. Text::_( 'COM_PHOCAGALLERY_CREATE_FOLDER' ).'</button></dd>'
.'</dl></div>'
//.'</fieldset>'
.HTMLHelper::_( 'form.token' )
.'</form>';
return $folderOutput;
}
}
?>

View File

@ -0,0 +1,37 @@
<?php
/**
* @package Phoca Gallery
* @author Jan Pavelka - https://www.phoca.cz
* @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later
* @cms Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Factory;
class PhocaGalleryFileUploadFront
{
public static function getSizeAllOriginalImages($fileSize, $userId) {
$db =Factory::getDBO();
$allFileSize = 0;
$query = 'SELECT SUM(a.imgorigsize) AS sumimgorigsize'
.' FROM #__phocagallery AS a'
.' LEFT JOIN #__phocagallery_categories AS cc ON a.catid = cc.id'
.' WHERE cc.owner_id = '.(int)$userId;
$db->setQuery($query, 0, 1);
$sumImgOrigSize = $db->loadObject();
if(isset($sumImgOrigSize->sumimgorigsize) && (int)$sumImgOrigSize->sumimgorigsize > 0) {
$allFileSize = (int)$allFileSize + (int)$sumImgOrigSize->sumimgorigsize;
}
if (isset($fileSize)) {
$allFileSize = (int)$allFileSize + (int)$fileSize;
}
return (int)$allFileSize;
}
}
?>

View File

@ -0,0 +1,78 @@
<?php
/**
* @package Phoca Gallery
* @author Jan Pavelka - https://www.phoca.cz
* @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later
* @cms Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Language\Text;
class PhocaGalleryFileUploadJava
{
public $returnUrl;
public $url;
public $source;
public $height;
public $width;
public $resizeheight;
public $resizewidth;
public $uploadmaxsize;
public function __construct() {}
public function getJavaUploadHTML() {
$html = '<!--[if !IE]> -->' . "\n"
.'<object classid="java:wjhk.jupload2.JUploadApplet" type="application/x-java-applet"'
.' archive="http://localhost/'. $this->source.'" height="'.$this->height.'" width="'.$this->width.'" >' . "\n"
.'<param name="archive" value="'. $this->source.'" />' . "\n"
.'<param name="postURL" value="'. $this->url.'"/>' . "\n"
.'<param name="afterUploadURL" value="'. $this->returnUrl.'"/>' . "\n"
.'<param name="allowedFileExtensions" value="jpg/gif/png/" />' . "\n"
.'<param name="uploadPolicy" value="PictureUploadPolicy" />' . "\n"
.'<param name="nbFilesPerRequest" value="1" />' . "\n"
.'<param name="maxPicHeight" value="'. $this->resizeheight .'" />' . "\n"
.'<param name="maxPicWidth" value="'. $this->resizewidth .'" />' . "\n"
.'<param name="maxFileSize" value="'. $this->uploadmaxsize .'" />' . "\n"
.'<param name="pictureTransmitMetadata" value="true" />' . "\n"
.'<param name="showLogWindow" value="false" />' . "\n"
.'<param name="showStatusBar" value="false" />' . "\n"
.'<param name="pictureCompressionQuality" value="1" />' . "\n"
.'<param name="lookAndFeel" value="system"/>' . "\n"
.'<!--<![endif]-->'. "\n"
.'<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0-windows-i586.cab"'
.' height="'.$this->height.'" width="'.$this->width.'" >'. "\n"
.'<param name="code" value="wjhk.jupload2.JUploadApplet" />'. "\n"
.'<param name="archive" value="'. $this->source .'" />'. "\n"
.'<param name="postURL" value="'. $this->url .'"/>'. "\n"
.'<param name="afterUploadURL" value="'. $this->returnUrl.'"/>'. "\n"
.'<param name="allowedFileExtensions" value="jpg/gif/png" />' . "\n"
.'<param name="uploadPolicy" value="PictureUploadPolicy" /> ' . "\n"
.'<param name="nbFilesPerRequest" value="1" />'. "\n"
.'<param name="maxPicHeight" value="'. $this->resizeheight .'" />'. "\n"
.'<param name="maxPicWidth" value="'. $this->resizewidth .'" />'. "\n"
.'<param name="maxFileSize" value="'. $this->uploadmaxsize .'" />' . "\n"
.'<param name="pictureTransmitMetadata" value="true" />'. "\n"
.'<param name="showLogWindow" value="false" />'. "\n"
.'<param name="showStatusBar" value="false" />'. "\n"
.'<param name="pictureCompressionQuality" value="1" />'. "\n"
.'<param name="lookAndFeel" value="system"/>' . "\n"
.'<div style="color:#cc0000">'.Text::_('COM_PHOCAGALLERY_JAVA_PLUGIN_MUST_BE_ENABLED').'</div>'. "\n"
.'</object>'. "\n"
.'<!--[if !IE]> -->'. "\n"
.'</object>' . "\n"
.'<!--<![endif]-->'. "\n"
.'</fieldset>' . "\n";
return $html;
}
}
?>

View File

@ -0,0 +1,307 @@
<?php
/**
* @package Phoca Gallery
* @author Jan Pavelka - https://www.phoca.cz
* @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later
* @cms Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\HTML\HTMLHelper;
class PhocaGalleryFileUploadMultiple
{
public $method = 1;
public $url = '';
public $reload = '';
public $maxFileSize = '';
public $chunkSize = '';
public $imageHeight = '';
public $imageWidth = '';
public $imageQuality= '';
public $frontEnd = 0;
public function __construct() {}
static public function renderMultipleUploadLibraries() {
$paramsC = ComponentHelper::getParams('com_phocagallery');
$chunkMethod = $paramsC->get( 'multiple_upload_chunk', 0 );
$uploadMethod = $paramsC->get( 'multiple_upload_method', 4 );
//First load mootools, then jquery and set noConflict
//JHtml::_('behavior.framework', true);// Load it here to be sure, it is loaded before jquery
HTMLHelper::_('jquery.framework', false);// Load it here because of own nonConflict method (nonconflict is set below)
$document = Factory::getDocument();
// No more used - - - - -
//$nC = 'var pgJQ = jQuery.noConflict();';//SET BELOW
//$document->addScriptDeclaration($nC);//SET BELOW
// - - - - - - - - - - - -
if ($uploadMethod == 2) {
//$document->addScript(JUri::root(true).'/media/com_phocagallery/js/plupload/gears_init.js');
}
if ($uploadMethod == 5) {
//$document->addScript('http://bp.yahooapis.com/2.4.21/browserplus-min.js');
}
HTMLHelper::_('script', 'media/com_phocagallery/js/plupload/plupload.js', array('version' => 'auto'));
if ($uploadMethod == 2) {
//$document->addScript(JUri::root(true).'/media/com_phocagallery/js/plupload/plupload.gears.js');
}
if ($uploadMethod == 3) {
//$document->addScript(JUri::root(true).'/media/com_phocagallery/js/plupload/plupload.silverlight.js');
}
if ($uploadMethod == 1) {
//$document->addScript(JUri::root(true).'/media/com_phocagallery/js/plupload/plupload.flash.js');
}
if ($uploadMethod == 5) {
//$document->addScript(JUri::root(true).'/media/com_phocagallery/js/plupload/plupload.browserplus.js');
}
if ($uploadMethod == 6) {
HTMLHelper::_('script', 'media/com_phocagallery/js/plupload/plupload.html4.js', array('version' => 'auto'));
}
if ($uploadMethod == 4) {
HTMLHelper::_('script', 'media/com_phocagallery/js/plupload/plupload.html5.js', array('version' => 'auto'));
}
HTMLHelper::_('script', 'media/com_phocagallery/js/plupload/jquery.plupload.queue/jquery.plupload.queue.js', array('version' => 'auto'));
HTMLHelper::_('stylesheet', 'media/com_phocagallery/js/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css', array('version' => 'auto'));
}
static public function getMultipleUploadSizeFormat($size) {
$readableSize = PhocaGalleryFile::getFileSizeReadable($size, '%01.0f %s', 1);
$readableSize = str_replace(' ', '', $readableSize);
$readableSize = strtolower($readableSize);
return $readableSize;
}
public function renderMultipleUploadJS($frontEnd = 0, $chunkMethod = 0) {
$document = Factory::getDocument();
switch ($this->method) {
case 2:
$name = 'gears_uploader';
$runtime = 'gears';
break;
case 3:
$name = 'silverlight_uploader';
$runtime = 'silverlight';
break;
case 4:
$name = 'html5_uploader';
$runtime = 'html5';
break;
case 5:
$name = 'browserplus_uploader';
$runtime = 'browserplus';
break;
case 6:
$name = 'html4_uploader';
$runtime = 'html4';
break;
case 1:
default:
$name = 'flash_uploader';
$runtime = 'flash';
break;
}
$chunkEnabled = 0;
// Chunk only if is enabled and only if flash is enabled
if (($chunkMethod == 1 && $this->method == 1) || ($this->frontEnd == 0 && $chunkMethod == 0 && $this->method == 1)) {
$chunkEnabled = 1;
}
$this->url = PhocaGalleryText::filterValue($this->url, 'text');
$this->reload = PhocaGalleryText::filterValue($this->reload, 'text');
$this->url = str_replace('&amp;', '&', $this->url);
$this->reload = str_replace('&amp;', '&', $this->reload);
//$js = ' var pgJQ = jQuery.noConflict();';
$js = 'var pgJQ = jQuery.noConflict();';
$js .=' pgJQ(function() {'."\n";
$js.=''."\n";
$js.=' plupload.addI18n({'."\n";
$js.=' \'Select files\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_SELECT_IMAGES')).'\','."\n";
$js.=' \'Add files to the upload queue and click the start button.\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_ADD_IMAGES_TO_UPLOAD_QUEUE_AND_CLICK_START_BUTTON')).'\','."\n";
$js.=' \'Filename\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_FILENAME')).'\','."\n";
$js.=' \'Status\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_STATUS')).'\','."\n";
$js.=' \'Size\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_SIZE')).'\','."\n";
$js.=' \'Add files\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_ADD_IMAGES')).'\','."\n";
$js.=' \'Add Files\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_ADD_IMAGES')).'\','."\n";
$js.=' \'Start upload\':\''.addslashes(Text::_('COM_PHOCAGALLERY_START_UPLOAD')).'\','."\n";
$js.=' \'Stop Upload\':\''.addslashes(Text::_('COM_PHOCAGALLERY_STOP_CURRENT_UPLOAD')).'\','."\n";
$js.=' \'Stop current upload\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_STOP_CURRENT_UPLOAD')).'\','."\n";
$js.=' \'Start uploading queue\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_START_UPLOADING_QUEUE')).'\','."\n";
$js.=' \'Drag files here.\' : \''.addslashes(Text::_('COM_PHOCAGALLERY_DRAG_FILES_HERE')).'\''."\n";
$js.=' });';
$js.=''."\n";
$js.=' pgJQ("#'.$name.'").pluploadQueue({'."\n";
$js.=' runtimes : \''.$runtime.'\','."\n";
$js.=' url : \''.$this->url.'\','."\n";
//$js.=' max_file_size : \''.$this->maxFileSize.'\','."\n";
if ($this->maxFileSize != '0b') {
$js.=' max_file_size : \''.$this->maxFileSize.'\','."\n";
}
if ($chunkEnabled == 1) {
$js.=' chunk_size : \'1mb\','."\n";
}
$js.=' preinit: attachCallbacks,'."\n";
$js.=' unique_names : false,'."\n";
$js.=' multipart: true,'."\n";
$js.=' filters : ['."\n";
$js.=' {title : "'.Text::_('COM_PHOCAGALLERY_IMAGE_FILES').'", extensions : "jpg,gif,png,jpeg,webp,avif"}'."\n";
//$js.=' {title : "Zip files", extensions : "zip"}'."\n";
$js.=' ],'."\n";
$js.=''."\n";
if ($this->method != 6) {
if ((int)$this->imageWidth > 0 || (int)$this->imageWidth > 0) {
$js.=' resize : {width : '.$this->imageWidth.', height : '.$this->imageHeight.', quality : '.$this->imageQuality.'},'."\n";
$js.=''."\n";
}
}
if ($this->method == 1) {
$js.=' flash_swf_url : \''.Uri::root(true).'/media/com_phocagallery/js/plupload/plupload.flash.swf\''."\n";
} else if ($this->method == 3) {
$js.=' silverlight_xap_url : \''.Uri::root(true).'/media/com_phocagallery/js/plupload/plupload.silverlight.xap\''."\n";
}
$js.=' });'."\n";
$js.=''."\n";
$js.='function attachCallbacks(Uploader) {'."\n";
$js.=' Uploader.bind(\'FileUploaded\', function(Up, File, Response) {'."\n";
$js.=' var obj = eval(\'(\' + Response.response + \')\');'."\n";
if ($this->method == 6) {
$js.=' var queueFiles = Uploader.total.failed + Uploader.total.uploaded;'."\n";
$js.=' var uploaded0 = Uploader.total.uploaded;'."\n";
} else {
$js.=' var queueFiles = Uploader.total.failed + Uploader.total.uploaded + 1;'."\n";
$js.=' var uploaded0 = Uploader.total.uploaded + 1;'."\n";
}
$js.=''."\n";
$js.=' if ((typeof(obj.result) != \'undefined\') && obj.result == \'error\') {'."\n";
$js.=' '."\n";
if ($this->method == 6) {
//$js.=' var uploaded0 = Uploader.total.uploaded;'."\n";
} else {
//$js.=' var uploaded0 = Uploader.total.uploaded + 1;'."\n";
}
$js.=' Up.trigger("Error", {message : obj.message, code : obj.code, details : obj.details, file: File});'."\n";
//$js.=' console.log(obj);'."\n";
$js.=' if( queueFiles == Uploader.files.length) {'."\n";
if ($this->method == 6) {
$js.=' var uploaded0 = Uploader.total.uploaded;'."\n";
} else {
$js.=' var uploaded0 = Uploader.total.uploaded;'."\n";
}
$js.=' window.location = \''.$this->reload.'\' + \'&muuploaded=\' + uploaded0 + \'&mufailed=\' + Uploader.total.failed;'."\n";
//$js.=' alert(\'Error\' + obj.message)'."\n";
$js.=' }'."\n";
$js.=' return false; '."\n";
$js.=''."\n";
$js.=' } else {'."\n";
$js.=' if( queueFiles == Uploader.files.length) {'."\n";
//$js.=' var uploaded = Uploader.total.uploaded + 1;'."\n";
if ($this->method == 6) {
$js.=' var uploaded = Uploader.total.uploaded;'."\n";
} else {
$js.=' var uploaded = Uploader.total.uploaded + 1;'."\n";
}
$js.=' window.location = \''.$this->reload.'\' + \'&muuploaded=\' + uploaded + \'&mufailed=\' + Uploader.total.failed;'."\n";
//$js.=' alert(\'OK\' + obj.message)'."\n";
$js.=' }'."\n";
$js.=' }'."\n";
$js.=' });'."\n";
$js.=' '."\n";
$js.=' Uploader.bind(\'Error\', function(Up, ErrorObj) {'."\n";
$js.=''."\n";
// $js.=' if (ErrorObj.code == 100) { '."\n";
$js.=' pgJQ(\'#\' + ErrorObj.file.id).append(\'<div class="alert alert-error alert-danger">\'+ ErrorObj.message + ErrorObj.details +\'</div>\');'."\n";
//$js.= ' console.log(ErrorObj.file.id + " " + ErrorObj.message + " " + ErrorObj.details);'."\n";
// $js.=' }'."\n";
$js.=' }); '."\n";
$js.='}';
$js.='});'."\n";// End $(function()
$document->addScriptDeclaration($js);
}
public function getMultipleUploadHTML($width = '', $height = '330', $mootools = 1) {
switch ($this->method) {
case 2:
$name = 'gears_uploader';
$msg = Text::_('COM_PHOCAGALLERY_NOT_INSTALLED_GEARS');
break;
case 3:
$name = 'silverlight_uploader';
$msg = Text::_('COM_PHOCAGALLERY_NOT_INSTALLED_SILVERLIGHT');
break;
case 4:
$name = 'html5_uploader';
$msg = Text::_('COM_PHOCAGALLERY_NOT_SUPPORTED_HTML5');
break;
case 5:
$name = 'browserplus_uploader';
$msg = Text::_('COM_PHOCAGALLERY_NOT_INSTALLED_BROWSERPLUS');
break;
case 6:
$name = 'html4_uploader';
$msg = Text::_('COM_PHOCAGALLERY_NOT_SUPPORTED_HTML4');
break;
case 1:
default:
$name = 'flash_uploader';
$msg = Text::_('COM_PHOCAGALLERY_NOT_INSTALLED_FLASH');
break;
}
$style = '';
if ($width != '') {
$style .= 'width: '.(int)$width.'px;';
}
if ($height != '') {
$style .= 'height: '.(int)$height.'px;';
}
return '<div id="'.$name.'" style="'.$style.'">'.$msg.'</div>';
}
}
?>

View File

@ -0,0 +1,40 @@
<?php
/**
* @package Phoca Gallery
* @author Jan Pavelka - https://www.phoca.cz
* @copyright Copyright (C) Jan Pavelka https://www.phoca.cz
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 and later
* @cms Joomla
* @copyright Copyright (C) Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
*/
defined( '_JEXEC' ) or die( 'Restricted access' );
use Joomla\CMS\Language\Text;
class PhocaGalleryFileUploadSingle
{
public $tab = '';
public $returnUrl = '';
public function __construct() {}
public function getSingleUploadHTML( $frontEnd = 0) {
if ($frontEnd == 1) {
$html = '<input type="hidden" name="controller" value="category" />'
.'<input type="hidden" name="tab" value="'.$this->tab.'" />';
} else {
$html = '<input type="file" id="sfile-upload" name="Filedata" />'
//.'<input type="submit" id="sfile-upload-submit" value="'.JText::_('COM_PHOCAGALLERY_START_UPLOAD').'"/>'
.'<button class="btn btn-primary" id="upload-submit"><i class="icon-upload icon-white"></i> '.Text::_('COM_PHOCAGALLERY_START_UPLOAD').'</button>'
.'<input type="hidden" name="return-url" value="'. base64_encode($this->returnUrl).'" />'
.'<input type="hidden" name="tab" value="'.$this->tab.'" />';
}
return $html;
}
}
?>

View File

@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>