aboutsummaryrefslogtreecommitdiffstats
path: root/admin/include/configuration_watermark_process.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2012-08-30 19:20:00 +0000
committerrvelices <rv-github@modusoptimus.com>2012-08-30 19:20:00 +0000
commitc918bb9209202bf9c7172890db626f07381346ac (patch)
tree5a5e6141716c401c5e0f9330989763f6587ee5b3 /admin/include/configuration_watermark_process.inc.php
parentd9854148a5100e2a1056441057deac40cbd67379 (diff)
bug 2725: Piwigo isn't compatible with suPHP + better handling of watermark upload errors
git-svn-id: http://piwigo.org/svn/trunk@17675 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/include/configuration_watermark_process.inc.php')
-rw-r--r--admin/include/configuration_watermark_process.inc.php28
1 files changed, 18 insertions, 10 deletions
diff --git a/admin/include/configuration_watermark_process.inc.php b/admin/include/configuration_watermark_process.inc.php
index 6efabac06..3038d5948 100644
--- a/admin/include/configuration_watermark_process.inc.php
+++ b/admin/include/configuration_watermark_process.inc.php
@@ -43,16 +43,24 @@ if (isset($_FILES['watermarkImage']) and !empty($_FILES['watermarkImage']['tmp_n
else
{
$upload_dir = PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'watermarks';
-
- include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
- prepare_directory($upload_dir);
-
- $new_name = get_filename_wo_extension($_FILES['watermarkImage']['name']).'.png';
- $file_path = $upload_dir.'/'.$new_name;
-
- move_uploaded_file($_FILES['watermarkImage']['tmp_name'], $file_path);
-
- $pwatermark['file'] = substr($file_path, strlen(PHPWG_ROOT_PATH));
+ if (mkgetdir($upload_dir, MKGETDIR_DEFAULT&~MKGETDIR_DIE_ON_ERROR))
+ {
+ $new_name = get_filename_wo_extension($_FILES['watermarkImage']['name']).'.png';
+ $file_path = $upload_dir.'/'.$new_name;
+
+ if (move_uploaded_file($_FILES['watermarkImage']['tmp_name'], $file_path))
+ {
+ $pwatermark['file'] = substr($file_path, strlen(PHPWG_ROOT_PATH));
+ }
+ else
+ {
+ $page['errors'][] = $errors['watermarkImage'] = "$file_path " .l10n('no write access');
+ }
+ }
+ else
+ {
+ $page['errors'][] = $errors['watermarkImage'] = sprintf( l10n('Add write access to the "%s" directory'), $upload_dir);
+ }
}
}