Make max upload filesize configurable for apache hosts
This commit is contained in:
parent
f48344df30
commit
6b34ba8a8e
|
@ -26,15 +26,26 @@
|
||||||
require_once('../lib/base.php');
|
require_once('../lib/base.php');
|
||||||
require( 'template.php' );
|
require( 'template.php' );
|
||||||
|
|
||||||
|
|
||||||
// Check if we are a user
|
// Check if we are a user
|
||||||
if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){
|
if( !OC_USER::isLoggedIn() || !OC_GROUP::inGroup( $_SESSION['user_id'], 'admin' )){
|
||||||
header( "Location: ".OC_HELPER::linkTo( "index.php" ));
|
header( "Location: ".OC_HELPER::linkTo( "index.php" ));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$htaccessWorking=(getenv('htaccessWorking')=='true');
|
||||||
|
if(isset($_POST['maxUploadSize'])){
|
||||||
|
$maxUploadFilesize=$_POST['maxUploadSize'];
|
||||||
|
OC_FILES::setUploadLimit(OC_HELPER::computerFileSize($maxUploadFilesize));
|
||||||
|
}else{
|
||||||
|
$maxUploadFilesize = ini_get('upload_max_filesize').'B';
|
||||||
|
}
|
||||||
|
|
||||||
OC_APP::setActiveNavigationEntry( "files_administration" );
|
OC_APP::setActiveNavigationEntry( "files_administration" );
|
||||||
// return template
|
// return template
|
||||||
$tmpl = new OC_TEMPLATE( "files", "admin", "admin" );
|
$tmpl = new OC_TEMPLATE( "files", "admin", "admin" );
|
||||||
|
$tmpl->assign( 'htaccessWorking', $htaccessWorking );
|
||||||
|
$tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize);
|
||||||
$tmpl->printPage();
|
$tmpl->printPage();
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -57,7 +57,7 @@ foreach( explode( "/", $dir ) as $i ){
|
||||||
|
|
||||||
// return template
|
// return template
|
||||||
$tmpl = new OC_TEMPLATE( "files", "index", "user" );
|
$tmpl = new OC_TEMPLATE( "files", "index", "user" );
|
||||||
$tmpl->assign( "files", $files );
|
$tmpl->assign( 'files', $files );
|
||||||
$tmpl->assign( "breadcrumb", $breadcrumb );
|
$tmpl->assign( "breadcrumb", $breadcrumb );
|
||||||
$tmpl->printPage();
|
$tmpl->printPage();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<form>
|
<form action='#' method='post'>
|
||||||
|
<?php if($_['htaccessWorking']):?>
|
||||||
|
Maximum upload size <input name='maxUploadSize' value='<?php echo $_['uploadMaxFilesize'] ?>'/><br/>
|
||||||
|
<?php endif;?>
|
||||||
<input type="checkbox" /> Allow public folders<br>
|
<input type="checkbox" /> Allow public folders<br>
|
||||||
|
|
||||||
(if public is enabled)<br>
|
(if public is enabled)<br>
|
||||||
|
@ -9,4 +12,5 @@
|
||||||
|
|
||||||
<input type="checkbox" /> Allow downloading shared files<br>
|
<input type="checkbox" /> Allow downloading shared files<br>
|
||||||
<input type="checkbox" /> Allow uploading in shared directory<br>
|
<input type="checkbox" /> Allow uploading in shared directory<br>
|
||||||
|
<input type='submit' value='Save'/>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -291,6 +291,24 @@ class OC_FILES {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set the maximum upload size limit for apache hosts using .htaccess
|
||||||
|
* @param int size filesisze in bytes
|
||||||
|
*/
|
||||||
|
static function setUploadLimit($size){
|
||||||
|
global $SERVERROOT;
|
||||||
|
global $WEBROOT;
|
||||||
|
$size=OC_HELPER::humanFileSize($size);
|
||||||
|
echo $size;
|
||||||
|
$size=substr($size,0,-1);//strip the B
|
||||||
|
$size=str_replace(' ','',$size); //remove the space between the size and the postfix
|
||||||
|
$content = "ErrorDocument 404 /$WEBROOT/templates/404.php\n";//custom 404 error page
|
||||||
|
$content.= "php_value upload_max_filesize $size\n";//upload limit
|
||||||
|
$content.= "php_value post_max_size $size\n";
|
||||||
|
$content.= "SetEnv htaccessWorking true\n";
|
||||||
|
@file_put_contents($SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function zipAddDir($dir,$zip,$internalDir=''){
|
function zipAddDir($dir,$zip,$internalDir=''){
|
||||||
|
|
|
@ -167,7 +167,10 @@ class OC_SETUP {
|
||||||
private static function createHtaccess() {
|
private static function createHtaccess() {
|
||||||
global $SERVERROOT;
|
global $SERVERROOT;
|
||||||
global $WEBROOT;
|
global $WEBROOT;
|
||||||
$content = "ErrorDocument 404 /$WEBROOT/templates/404.php\n";
|
$content = "ErrorDocument 404 /$WEBROOT/templates/404.php\n";//custom 404 error page
|
||||||
|
$content.= "php_value upload_max_filesize 20M\n";//upload limit
|
||||||
|
$content.= "php_value post_max_size 20M\n";
|
||||||
|
$content.= "SetEnv htaccessWorking true\n";
|
||||||
@file_put_contents($SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it
|
@file_put_contents($SERVERROOT.'/.htaccess', $content); //supress errors in case we don't have permissions for it
|
||||||
|
|
||||||
$content = "deny from all";
|
$content = "deny from all";
|
||||||
|
|
Loading…
Reference in New Issue