We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 383e6c73 authored by Evan Prodromou's avatar Evan Prodromou

Merge branch '0.7.x' of git://gitorious.org/laconica/sgmurphy-clone into sgmurphy-clone/0.7.x

parents 7ea136ee d4bdb2dc
...@@ -75,7 +75,7 @@ class AvatarsettingsAction extends AccountSettingsAction ...@@ -75,7 +75,7 @@ class AvatarsettingsAction extends AccountSettingsAction
function getInstructions() function getInstructions()
{ {
return _('You can upload your personal avatar.'); return _('You can upload your personal avatar. The maximum file size is '.ImageFile::maxFileSize().'.');
} }
/** /**
...@@ -155,7 +155,7 @@ class AvatarsettingsAction extends AccountSettingsAction ...@@ -155,7 +155,7 @@ class AvatarsettingsAction extends AccountSettingsAction
$this->element('input', array('name' => 'MAX_FILE_SIZE', $this->element('input', array('name' => 'MAX_FILE_SIZE',
'type' => 'hidden', 'type' => 'hidden',
'id' => 'MAX_FILE_SIZE', 'id' => 'MAX_FILE_SIZE',
'value' => MAX_AVATAR_SIZE)); 'value' => ImageFile::maxFileSize(true)));
$this->elementEnd('li'); $this->elementEnd('li');
$this->elementEnd('ul'); $this->elementEnd('ul');
......
...@@ -152,7 +152,7 @@ class GrouplogoAction extends Action ...@@ -152,7 +152,7 @@ class GrouplogoAction extends Action
function getInstructions() function getInstructions()
{ {
return _('You can upload a logo image for your group.'); return _('You can upload a logo image for your group. The maximum file size is '.ImageFile::maxFileSize().'.');
} }
/** /**
...@@ -229,7 +229,7 @@ class GrouplogoAction extends Action ...@@ -229,7 +229,7 @@ class GrouplogoAction extends Action
$this->element('input', array('name' => 'MAX_FILE_SIZE', $this->element('input', array('name' => 'MAX_FILE_SIZE',
'type' => 'hidden', 'type' => 'hidden',
'id' => 'MAX_FILE_SIZE', 'id' => 'MAX_FILE_SIZE',
'value' => MAX_AVATAR_SIZE)); 'value' => ImageFile::maxFileSize(true)));
$this->elementEnd('li'); $this->elementEnd('li');
$this->elementEnd('ul'); $this->elementEnd('ul');
......
...@@ -24,7 +24,6 @@ define('LACONICA_VERSION', '0.7.0'); ...@@ -24,7 +24,6 @@ define('LACONICA_VERSION', '0.7.0');
define('AVATAR_PROFILE_SIZE', 96); define('AVATAR_PROFILE_SIZE', 96);
define('AVATAR_STREAM_SIZE', 48); define('AVATAR_STREAM_SIZE', 48);
define('AVATAR_MINI_SIZE', 24); define('AVATAR_MINI_SIZE', 24);
define('MAX_AVATAR_SIZE', 256 * 1024);
define('NOTICES_PER_PAGE', 20); define('NOTICES_PER_PAGE', 20);
define('PROFILES_PER_PAGE', 20); define('PROFILES_PER_PAGE', 20);
......
...@@ -72,7 +72,7 @@ class ImageFile ...@@ -72,7 +72,7 @@ class ImageFile
break; break;
case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE: case UPLOAD_ERR_FORM_SIZE:
throw new Exception(_('That file is too big.')); throw new Exception(_('That file is too big. The maximum file size is '.$this->maxFileSize().'.'));
return; return;
case UPLOAD_ERR_PARTIAL: case UPLOAD_ERR_PARTIAL:
@unlink($_FILES[$param]['tmp_name']); @unlink($_FILES[$param]['tmp_name']);
...@@ -182,4 +182,32 @@ class ImageFile ...@@ -182,4 +182,32 @@ class ImageFile
{ {
@unlink($this->filename); @unlink($this->filename);
} }
static function maxFileSize($return_bytes = false)
{
$limit = min(ImageFile::strToInt(ini_get('post_max_size')), ImageFile::strToInt(ini_get('upload_max_filesize')), ImageFile::strToInt(ini_get('memory_limit')));
if ($return_bytes) {
return $limit;
}
return ($limit/(1024*1024)).'MB';
}
static function strToInt($str)
{
$unit = substr($str, -1);
$num = substr($str, 0, -1);
switch(strtoupper($unit)){
case 'G':
$num *= 1024;
case 'M':
$num *= 1024;
case 'K':
$num *= 1024;
}
return $num;
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment