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:
@@ -11,8 +11,8 @@
|
|||||||
| GNU General Public License (http://gnu.org).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_admin/filemanager.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_admin/filemanager.php,v $
|
||||||
| $Revision: 1.3 $
|
| $Revision: 1.4 $
|
||||||
| $Date: 2008-04-01 20:06:24 $
|
| $Date: 2008-05-25 09:04:16 $
|
||||||
| $Author: e107steved $
|
| $Author: e107steved $
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
@@ -23,6 +23,7 @@ if (!getperms("6")) {
|
|||||||
}
|
}
|
||||||
$e_sub_cat = 'filemanage';
|
$e_sub_cat = 'filemanage';
|
||||||
require_once("auth.php");
|
require_once("auth.php");
|
||||||
|
require_once(e_HANDLER.'upload_handler.php');
|
||||||
|
|
||||||
|
|
||||||
$pubfolder = (str_replace("../","",e_QUERY) == str_replace("../","",e_FILE."public/")) ? TRUE : FALSE;
|
$pubfolder = (str_replace("../","",e_QUERY) == str_replace("../","",e_FILE."public/")) ? TRUE : FALSE;
|
||||||
@@ -204,9 +205,13 @@ $text .= "</select>\n
|
|||||||
$ns->tablerender(FMLAN_34, $text);
|
$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\">
|
$text = "<form enctype=\"multipart/form-data\" action=\"".e_SELF.(e_QUERY ? "?".e_QUERY : "")."\" method=\"post\">
|
||||||
<div style=\"text-align:center\">
|
<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."\">";
|
<table class='fborder' style=\"".ADMIN_WIDTH."\">";
|
||||||
|
|
||||||
$text .= "<tr>
|
$text .= "<tr>
|
||||||
@@ -356,26 +361,6 @@ function dirsize($dir) {
|
|||||||
return parsesize($size);
|
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");
|
require_once("footer.php");
|
||||||
?>
|
?>
|
@@ -11,8 +11,8 @@
|
|||||||
| GNU General Public License (http://gnu.org).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_admin/plugin.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_admin/plugin.php,v $
|
||||||
| $Revision: 1.15 $
|
| $Revision: 1.16 $
|
||||||
| $Date: 2008-04-05 07:58:30 $
|
| $Date: 2008-05-25 09:04:16 $
|
||||||
| $Author: e107steved $
|
| $Author: e107steved $
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
@@ -418,13 +418,17 @@ if(!is_writable(e_PLUGIN))
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$text = "<div style='text-align:center'>
|
// 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."'>
|
<form enctype='multipart/form-data' method='post' action='".e_SELF."'>
|
||||||
<table style='".ADMIN_WIDTH."' class='fborder'>
|
<table style='".ADMIN_WIDTH."' class='fborder'>
|
||||||
<tr>
|
<tr>
|
||||||
<td class='forumheader3' style='width: 50%;'>".EPL_ADLAN_37."</td>
|
<td class='forumheader3' style='width: 50%;'>".EPL_ADLAN_37."</td>
|
||||||
<td class='forumheader3' style='width: 50%;'>
|
<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 type='hidden' name='ac' value='".md5(ADMINPWCHANGE)."' />
|
||||||
<input class='tbox' type='file' name='file_userfile[]' size='50' />
|
<input class='tbox' type='file' name='file_userfile[]' size='50' />
|
||||||
</td>
|
</td>
|
||||||
|
@@ -11,8 +11,8 @@
|
|||||||
| GNU General Public License (http://gnu.org).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/theme_handler.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/theme_handler.php,v $
|
||||||
| $Revision: 1.8 $
|
| $Revision: 1.9 $
|
||||||
| $Date: 2008-04-10 19:23:41 $
|
| $Date: 2008-05-25 09:04:16 $
|
||||||
| $Author: e107steved $
|
| $Author: e107steved $
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
@@ -251,13 +251,18 @@ class themeHandler{
|
|||||||
if(!is_writable(e_THEME)) {
|
if(!is_writable(e_THEME)) {
|
||||||
$ns->tablerender(TPVLAN_16, TPVLAN_15);
|
$ns->tablerender(TPVLAN_16, TPVLAN_15);
|
||||||
$text = "";
|
$text = "";
|
||||||
} else {
|
}
|
||||||
$text = "<div style='text-align:center'>
|
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'>
|
<table style='".ADMIN_WIDTH."' class='fborder'>
|
||||||
<tr>
|
<tr>
|
||||||
<td class='forumheader3' style='width: 50%;'>".TPVLAN_13."</td>
|
<td class='forumheader3' style='width: 50%;'>".TPVLAN_13."</td>
|
||||||
<td class='forumheader3' style='width: 50%;'>
|
<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 type='hidden' name='ac' value='".md5(ADMINPWCHANGE)."' />
|
||||||
<input class='tbox' type='file' name='file_userfile[]' size='50' />
|
<input class='tbox' type='file' name='file_userfile[]' size='50' />
|
||||||
</td>
|
</td>
|
||||||
|
@@ -12,20 +12,9 @@
|
|||||||
| GNU General Public License (http://gnu.org).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/upload_handler.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/upload_handler.php,v $
|
||||||
| $Revision: 1.13 $
|
| $Revision: 1.14 $
|
||||||
| $Date: 2008-04-22 20:32:40 $
|
| $Date: 2008-05-25 09:04:16 $
|
||||||
| $Author: e107steved $
|
| $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;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Reference in New Issue
Block a user