EGroupware /
egroupware
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * EGroupware - Filemanager - test script |
||
| 4 | * |
||
| 5 | * @link http://www.egroupware.org |
||
| 6 | * @package filemanager |
||
| 7 | * @author Ralf Becker <RalfBecker-AT-outdoor-training.de> |
||
| 8 | * @copyright (c) 2009-16 by Ralf Becker <RalfBecker-AT-outdoor-training.de> |
||
| 9 | * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
||
| 10 | * @version $Id$ |
||
| 11 | */ |
||
| 12 | |||
| 13 | use EGroupware\Api; |
||
| 14 | use EGroupware\Api\Vfs; |
||
| 15 | |||
| 16 | $GLOBALS['egw_info']['flags'] = array( |
||
| 17 | 'currentapp' => 'filemanager' |
||
| 18 | ); |
||
| 19 | include('../header.inc.php'); |
||
| 20 | |||
| 21 | if (!($path = Api\Cache::getSession('filemanger','test'))) |
||
| 22 | { |
||
| 23 | $path = '/home/'.$GLOBALS['egw_info']['user']['account_lid']; |
||
| 24 | } |
||
| 25 | if (isset($_REQUEST['path'])) $path = $_REQUEST['path']; |
||
| 26 | echo Api\Html::form("<p>Path: ".Api\Html::input('path',$path,'text','size="40"'). |
||
| 27 | Api\Html::submit_button('',lang('Submit'))."</p>\n",array(),'','','','','GET'); |
||
| 28 | |||
| 29 | if (isset($path) && !empty($path)) |
||
| 30 | { |
||
| 31 | if ($path[0] != '/') |
||
| 32 | { |
||
| 33 | throw new Api\Exception\WrongUserinput('Not an absolute path!'); |
||
| 34 | } |
||
| 35 | Api\Cache::setSession('filemanger','test',$path); |
||
| 36 | |||
| 37 | echo "<h2>"; |
||
| 38 | foreach(explode('/',$path) as $n => $part) |
||
| 39 | { |
||
| 40 | $p .= ($p != '/' ? '/' : '').$part; |
||
| 41 | echo ($n > 1 ? ' / ' : '').Api\Html::a_href($n ? $part : ' / ','/filemanager/test.php',array('path'=>$p,'cd'=>'no')); |
||
| 42 | } |
||
| 43 | echo "</h2>\n"; |
||
| 44 | |||
| 45 | echo "<p><b>Vfs::propfind('$path')</b>=".array2string(Vfs::propfind($path))."</p>\n"; |
||
| 46 | echo "<p><b>Vfs::resolve_url('$path')</b>=".array2string(Vfs::resolve_url($path))."</p>\n"; |
||
| 47 | |||
| 48 | $is_dir = Vfs::is_dir($path); |
||
| 49 | echo "<p><b>is_dir('$path')</b>=".array2string($is_dir)."</p>\n"; |
||
| 50 | |||
| 51 | $time = microtime(true); |
||
| 52 | $stat = Vfs::stat($path); |
||
| 53 | $stime = number_format(1000*(microtime(true)-$time),1); |
||
| 54 | |||
| 55 | $time2 = microtime(true); |
||
| 56 | if ($is_dir)// && ($d = Vfs::opendir($path))) |
||
| 57 | { |
||
| 58 | $files = array(); |
||
| 59 | //while(($file = readdir($d))) |
||
| 60 | foreach(Vfs::scandir($path) as $file) |
||
| 61 | { |
||
| 62 | if (Vfs::is_readable($fpath=Vfs::concat($path,$file))) |
||
| 63 | { |
||
| 64 | $file = Api\Html::a_href($file,'/filemanager/test.php',array('path'=>$fpath,'cd'=>'no')); |
||
| 65 | } |
||
| 66 | $file .= ' ('.Vfs::mime_content_type($fpath).')'; |
||
| 67 | $files[] = $file; |
||
| 68 | } |
||
| 69 | //closedir($d); |
||
| 70 | $time2f = number_format(1000*(microtime(true)-$time2),1); |
||
| 71 | echo "<p>".($files ? 'Directory' : 'Empty directory')." took $time2f ms</p>\n"; |
||
| 72 | if($files) echo '<ol><li>'.implode("</li>\n<li>",$files).'</ol>'."\n"; |
||
| 73 | } |
||
| 74 | |||
| 75 | echo "<p><b>stat('$path')</b> took $stime ms (mode = ".(isset($stat['mode'])?sprintf('%o',$stat['mode']).' = '.Vfs::int2mode($stat['mode']):'NULL').')'; |
||
| 76 | if (is_array($stat)) |
||
|
0 ignored issues
–
show
introduced
by
Loading history...
|
|||
| 77 | { |
||
| 78 | _debug_array($stat); |
||
| 79 | } |
||
| 80 | else |
||
| 81 | { |
||
| 82 | echo "<p>".array2string($stat)."</p>\n"; |
||
| 83 | } |
||
| 84 | |||
| 85 | echo "<p><b>Vfs::is_readable('$path')</b>=".array2string(Vfs::is_readable($path))."</p>\n"; |
||
| 86 | echo "<p><b>Vfs::is_writable('$path')</b>=".array2string(Vfs::is_writable($path))."</p>\n"; |
||
| 87 | |||
| 88 | echo "<p><b>is_link('$path')</b>=".array2string(Vfs::is_link($path))."</p>\n"; |
||
| 89 | echo "<p><b>readlink('$path')</b>=".array2string(Vfs::readlink($path))."</p>\n"; |
||
| 90 | $time3 = microtime(true); |
||
| 91 | $lstat = Vfs::lstat($path); |
||
| 92 | $time3f = number_format(1000*(microtime(true)-$time3),1); |
||
| 93 | echo "<p><b>lstat('$path')</b> took $time3f ms (mode = ".(isset($lstat['mode'])?sprintf('%o',$lstat['mode']).' = '.Vfs::int2mode($lstat['mode']):'NULL').')'; |
||
| 94 | if (is_array($lstat)) |
||
|
0 ignored issues
–
show
|
|||
| 95 | { |
||
| 96 | _debug_array($lstat); |
||
| 97 | } |
||
| 98 | else |
||
| 99 | { |
||
| 100 | echo "<p>".array2string($lstat)."</p>\n"; |
||
| 101 | } |
||
| 102 | if (!$is_dir && $stat) |
||
|
0 ignored issues
–
show
The expression
$stat of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using Loading history...
|
|||
| 103 | { |
||
| 104 | echo "<p><b>Vfs::mime_content_type('$path')</b>=".array2string(Vfs::mime_content_type($path))."</p>\n"; |
||
| 105 | echo "<p><b>filesize(Vfs::PREFIX.'$path')</b>=".array2string(filesize(Vfs::PREFIX.$path))."</p>\n"; |
||
| 106 | echo "<p><b>bytes(file_get_contents(Vfs::PREFIX.'$path'))</b>=".array2string(bytes(file_get_contents(Vfs::PREFIX.$path)))."</p>\n"; |
||
| 107 | } |
||
| 108 | } |
||
| 109 | echo $GLOBALS['egw']->framework->footer(); |
||
| 110 |