From 2de8344c97468ea9a833f470885243fc94ee7742 Mon Sep 17 00:00:00 2001 From: plegall Date: Mon, 3 May 2010 09:09:40 +0000 Subject: bug 1635 fixed: new API method pwg.images.checkUpload tells pLoader if Piwigo is ready for upload (currently, it checks write access on the upload directory) git-svn-id: http://piwigo.org/svn/trunk@6049 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/ws_functions.inc.php | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'include/ws_functions.inc.php') diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php index 6f2adbf2d..87cb72393 100644 --- a/include/ws_functions.inc.php +++ b/include/ws_functions.inc.php @@ -2126,4 +2126,52 @@ function ws_logfile($string) FILE_APPEND ); } + +function ws_images_checkUpload($params, &$service) +{ + global $conf; + + if (!is_admin() or is_adviser()) + { + return new PwgError(401, 'Access denied'); + } + + $relative_dir = preg_replace('#^'.PHPWG_ROOT_PATH.'#', '', $conf['upload_dir']); + + $ret['message'] = null; + $ret['ready_for_upload'] = true; + + if (!is_dir($conf['upload_dir'])) + { + if (!is_writable(dirname($conf['upload_dir']))) + { + $ret['message'] = sprintf( + l10n('Create the "%s" directory at the root of your Piwigo installation'), + $relative_dir + ); + } + } + else + { + if (!is_writable($conf['upload_dir'])) + { + @chmod($conf['upload_dir'], 0777); + + if (!is_writable($conf['upload_dir'])) + { + $ret['message'] = sprintf( + l10n('Give write access (chmod 777) to "%s" directory at the root of your Piwigo installation'), + $relative_dir + ); + } + } + } + + if (!empty($ret['message'])) + { + $ret['ready_for_upload'] = false; + } + + return $ret; +} ?> -- cgit v1.2.3