Add function to get integer/byte filesize from human readable

This commit is contained in:
Nathan Gray 2012-05-14 19:10:45 +00:00
parent fe7814b64c
commit 2764e9529c
3 changed files with 40 additions and 1 deletions

View File

@ -1892,7 +1892,7 @@ class egw_db
$this->column_data_implode(',',$data,True,true,$table_def['fd']).' WHERE '.$where;
}
$ret = $this->query($sql,$line,$file,0,-1,$inputarr);
if ($this->Debug) echo "<p>db::query('$sql',$line,$file) = '$ret'</p>\n";
if ($this->Debug) echo "<p>db::query('$sql',$line,$file)</p>\n";
}
// if we have any blobs to update, we do so now
if (($ret || !count($data)) && count($blobs2update))

View File

@ -120,6 +120,7 @@ class egw_link extends solink
*/
static $app_register = array(
'home-accounts' => array( // user need run-rights for home
'app' => 'home',
'name' => 'Accounts',
'icon' => 'addressbook/accounts',
'query' => 'accounts::link_query',

View File

@ -1143,6 +1143,44 @@ class egw_vfs extends vfs_stream_wrapper
return sprintf('%3.1lfG',(float)$size/(1024*1024*1024));
}
/**
* Size in bytes, from human readable
*
* From PHP ini_get docs, Ivo Mandalski 15-Nov-2011 08:27
*/
static function int_size($val)
{
if(empty($val))return 0;
$val = trim($val);
preg_match('#([0-9]+)[\s]*([a-z]+)#i', $val, $matches);
$last = '';
if(isset($matches[2])){
$last = $matches[2];
}
if(isset($matches[1])){
$val = (int) $matches[1];
}
switch (strtolower($last))
{
case 'g':
case 'gb':
$val *= 1024;
case 'm':
case 'mb':
$val *= 1024;
case 'k':
case 'kb':
$val *= 1024;
}
return (int) $val;
}
/**
* like basename($path), but also working if the 1. char of the basename is non-ascii
*