From e551a027e2d960008ef7007fc1b107795caaa01c Mon Sep 17 00:00:00 2001 From: vargenau Date: Mon, 19 Oct 2009 07:46:27 +0000 Subject: [PATCH] Get the maximum upload filesize from PHP config git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@7218 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- g | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/g b/g index 601085126..3d2479e4d 100644 --- a/g +++ b/g @@ -89,6 +89,9 @@ if (!$group_id || !$project) { // Use black list of extensions instead of white list define('DISABLE_UPLOAD_ONLY_ALLOWED_EXTENSIONS', true); + // Get the maximum upload filesize from PHP config + define('MAX_UPLOAD_SIZE', octets(ini_get('upload_max_filesize'))); + // GForge is UTF-8, so use the same. define('CHARSET', 'UTF-8'); @@ -203,12 +206,11 @@ if (!$group_id || !$project) { define('STRICT_MAILABLE_PAGEDUMPS', false); - define('DEFAULT_DUMP_DIR', "/tmp/wikidump"); - define('HTML_DUMP_DIR', "/tmp/wikidumphtml"); + // Perhaps propose Web DAV location ? + define('DEFAULT_DUMP_DIR', ""); + define('HTML_DUMP_DIR', ""); define('HTML_DUMP_SUFFIX', ".html"); - define('MAX_UPLOAD_SIZE', 16777216); - define('MINOR_EDIT_TIMEOUT', 604800); define('COMPRESS_OUTPUT', false); @@ -263,4 +265,22 @@ if (!$group_id || !$project) { // Start the wiki include "lib/main.php"; } + +/** + * Return a number of octets from a string like "300M" + */ +function octets($val) { + $val = trim($val); + $last = strtolower($val[strlen($val)-1]); + switch($last) { + // The 'G' modifier is available since PHP 5.1.0 + case 'g': + $val *= 1024; + case 'm': + $val *= 1024; + case 'k': + $val *= 1024; + } + return $val; +} ?> -- 2.45.0