Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resize error [php:ERROR_PERM_DENIED] using FTP driver #2287

Closed
zzplab opened this issue Nov 20, 2017 · 6 comments
Closed

Resize error [php:ERROR_PERM_DENIED] using FTP driver #2287

zzplab opened this issue Nov 20, 2017 · 6 comments

Comments

@zzplab
Copy link
Contributor

zzplab commented Nov 20, 2017

I'm using elFinder [2.1.29] with elFinderVolumeFTP.class. Viewing, uploading, deleting, moving, everything works ok. Except...
Except resize/crop/rotate: I get an error I can relate back to PHP > ERROR_PERM_DENIED in elFinder.class.
Is that a bug? Is resize not possible with FTP driver? Or error in my setup?
How to solve?
FTP is connecting to other accounts on the same server, example:
/account_dir/...
The .tmb images are kept 'locally' in the account where elFinder is active, example:
/elfinder/...

My setup > html/js:

<script type="text/javascript" charset="utf-8">
function getUrlParam(paramName) {
  var reParam = new RegExp('(?:[\?&]|&amp;)' + paramName + '=([^&]+)', 'i') ;
  var match = window.location.search.match(reParam) ;
  return (match && match.length > 1) ? match[1] : '' ;
}
   
$(function() {
var funcNum = getUrlParam('CKEditorFuncNum');
	var elf = $('#elfinder').elfinder({
	lang: 'nl',
	url : 'connector/images.php',
	height : "94%",
	validName: '/^[^\s]$/',
	onlyMimes: [
							'image/bmp'
							,'image/png'
							,'image/gif'
							,'image/jpeg'
							, 'image/svg+xml'
							],
	commands : [
'open', 'reload', 'home', 'up', 'back', 'forward', 'getfile', 'quicklook', 
'download', 'rm', 'duplicate', 'rename', 'mkdir', 'upload', 'copy',
'cut', 'paste', 'search', 'info', 'view',
'resize', 'sort'
],
	uiOptions : {
		toolbar : [
			['back', 'forward', 'up', 'home'],
			['mkdir'],
			['reload', 'sort', 'view'],
			['rm'],
			['copy', 'cut', 'paste'],
			['duplicate'],
			['open', 'download'],
			['getfile'],
			['info', 'quicklook'],
			['upload', 'rename', 'resize'],
			['search']
		],
		tree : {
			openRootOnLoad : true,
			syncTree : true
		},
		navbar : {
			minWidth : 120,
			maxWidth : 320
		}
	},
	loadTmbs : 160,
	showFiles: 480,
	requestMaxConn: 64,
	getFileCallback : function(file) {
	  window.opener.CKEDITOR.tools.callFunction(funcNum, file.url);
	  window.close();
	}
	}).elfinder('instance');
});
</script>

PHP>

require '/..PATH../elfinder/vendor/studio-42/elfinder/php/autoload.php';
elFinder::$netDrivers['ftp'] = 'FTP';

function access($attr, $path, $data, $volume) {
	return strpos(basename($path), '.') === 0
		? !($attr == 'read' || $attr == 'write')
		:  null; 
}

$elf_dir = 'account_dir';
define('t_root', '/..root_pathto.../elfinder/.tmb/'.$elf_dir);
define('t_url', 'https://example.com/elfinder/.tmb/'.$elf_dir);

if(!is_dir(t_root))
{
	mkdir(t_root);
}

$opts = array(
	'bind' => array(
		'mkdir.pre mkfile.pre rename.pre archive.pre' => array(
			'Plugin.Sanitizer.cmdPreprocess',
			'Plugin.Normalizer.cmdPreprocess'
		),
		'upload.presave' => array(
			'Plugin.Sanitizer.onUpLoadPreSave',
			'Plugin.Normalizer.onUpLoadPreSave',
			'Plugin.AutoResize.onUpLoadPreSave'
		)
	),
	'plugin' => array(
		'Sanitizer' => array(
			'enable' => true,
			'targets'  => array('\\','/',':','*','?','"','<','>','|','\'','@','#','$','(',')',',',';','_','%','&','^','=',' ','!','--'),
			'replace'  => '-'
		),
		'Normalizer' => array(
			'enable' 		=> true,
			'nfc'   		=> false,
			'nfkc'			=> false,
			'lowercase' => true
		),
		'AutoResize' => array(
			'enable'         => true,
			'maxWidth'       => 1600,
			'maxHeight'      => 1200,
			'quality'        => 95,
			'preserveExif'   => false,
			'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP
		)
	),

	'roots' => array(

		array(
	    'driver'        => 'FTP',
	    'host'          => 'localhost',
	    'user'          => $user,
	    'pass'          => $pass,
	    'port'          => 21,
	    'mode'          => 'passive',
	    'path'          => '/..pathto../images',
	    'URL'           => $uploadURL.'/images/',
			'tmbPath'     	=> t_root,
			'tmbURL'       	=> t_url,
			'tmpPath'       => t_root,
	    'alias'     		=> 'Afbeeldingen',
	    'owner'         => true,
	    'uploadAllow'   => array(
													'image/bmp'
													, 'image/png'
													, 'image/gif'
													, 'image/jpeg'
													, 'image/svg+xml'
													),
			'uploadDeny'    => array('all'),
			'uploadOrder'   => 'deny,allow',
			'uploadMaxSize' => '5M',
			'checkSubfolders' => -1,
			'locale' => 'nl_NL.utf8',
			'uploadMaxConn' => 8,
			'autoload' => true,
	    'accessControl' => 'access'
		),
	)
);

$connector = new elFinderConnector(new elFinder($opts));
$connector->run();
@zzplab
Copy link
Contributor Author

zzplab commented Nov 20, 2017

schermafbeelding 2017-11-20 om 13 27 40
schermafbeelding 2017-11-20 om 13 27 59

@nao-pon
Copy link
Member

nao-pon commented Nov 21, 2017

@zzplab Is there same problem with the nightly build?

@zzplab
Copy link
Contributor Author

zzplab commented Nov 21, 2017

Thanks :-) That works fine as expected, problem solved. Is the nightly build as it is now safe to use in production? When is next release date?

Other question:
In elFinderVolumeFTP.class.php I always need FTP + SSL on my server. I manually change ftp_connect to ftp_ssl_connect after updates. Is a pull request a good idea to add the option for SSL in the elFinder source?

@nao-pon
Copy link
Member

nao-pon commented Nov 21, 2017

2.1.30 release is scheduled for around the end of this month from a few days later. Adding the ftp_ssl_connect option is a good idea! Please send PR.

@zzplab
Copy link
Contributor Author

zzplab commented Nov 21, 2017

2.1.30 > great. I'll stick to the nightly for now.
SSL ok.

@zzplab
Copy link
Contributor Author

zzplab commented Nov 22, 2017

Thanks for the merge #2289

@zzplab zzplab closed this as completed Nov 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants