1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

Bugtracker #4311 - calculate largest allowable upload file size in admin functions

This commit is contained in:
e107steved
2008-05-25 09:04:16 +00:00
parent 33f96bb871
commit 899490243b
4 changed files with 39 additions and 45 deletions

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/filemanager.php,v $
| $Revision: 1.3 $
| $Date: 2008-04-01 20:06:24 $
| $Revision: 1.4 $
| $Date: 2008-05-25 09:04:16 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
@@ -23,6 +23,7 @@ if (!getperms("6")) {
}
$e_sub_cat = 'filemanage';
require_once("auth.php");
require_once(e_HANDLER.'upload_handler.php');
$pubfolder = (str_replace("../","",e_QUERY) == str_replace("../","",e_FILE."public/")) ? TRUE : FALSE;
@@ -204,9 +205,13 @@ $text .= "</select>\n
$ns->tablerender(FMLAN_34, $text);
// Get largest allowable file upload
$max_file_size = get_user_max_upload();
$text = "<form enctype=\"multipart/form-data\" action=\"".e_SELF.(e_QUERY ? "?".e_QUERY : "")."\" method=\"post\">
<div style=\"text-align:center\">
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"1000000\" />
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"{$max_file_size}\" />
<table class='fborder' style=\"".ADMIN_WIDTH."\">";
$text .= "<tr>
@@ -356,26 +361,6 @@ function dirsize($dir) {
return parsesize($size);
}
function parsesize($size) {
$kb = 1024;
$mb = 1024 * $kb;
$gb = 1024 * $mb;
$tb = 1024 * $gb;
if ($size < $kb) {
return $size." b";
}
else if($size < $mb) {
return round($size/$kb, 2)." kb";
}
else if($size < $gb) {
return round($size/$mb, 2)." mb";
}
else if($size < $tb) {
return round($size/$gb, 2)." gb";
} else {
return round($size/$tb, 2)." tb";
}
}
require_once("footer.php");
?>

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/plugin.php,v $
| $Revision: 1.15 $
| $Date: 2008-04-05 07:58:30 $
| $Revision: 1.16 $
| $Date: 2008-05-25 09:04:16 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
@@ -418,13 +418,17 @@ if(!is_writable(e_PLUGIN))
}
else
{
// Get largest allowable file upload
require_once(e_HANDLER.'upload_handler.php');
$max_file_size = get_user_max_upload();
$text = "<div style='text-align:center'>
<form enctype='multipart/form-data' method='post' action='".e_SELF."'>
<table style='".ADMIN_WIDTH."' class='fborder'>
<tr>
<td class='forumheader3' style='width: 50%;'>".EPL_ADLAN_37."</td>
<td class='forumheader3' style='width: 50%;'>
<input type='hidden' name='MAX_FILE_SIZE' value='1000000' />
<input type='hidden' name='MAX_FILE_SIZE' value='{$max_file_size}' />
<input type='hidden' name='ac' value='".md5(ADMINPWCHANGE)."' />
<input class='tbox' type='file' name='file_userfile[]' size='50' />
</td>

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/theme_handler.php,v $
| $Revision: 1.8 $
| $Date: 2008-04-10 19:23:41 $
| $Revision: 1.9 $
| $Date: 2008-05-25 09:04:16 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
@@ -251,13 +251,18 @@ class themeHandler{
if(!is_writable(e_THEME)) {
$ns->tablerender(TPVLAN_16, TPVLAN_15);
$text = "";
} else {
}
else
{
require_once(e_HANDLER.'upload_handler.php');
$max_file_size = get_user_max_upload();
$text = "<div style='text-align:center'>
<table style='".ADMIN_WIDTH."' class='fborder'>
<tr>
<td class='forumheader3' style='width: 50%;'>".TPVLAN_13."</td>
<td class='forumheader3' style='width: 50%;'>
<input type='hidden' name='MAX_FILE_SIZE' value='1000000' />
<input type='hidden' name='MAX_FILE_SIZE' value='{$max_file_size}' />
<input type='hidden' name='ac' value='".md5(ADMINPWCHANGE)."' />
<input class='tbox' type='file' name='file_userfile[]' size='50' />
</td>

View File

@@ -12,20 +12,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/upload_handler.php,v $
| $Revision: 1.13 $
| $Date: 2008-04-22 20:32:40 $
| $Revision: 1.14 $
| $Date: 2008-05-25 09:04:16 $
| $Author: e107steved $
********** TEST VERSION DOES INTERMEDIATE COPY ***************
Unaltered code to:
V0.7.x File V1.33
V0.8.x File V1.12
To do:
1. Criteria for intermediate copy
2. Make get_file_types compatible with XML counterpart - array of filetype/max size
3. Check sizes - may be different for various file types for non-admin user, for example
+---------------------------------------------------------------+
*/
@@ -821,4 +810,15 @@ function set_max_size(&$allowed_filetypes, $max_upload_size)
}
// Quick routine if all we want is the size of the largest file the current user can upload
function get_user_max_upload()
{
$a_filetypes = get_filetypes();
if (count($a_filetypes) == 0) return 0; // Return if no upload allowed
$max_upload_size = calc_max_upload_size(-1); // Find overriding maximum upload size
$max_upload_size = set_max_size($a_filetypes, $max_upload_size);
return $max_upload_size;
}
?>