# HG changeset patch # User Dan # Date 1272856518 14400 # Node ID 81b03b3e88d0af4a785ae5e67b1898073dd89675 # Parent 3914c9a9587912ce58ea0d07739209f4772c37f0 Added a box on Admin:UploadConfig showing the value of upload_max_filesize. diff -r 3914c9a95879 -r 81b03b3e88d0 includes/functions.php --- a/includes/functions.php Fri Apr 30 22:15:03 2010 -0400 +++ b/includes/functions.php Sun May 02 23:15:18 2010 -0400 @@ -2833,6 +2833,25 @@ } /** + * Convert PHP's suffixes for a file size an integer. + * @param string + */ + +function php_filesize_to_int($sz) +{ + $num = preg_replace('/[^0-9]/', '', $sz); + $unit = preg_replace('/[^A-z]/', '', $sz); + $multiplier = 1; + switch(strtolower($unit)) + { + case 'g': $multiplier = 1073741824; break; + case 'm': $multiplier = 1048576; break; + case 'k': $multiplier = 1024; break; + } + return intval($num) * $multiplier; +} + +/** * Injects a string into another string at the specified position. * @param string The haystack * @param string The needle diff -r 3914c9a95879 -r 81b03b3e88d0 language/english/admin.json --- a/language/english/admin.json Fri Apr 30 22:15:03 2010 -0400 +++ b/language/english/admin.json Sun May 02 23:15:18 2010 -0400 @@ -496,17 +496,18 @@ }, acpup: { heading_main: 'File upload configuration', - intro: 'Enano supports the ability to upload files to your website and store the files in the database. This enables you to embed images and such into pages without manually writing the HTML. However, the upload feature can sometimes pose a risk to your site, as viruses and executable files can sometimes be uploaded.', + intro: 'Enano supports the ability to upload files to your website and store the files in the database. This enables you to embed images and such into pages without manually writing the HTML.
Enabling file uploads is a significant security risk. Before enabling uploads, make sure that the "files" directory is not accessible via HTTP, and especially that files cannot be listed. Enano does its best to restrict the files directory for you, but it isn\'t foolproof, especially on non-Apache servers. Only if your server is secured properly will it be safe to enable uploads of sensitive file types like .html and .php.', field_enable: 'Enable file uploads', + info_max_server_size: 'Your server\'s PHP configuration reports a maximum file size of %size%.', field_max_size: 'Maximum file size:', info_magick: 'You can allow Enano to generate thumbnails of images automatically. This feature requires ImageMagick to work properly. If your server does not have ImageMagick on it, Enano will try to use the GD library (if available) to scale images. This can be slower, but it works on a wider range of servers. If even that does not work, Enano will simply make your users\' browsers scale the images. In most cases this is fine, but if you are uploading large (>100KB) images and embedding them inside of pages, you should try to enable ImageMagick or configure GD because transferring these large images many times can cost you quite a lot of bandwidth.', field_magick_enable: 'Use ImageMagick to scale images', field_magick_path: 'Path to ImageMagick:', - err_magick_not_found: 'Warning: the file "%magick_path%" was not found, and the ImageMagick file path was not updated.', + err_magick_not_found: 'Warning: the ImageMagick executable "%magick_path|escape%" you entered was not found, or it can\'t be checked for because PHP has Safe Mode or open_basedir enabled. Enano will not use ImageMagick to scale images.', // Translators: for the path here, please be sure to use a double-backslash in the Windows path. Avoid translating the file paths // anyway since they're generally the same even on non-English Windows systems. field_magick_path_hint: 'On Linux and Unix servers, the most likely options here are /usr/bin/convert and /usr/local/bin/convert. If you server runs Windows, then ImageMagick is most likely to be C:\\Windows\\Convert.exe or C:\\Windows\\System32\\Convert.exe.', - info_cache: 'If you use ImageMagick to scale images, your server will be very busy constantly scaling images if your website is busy, and your site may experience slowdowns. You can dramatically speed up this scaling process if you use a directory to cache thumbnail images.', + info_cache: 'If you use ImageMagick to scale images, all but the smallest websites should enable caching below (enabled by default). Otherwise your server may become overloaded very quickly!', info_cache_chmod: 'Please note: the cache/ directory on your server must be writable by the server. While this is not usually a problem on Windows servers, most Linux/Unix servers will require you to CHMOD the cache/ directory to 777. See your FTP client\'s user guide for more information on how to do this.', msg_cache_not_writable: ' At present, it seems that the cache directory is not writable. The checkbox below has been disabled to maintain the stability of Enano.', field_cache: 'Cache thumbnailed images', diff -r 3914c9a95879 -r 81b03b3e88d0 plugins/SpecialAdmin.php --- a/plugins/SpecialAdmin.php Fri Apr 30 22:15:03 2010 -0400 +++ b/plugins/SpecialAdmin.php Sun May 02 23:15:18 2010 -0400 @@ -1170,21 +1170,24 @@ $db->_die(); setConfig('file_history', '0'); } - if(file_exists($_POST['imagemagick_path']) && $_POST['imagemagick_path'] != getConfig('imagemagick_path')) + $path = $_POST['imagemagick_path']; + $result = @file_exists($path) && @is_file($path) && @is_executable($path); + if ( $path !== getConfig('imagemagick_path', '/usr/bin/convert') ) { + if ( !$result ) + { + echo '
get('acpup_field_max_size'); ?>