Browse Source

! move some txt string formatting back to the source files (subtext)
+ add in a basic check for upload_max_filesize and post_max_size to see if they support what the user has entered in the acp

Spuds 13 years ago
parent
commit
a42e09317e
2 changed files with 30 additions and 19 deletions
  1. 18 10
      Sources/ManageAttachments.php
  2. 12 9
      Themes/default/languages/Admin.english.php

+ 18 - 10
Sources/ManageAttachments.php

@@ -92,6 +92,12 @@ function ManageAttachmentSettings($return_config = false)
 
 	// Perform a test to see if the GD module is installed.
 	$testGD = get_extension_funcs('gd');
+	
+	// See if we can find if the server is set up to support the attacment limits
+	$post_max_size = ini_get('post_max_size');
+	$upload_max_filesize = ini_get('upload_max_filesize');
+	$testPM = !empty($post_max_size) ? (memoryReturnBytes($post_max_size) >= (isset($modSettings['attachmentPostLimit']) ? $modSettings['attachmentPostLimit'] * 1024 : 0)) : true;
+	$testUM = !empty($upload_max_filesize) ? (memoryReturnBytes($upload_max_filesize) >= (isset($modSettings['attachmentSizeLimit']) ? $modSettings['attachmentSizeLimit'] * 1024 : 0)) : true;
 
 	$config_vars = array(
 		array('title', 'attachment_manager_settings'),
@@ -103,12 +109,14 @@ function ManageAttachmentSettings($return_config = false)
 		'',
 			// Directory and size limits.
 			empty($modSettings['currentAttachmentUploadDir']) ? array('text', 'attachmentUploadDir', 40, 'invalid' => !$context['valid_upload_dir']) : array('var_message', 'attachmentUploadDir_multiple', 'message' => 'attachmentUploadDir_multiple_configure'),
-			array('text', 'attachmentDirSizeLimit', 6, 'postinput' => $txt['kilobyte']),
-			array('text', 'attachmentPostLimit', 6, 'postinput' => $txt['kilobyte']),
-			array('text', 'attachmentSizeLimit', 6, 'postinput' => $txt['kilobyte']),
-			array('text', 'attachmentNumPerPostLimit', 6),
+			array('int', 'attachmentDirSizeLimit', 6, 'postinput' => $txt['kilobyte'], 'subtext' => $txt['attachment_no_limit']),
+			array('int', 'attachmentPostLimit', 6, 'postinput' => $txt['kilobyte'], 'subtext' => $txt['attachment_no_limit']),
+			array('warning', empty($testPM) ? 'attachment_postsize_warning' : ''),
+			array('int', 'attachmentSizeLimit', 6, 'postinput' => $txt['kilobyte'], 'subtext' => $txt['attachment_no_limit']),
+			array('warning', empty($testUM) ? 'attachment_filesize_warning' : ''),
+			array('int', 'attachmentNumPerPostLimit', 6, 'subtext' => $txt['attachment_no_limit']),
 			// Security Items
-		'',
+		array('title', 'attachment_security_settings'),
 			// Extension checks etc.
 			array('check', 'attachmentCheckExtensions'),
 			array('text', 'attachmentExtensions', 40),
@@ -119,8 +127,8 @@ function ManageAttachmentSettings($return_config = false)
 		'',
 			array('warning', 'attachment_image_paranoid_warning'),
 			array('check', 'attachment_image_paranoid'),
-		'',
 			// Thumbnail settings.
+		array('title', 'attachment_thumbnail_settings'),
 			array('check', 'attachmentShowImages'),
 			array('check', 'attachmentThumbnails'),
 			array('check', 'attachment_thumb_png'),
@@ -186,8 +194,8 @@ function ManageAvatarSettings($return_config = false)
 		array('title', 'avatar_external'),
 			array('permissions', 'profile_remote_avatar', 0, $txt['avatar_external_url_groups']),
 			array('check', 'avatar_download_external', 0, 'onchange' => 'fUpdateStatus();'),
-			array('text', 'avatar_max_width_external', 6),
-			array('text', 'avatar_max_height_external', 6),
+			array('text', 'avatar_max_width_external', 6, 'subtext' => $txt['avatar_dimension_note']),
+			array('text', 'avatar_max_height_external', 6, 'subtext' => $txt['avatar_dimension_note']),
 			array('select', 'avatar_action_too_large',
 				array(
 					'option_refuse' => $txt['option_refuse'],
@@ -199,8 +207,8 @@ function ManageAvatarSettings($return_config = false)
 		// Uploadable avatars?
 		array('title', 'avatar_upload'),
 			array('permissions', 'profile_upload_avatar', 0, $txt['avatar_upload_groups']),
-			array('text', 'avatar_max_width_upload', 6),
-			array('text', 'avatar_max_height_upload', 6),
+			array('text', 'avatar_max_width_upload', 6, 'subtext' => $txt['avatar_dimension_note']),
+			array('text', 'avatar_max_height_upload', 6, 'subtext' => $txt['avatar_dimension_note']),
 			array('check', 'avatar_resize_upload', 'subtext' => $txt['avatar_resize_upload_note']),
 			array('check', 'avatar_reencode'),
 		'',

+ 12 - 9
Themes/default/languages/Admin.english.php

@@ -351,11 +351,13 @@ $txt['attachmentEncryptFilenames'] = 'Encrypt stored filenames';
 $txt['attachmentUploadDir'] = 'Attachments directory<div class="smalltext"><a href="' . $scripturl . '?action=admin;area=manageattachments;sa=attachpaths">Configure multiple attachment directories</a></div>';
 $txt['attachmentUploadDir_multiple'] = 'Attachments directory';
 $txt['attachmentUploadDir_multiple_configure'] = '<a href="' . $scripturl . '?action=admin;area=manageattachments;sa=attachpaths">[Configure multiple attachment directories]</a>';
-$txt['attachmentDirSizeLimit'] = 'Max attachment folder space<div class="smalltext">(0 for no limit)</div>';
-$txt['attachmentPostLimit'] = 'Max attachment size per post<div class="smalltext">(0 for no limit)</div>';
-$txt['attachmentSizeLimit'] = 'Max size per attachment<div class="smalltext">(0 for no limit)</div>';
-$txt['attachmentNumPerPostLimit'] = 'Max number of attachments per post<div class="smalltext">(0 for no limit)</div>';
+$txt['attachmentDirSizeLimit'] = 'Max attachment folder space';
+$txt['attachmentPostLimit'] = 'Max attachment size per post';
+$txt['attachmentSizeLimit'] = 'Max size per attachment';
+$txt['attachmentNumPerPostLimit'] = 'Max number of attachments per post';
 $txt['attachment_gd_warning'] = 'The GD module is currently not installed. Image re-encoding is not possible.';
+$txt['attachment_postsize_warning'] = 'The current php.ini setting \'post_max_size\' may not support this.';
+$txt['attachment_filesize_warning'] = 'The current php.ini setting \'upload_max_filesize\' may not support this.';
 $txt['attachment_image_reencode'] = 'Re-encode potentially dangerous image attachments';
 $txt['attachment_image_reencode_note'] = '(requires GD module)';
 $txt['attachment_image_paranoid_warning'] = 'The extensive security checks can result in a large number of rejected attachments.';
@@ -369,6 +371,7 @@ $txt['attachmentThumbWidth'] = 'Maximum width of thumbnails';
 $txt['attachmentThumbHeight'] = 'Maximum height of thumbnails';
 $txt['attachment_thumbnail_settings'] = 'Thumbnail Settings';
 $txt['attachment_security_settings'] = 'Attachment Security Settings';
+$txt['attachment_no_limit'] = '(0 for no limit)';
 
 $txt['attach_dir_does_not_exist'] = 'Does Not Exist';
 $txt['attach_dir_not_writable'] = 'Not Writable';
@@ -389,16 +392,16 @@ $txt['attach_path_current_bad'] = 'Invalid current attachment path.';
 $txt['mods_cat_avatars'] = 'Avatars';
 $txt['avatar_directory'] = 'Avatars directory';
 $txt['avatar_url'] = 'Avatars URL';
-$txt['avatar_dimension_note'] = '(0 = no limit)';
-$txt['avatar_max_width_external'] = 'Maximum width of external avatar<div class="smalltext">(0 for no limit)</div>';
-$txt['avatar_max_height_external'] = 'Maximum height of external avatar<div class="smalltext">(0 for no limit)</div>';
+$txt['avatar_dimension_note'] = '(0 for no limit)';
+$txt['avatar_max_width_external'] = 'Maximum width of external avatar';
+$txt['avatar_max_height_external'] = 'Maximum height of external avatar';
 $txt['avatar_action_too_large'] = 'If the avatar is too large...';
 $txt['option_refuse'] = 'Refuse it';
 $txt['option_html_resize'] = 'Let the HTML resize it';
 $txt['option_js_resize'] = 'Resize it with JavaScript';
 $txt['option_download_and_resize'] = 'Download and resize it (requires GD module)';
-$txt['avatar_max_width_upload'] = 'Maximum width of uploaded avatar<div class="smalltext">(0 for no limit)</div>';
-$txt['avatar_max_height_upload'] = 'Maximum height of uploaded avatar<div class="smalltext">(0 for no limit)</div>';
+$txt['avatar_max_width_upload'] = 'Maximum width of uploaded avatar';
+$txt['avatar_max_height_upload'] = 'Maximum height of uploaded avatar';
 $txt['avatar_resize_upload'] = 'Resize oversized large avatars';
 $txt['avatar_resize_upload_note'] = '(requires GD module)';
 $txt['avatar_download_png'] = 'Use PNG for resized avatars';