Commit ee21db69 by Christian Rafael Committed by Scott

Fixed problems with a types and refactored the code of files sizes conversions

parent 8f2fa77b
......@@ -1206,7 +1206,7 @@ function qa_html_page_links($request, $start, $pagesize, $count, $prevnext, $par
if (qa_to_override(__FUNCTION__)) { $args=func_get_args(); return qa_call_override(__FUNCTION__, $args); }
$thispage = 1 + floor($start / $pagesize);
$lastpage = ceil(min($count, 1 + QA_MAX_LIMIT_START) / $pagesize);
$lastpage = ceil(min((int)$count, 1 + QA_MAX_LIMIT_START) / $pagesize);
if ($thispage > 1 || $lastpage > $thispage) {
$links = array('label' => qa_lang_html('main/page_label'), 'items' => array());
......
......@@ -98,7 +98,7 @@ function qa_upload_file($localfilename, $sourcefilename, $maxfilesize = null, $o
$maxfilesize = qa_get_max_upload_size();
if ($filesize <= 0 || $filesize > $maxfilesize) { // if file was too big for PHP, $filesize will be zero
$result['error'] = qa_lang_sub('main/max_upload_size_x', qa_format_number($maxfilesize / 1048576, 1) . 'MB');
$result['error'] = qa_lang_sub('main/max_upload_size_x', qa_format_number($maxfilesize / pow(1024, 2), 1) . 'MB');
return $result;
}
......
......@@ -1284,11 +1284,13 @@ function qa_post_limit_exceeded()
*/
function convert_to_bytes($unit, $value)
{
$value = (int) $value;
switch (strtolower($unit)) {
case 'g':
return $value * 1073741824;
return $value * pow(1024, 3);
case 'm':
return $value * 1048576;
return $value * pow(1024, 2);
case 'k':
return $value * 1024;
default:
......
......@@ -113,9 +113,9 @@ class qa_wysiwyg_editor
array(
'id' => 'wysiwyg_editor_upload_max_size_display',
'label' => 'Maximum size of uploads:',
'suffix' => 'MB (max '.qa_html(qa_format_number($this->bytes_to_mega(qa_get_max_upload_size()))).')',
'suffix' => 'MB (max '.qa_html(number_format($this->bytes_to_mega(qa_get_max_upload_size()), 1)).')',
'type' => 'number',
'value' => qa_html(number_format($this->bytes_to_mega(qa_opt('wysiwyg_editor_upload_max_size')))),
'value' => qa_html(number_format($this->bytes_to_mega(qa_opt('wysiwyg_editor_upload_max_size')), 1)),
'tags' => 'name="wysiwyg_editor_upload_max_size_field"',
),
......
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