forked from extern/egroupware
fix tons of IDE warnings
This commit is contained in:
parent
1affa826b1
commit
8707ea68b5
@ -181,8 +181,6 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
*/
|
*/
|
||||||
static function copy($from,$to)
|
static function copy($from,$to)
|
||||||
{
|
{
|
||||||
$ret = false;
|
|
||||||
|
|
||||||
$old_props = self::file_exists($to) ? self::propfind($to,null) : array();
|
$old_props = self::file_exists($to) ? self::propfind($to,null) : array();
|
||||||
// copy properties (eg. file comment), if there are any and evtl. existing old properties
|
// copy properties (eg. file comment), if there are any and evtl. existing old properties
|
||||||
$props = self::propfind($from,null);
|
$props = self::propfind($from,null);
|
||||||
@ -373,12 +371,12 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
{
|
{
|
||||||
if (!self::$is_root)
|
if (!self::$is_root)
|
||||||
{
|
{
|
||||||
if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') permission denied, you are NOT root!');
|
if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).','.array2string($path).') permission denied, you are NOT root!');
|
||||||
return false; // only root can mount
|
return false; // only root can mount
|
||||||
}
|
}
|
||||||
if (!isset(self::$fstab[$path]) && ($path = array_search($path,self::$fstab)) === false)
|
if (!isset(self::$fstab[$path]) && ($path = array_search($path,self::$fstab)) === false)
|
||||||
{
|
{
|
||||||
if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') NOT mounted!');
|
if (self::LOG_LEVEL > 0) error_log(__METHOD__.'('.array2string($path).') NOT mounted!');
|
||||||
return false; // $path not mounted
|
return false; // $path not mounted
|
||||||
}
|
}
|
||||||
unset(self::$fstab[$path]);
|
unset(self::$fstab[$path]);
|
||||||
@ -390,7 +388,7 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
{
|
{
|
||||||
$GLOBALS['egw']->invalidate_session_cache();
|
$GLOBALS['egw']->invalidate_session_cache();
|
||||||
}
|
}
|
||||||
if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($url).','.array2string($path).') returns true (successful unmount).');
|
if (self::LOG_LEVEL > 1) error_log(__METHOD__.'('.array2string($path).') returns true (successful unmount).');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,13 +503,13 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
}
|
}
|
||||||
if ($is_dir && (!isset($options['maxdepth']) || ($options['maxdepth'] > 0 && $options['depth'] < $options['maxdepth'])) && ($dir = @opendir($path)))
|
if ($is_dir && (!isset($options['maxdepth']) || ($options['maxdepth'] > 0 && $options['depth'] < $options['maxdepth'])) && ($dir = @opendir($path)))
|
||||||
{
|
{
|
||||||
while(($file = readdir($dir)) !== false)
|
while(($fname = readdir($dir)) !== false)
|
||||||
{
|
{
|
||||||
if ($file == '.' || $file == '..') continue; // ignore current and parent dir!
|
if ($fname == '.' || $fname == '..') continue; // ignore current and parent dir!
|
||||||
|
|
||||||
if (self::is_hidden($file) && !$options['hidden']) continue; // ignore hidden files
|
if (self::is_hidden($fname) && !$options['hidden']) continue; // ignore hidden files
|
||||||
|
|
||||||
$file = self::concat($path,$file);
|
$file = self::concat($path, $fname);
|
||||||
|
|
||||||
if ((int)$options['mindepth'] <= 1)
|
if ((int)$options['mindepth'] <= 1)
|
||||||
{
|
{
|
||||||
@ -522,7 +520,7 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
{
|
{
|
||||||
$opts = $options;
|
$opts = $options;
|
||||||
if ($opts['mindepth']) $opts['mindepth']--;
|
if ($opts['mindepth']) $opts['mindepth']--;
|
||||||
if ($opts['maxdepth']) $opts['depth']++;;
|
if ($opts['maxdepth']) $opts['depth']++;
|
||||||
unset($opts['order']);
|
unset($opts['order']);
|
||||||
unset($opts['limit']);
|
unset($opts['limit']);
|
||||||
foreach(self::find($options['url']?$file:self::parse_url($file,PHP_URL_PATH),$opts,true) as $p => $s)
|
foreach(self::find($options['url']?$file:self::parse_url($file,PHP_URL_PATH),$opts,true) as $p => $s)
|
||||||
@ -671,7 +669,7 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
{
|
{
|
||||||
list($type,$subtype) = explode('/',$options['mime']);
|
list($type,$subtype) = explode('/',$options['mime']);
|
||||||
// no subtype (eg. 'image') --> check only the main type
|
// no subtype (eg. 'image') --> check only the main type
|
||||||
if ($sub_type || substr($stat['mime'],0,strlen($type)+1) != $type.'/')
|
if ($subtype || substr($stat['mime'],0,strlen($type)+1) != $type.'/')
|
||||||
{
|
{
|
||||||
return; // wrong mime-type
|
return; // wrong mime-type
|
||||||
}
|
}
|
||||||
@ -921,7 +919,7 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
*
|
*
|
||||||
* Does NOT check if user has the rights to set the extended acl for the given url/path!
|
* Does NOT check if user has the rights to set the extended acl for the given url/path!
|
||||||
*
|
*
|
||||||
* @param string $path string with path
|
* @param string $url string with path
|
||||||
* @param int $rights =null rights to set, or null to delete the entry
|
* @param int $rights =null rights to set, or null to delete the entry
|
||||||
* @param int|boolean $owner =null owner for whom to set the rights, null for the current user, or false to delete all rights for $path
|
* @param int|boolean $owner =null owner for whom to set the rights, null for the current user, or false to delete all rights for $path
|
||||||
* @return boolean true if acl is set/deleted, false on error
|
* @return boolean true if acl is set/deleted, false on error
|
||||||
@ -1003,6 +1001,7 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
}
|
}
|
||||||
foreach(explode(',',$set) as $s)
|
foreach(explode(',',$set) as $s)
|
||||||
{
|
{
|
||||||
|
$matches = null;
|
||||||
if (!preg_match($use='/^([ugoa]*)([+=-]+)([rwx]+)$/',$s,$matches))
|
if (!preg_match($use='/^([ugoa]*)([+=-]+)([rwx]+)$/',$s,$matches))
|
||||||
{
|
{
|
||||||
$use = str_replace(array('/','^','$','(',')'),'',$use);
|
$use = str_replace(array('/','^','$','(',')'),'',$use);
|
||||||
@ -1164,12 +1163,13 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
*
|
*
|
||||||
* From PHP ini_get docs, Ivo Mandalski 15-Nov-2011 08:27
|
* From PHP ini_get docs, Ivo Mandalski 15-Nov-2011 08:27
|
||||||
*/
|
*/
|
||||||
static function int_size($val)
|
static function int_size($_val)
|
||||||
{
|
{
|
||||||
if(empty($val))return 0;
|
if(empty($_val))return 0;
|
||||||
|
|
||||||
$val = trim($val);
|
$val = trim($_val);
|
||||||
|
|
||||||
|
$matches = null;
|
||||||
preg_match('#([0-9]+)[\s]*([a-z]+)#i', $val, $matches);
|
preg_match('#([0-9]+)[\s]*([a-z]+)#i', $val, $matches);
|
||||||
|
|
||||||
$last = '';
|
$last = '';
|
||||||
@ -1200,12 +1200,12 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
/**
|
/**
|
||||||
* like basename($path), but also working if the 1. char of the basename is non-ascii
|
* like basename($path), but also working if the 1. char of the basename is non-ascii
|
||||||
*
|
*
|
||||||
* @param string $path
|
* @param string $_path
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
static function basename($path)
|
static function basename($_path)
|
||||||
{
|
{
|
||||||
list($path,$query) = explode('?',$path); // remove query
|
list($path) = explode('?',$_path); // remove query
|
||||||
$parts = explode('/',$path);
|
$parts = explode('/',$path);
|
||||||
|
|
||||||
return array_pop($parts);
|
return array_pop($parts);
|
||||||
@ -1216,12 +1216,12 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
*
|
*
|
||||||
* Also works around PHP under Windows returning dirname('/something') === '\\', which is NOT understood by EGroupware's VFS!
|
* Also works around PHP under Windows returning dirname('/something') === '\\', which is NOT understood by EGroupware's VFS!
|
||||||
*
|
*
|
||||||
* @param string $path path or url
|
* @param string $_url path or url
|
||||||
* @return string|boolean parent or false if there's none ($path == '/')
|
* @return string|boolean parent or false if there's none ($path == '/')
|
||||||
*/
|
*/
|
||||||
static function dirname($url)
|
static function dirname($_url)
|
||||||
{
|
{
|
||||||
list($url,$query) = explode('?',$url,2); // strip the query first, as it can contain slashes
|
list($url,$query) = explode('?',$_url,2); // strip the query first, as it can contain slashes
|
||||||
|
|
||||||
if ($url == '/' || $url[0] != '/' && self::parse_url($url,PHP_URL_PATH) == '/')
|
if ($url == '/' || $url[0] != '/' && self::parse_url($url,PHP_URL_PATH) == '/')
|
||||||
{
|
{
|
||||||
@ -1262,26 +1262,26 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
*
|
*
|
||||||
* Also normalizing the path, as the relative path can contain ../
|
* Also normalizing the path, as the relative path can contain ../
|
||||||
*
|
*
|
||||||
* @param string $url base url or path, might end in a /
|
* @param string $_url base url or path, might end in a /
|
||||||
* @param string $relative relative path to add to $url
|
* @param string $relative relative path to add to $url
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
static function concat($url,$relative)
|
static function concat($_url,$relative)
|
||||||
{
|
{
|
||||||
list($url,$query) = explode('?',$url,2);
|
list($url,$query) = explode('?',$_url,2);
|
||||||
if (substr($url,-1) == '/') $url = substr($url,0,-1);
|
if (substr($url,-1) == '/') $url = substr($url,0,-1);
|
||||||
$url = ($relative === '' || $relative[0] == '/' ? $url.$relative : $url.'/'.$relative);
|
$ret = ($relative === '' || $relative[0] == '/' ? $url.$relative : $url.'/'.$relative);
|
||||||
|
|
||||||
// now normalize the path (remove "/something/..")
|
// now normalize the path (remove "/something/..")
|
||||||
while (strpos($url,'/../') !== false)
|
while (strpos($ret,'/../') !== false)
|
||||||
{
|
{
|
||||||
list($a,$b) = explode('/../',$url,2);
|
list($a_str,$b_str) = explode('/../',$ret,2);
|
||||||
$a = explode('/',$a);
|
$a = explode('/',$a_str);
|
||||||
array_pop($a);
|
array_pop($a);
|
||||||
$b = explode('/',$b);
|
$b = explode('/',$b_str);
|
||||||
$url = implode('/',array_merge($a,$b));
|
$ret = implode('/',array_merge($a,$b));
|
||||||
}
|
}
|
||||||
return $url.($query ? (strpos($url,'?')===false ? '?' : '&').$query : '');
|
return $ret.($query ? (strpos($url,'?')===false ? '?' : '&').$query : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1332,21 +1332,20 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
/**
|
/**
|
||||||
* Download the given file list as a ZIP
|
* Download the given file list as a ZIP
|
||||||
*
|
*
|
||||||
* @param array $files List of files to include in the zip
|
* @param array $_files List of files to include in the zip
|
||||||
* @param string $name optional Zip file name. If not provided, it will be determined automatically from the files
|
* @param string $name optional Zip file name. If not provided, it will be determined automatically from the files
|
||||||
*
|
*
|
||||||
* @return undefined
|
* @return undefined
|
||||||
*/
|
*/
|
||||||
public static function download_zip(Array $files, $name = false)
|
public static function download_zip(Array $_files, $name = false)
|
||||||
{
|
{
|
||||||
error_log(__METHOD__ . ': '.implode(',',$files));
|
error_log(__METHOD__ . ': '.implode(',',$_files));
|
||||||
|
|
||||||
// Create zip file
|
// Create zip file
|
||||||
$zip_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'zip');
|
$zip_file = tempnam($GLOBALS['egw_info']['server']['temp_dir'], 'zip');
|
||||||
|
|
||||||
$zip = new ZipArchive();
|
$zip = new ZipArchive();
|
||||||
$result = $zip->open($zip_file, ZipArchive::OVERWRITE);
|
if (!$zip->open($zip_file, ZipArchive::OVERWRITE))
|
||||||
if($result !== TRUE)
|
|
||||||
{
|
{
|
||||||
throw new egw_exception("Cannot open zip file for writing.");
|
throw new egw_exception("Cannot open zip file for writing.");
|
||||||
}
|
}
|
||||||
@ -1354,12 +1353,12 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
// Find lowest common directory, to use relative paths
|
// Find lowest common directory, to use relative paths
|
||||||
// eg: User selected /home/nathan/picture.jpg, /home/Pictures/logo.jpg
|
// eg: User selected /home/nathan/picture.jpg, /home/Pictures/logo.jpg
|
||||||
// We want /home
|
// We want /home
|
||||||
$paths = array();
|
$dirs = array();
|
||||||
foreach($files as $file)
|
foreach($_files as $file)
|
||||||
{
|
{
|
||||||
$paths[] = self::dirname($file);
|
$dirs[] = self::dirname($file);
|
||||||
}
|
}
|
||||||
$paths = array_unique($paths);
|
$paths = array_unique($dirs);
|
||||||
if(count($paths) > 0)
|
if(count($paths) > 0)
|
||||||
{
|
{
|
||||||
// Shortest to longest
|
// Shortest to longest
|
||||||
@ -1368,19 +1367,19 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Start with shortest, pop off sub-directories that don't match
|
// Start with shortest, pop off sub-directories that don't match
|
||||||
$base_dir = explode('/',$paths[0]);
|
$parts = explode('/',$paths[0]);
|
||||||
foreach($paths as $index => $path)
|
foreach($paths as $path)
|
||||||
{
|
{
|
||||||
$dirs = explode('/',$path);
|
$dirs = explode('/',$path);
|
||||||
foreach($dirs as $dir_index => $dir)
|
foreach($dirs as $dir_index => $dir)
|
||||||
{
|
{
|
||||||
if($base_dir[$dir_index] && $base_dir[$dir_index] != $dir)
|
if($parts[$dir_index] && $parts[$dir_index] != $dir)
|
||||||
{
|
{
|
||||||
unset($base_dir[$dir_index]);
|
unset($parts[$dir_index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$base_dir = implode('/', $base_dir);
|
$base_dir = implode('/', $parts);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1400,9 +1399,9 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
$filename = $GLOBALS['egw_info']['server']['site_title'] . '_' .
|
$filename = $GLOBALS['egw_info']['server']['site_title'] . '_' .
|
||||||
str_replace($replace,'_',(
|
str_replace($replace,'_',(
|
||||||
$name ? $name : (
|
$name ? $name : (
|
||||||
count($files) == 1 ?
|
count($_files) == 1 ?
|
||||||
// Just one file (hopefully a directory?) selected
|
// Just one file (hopefully a directory?) selected
|
||||||
self::basename($files[0]) :
|
self::basename($_files[0]) :
|
||||||
// Use the lowest common directory (eg: Infolog, Open, nathan)
|
// Use the lowest common directory (eg: Infolog, Open, nathan)
|
||||||
self::basename($base_dir))
|
self::basename($base_dir))
|
||||||
)) . '.zip';
|
)) . '.zip';
|
||||||
@ -1414,7 +1413,7 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Go into directories, find them all
|
// Go into directories, find them all
|
||||||
$files = self::find($files);
|
$files = self::find($_files);
|
||||||
$links = array();
|
$links = array();
|
||||||
|
|
||||||
// We need to remove them _after_ we're done
|
// We need to remove them _after_ we're done
|
||||||
@ -1424,13 +1423,13 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
set_time_limit(count($files));
|
set_time_limit(count($files));
|
||||||
|
|
||||||
// Add files to archive
|
// Add files to archive
|
||||||
foreach($files as $idx => &$addfile)
|
foreach($files as &$addfile)
|
||||||
{
|
{
|
||||||
// Use relative paths inside zip
|
// Use relative paths inside zip
|
||||||
$_name = str_replace($base_dir, '', $addfile);
|
$relative = substr($addfile, strlen($base_dir));
|
||||||
|
|
||||||
// Use safe names - replace unsafe chars, convert to ASCII (ZIP spec says CP437, but we'll try)
|
// Use safe names - replace unsafe chars, convert to ASCII (ZIP spec says CP437, but we'll try)
|
||||||
$path = explode('/',$_name);
|
$path = explode('/',$relative);
|
||||||
$_name = translation::convert(translation::to_ascii(implode('/', str_replace($replace,'_',$path))),false,'ASCII');
|
$_name = translation::convert(translation::to_ascii(implode('/', str_replace($replace,'_',$path))),false,'ASCII');
|
||||||
|
|
||||||
// Don't go infinite with app entries
|
// Don't go infinite with app entries
|
||||||
@ -1467,10 +1466,10 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
$comment = self::find_prop($props,'comment');
|
$comment = self::find_prop($props,'comment');
|
||||||
if($comment)
|
if($comment)
|
||||||
{
|
{
|
||||||
$zip->setCommentName($_name, $prop['val']);
|
$zip->setCommentName($_name, $comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$props = null;
|
unset($props);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1603,6 +1602,7 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
$ret = true;
|
$ret = true;
|
||||||
}
|
}
|
||||||
catch(egw_exception_db $e) {
|
catch(egw_exception_db $e) {
|
||||||
|
unset($e);
|
||||||
$ret = false; // there's already a lock
|
$ret = false; // there's already a lock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1696,7 +1696,7 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
'content' => $content,
|
'content' => $content,
|
||||||
))))
|
))))
|
||||||
{
|
{
|
||||||
foreach($vfs_extra as $app => $data)
|
foreach($vfs_extra as $data)
|
||||||
{
|
{
|
||||||
$extra = $extra ? array_merge($extra, $data) : $data;
|
$extra = $extra ? array_merge($extra, $data) : $data;
|
||||||
}
|
}
|
||||||
@ -1809,11 +1809,11 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
else if ($file && $mime_main == 'image' && in_array($mime_sub, array('png','jpeg','jpg','gif','bmp')) &&
|
else if ($file && $mime_main == 'image' && in_array($mime_sub, array('png','jpeg','jpg','gif','bmp')) &&
|
||||||
(string)$GLOBALS['egw_info']['server']['link_list_thumbnail'] != '0' &&
|
(string)$GLOBALS['egw_info']['server']['link_list_thumbnail'] != '0' &&
|
||||||
(string)$GLOBALS['egw_info']['user']['preferences']['common']['link_list_thumbnail'] != '0' &&
|
(string)$GLOBALS['egw_info']['user']['preferences']['common']['link_list_thumbnail'] != '0' &&
|
||||||
(!is_array($value) && ($stat = egw_vfs::stat($file)) ? $stat['size'] : $value['size']) < 1500000)
|
($stat = egw_vfs::stat($file)) && $stat['size'] < 1500000)
|
||||||
{
|
{
|
||||||
if (substr($file, 0, 6) == '/apps/')
|
if (substr($file, 0, 6) == '/apps/')
|
||||||
{
|
{
|
||||||
$file = self::parse_url(egw_vfs::resolve_url_symlinks($path), PHP_URL_PATH);
|
$file = self::parse_url(egw_vfs::resolve_url_symlinks($file), PHP_URL_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Assemble the thumbnail parameters
|
//Assemble the thumbnail parameters
|
||||||
@ -1828,7 +1828,7 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
list($app, $name) = explode("/", egw_vfs::mime_icon($mime), 2);
|
list($app, $name) = explode("/", egw_vfs::mime_icon($mime), 2);
|
||||||
$image = $GLOBALS['egw']->common->image($app, $name);
|
$image = common::image($app, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $image;
|
return $image;
|
||||||
@ -1878,10 +1878,6 @@ class egw_vfs extends vfs_stream_wrapper
|
|||||||
// Create the target directory
|
// Create the target directory
|
||||||
egw_vfs::mkdir($target,null,STREAM_MKDIR_RECURSIVE);
|
egw_vfs::mkdir($target,null,STREAM_MKDIR_RECURSIVE);
|
||||||
|
|
||||||
$files = egw_vfs::find($file, array(
|
|
||||||
"hidden" => true
|
|
||||||
));
|
|
||||||
|
|
||||||
$copied[] = $file;
|
$copied[] = $file;
|
||||||
$copied[] = $target; // < newly created folder must not be copied again!
|
$copied[] = $target; // < newly created folder must not be copied again!
|
||||||
if (egw_vfs::copy_files(egw_vfs::find($file), $target,
|
if (egw_vfs::copy_files(egw_vfs::find($file), $target,
|
||||||
|
Loading…
Reference in New Issue
Block a user