forked from extern/egroupware
Add function to get integer/byte filesize from human readable
This commit is contained in:
parent
fe7814b64c
commit
2764e9529c
@ -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))
|
||||
|
@ -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',
|
||||
|
@ -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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user