Beispiel #1
0
				if(!empty($gr)) $groups[$gr] = true;
				
				$own = get_group($v);
				if(!empty($own)) $owners[$own] = true;
				
				$mod = get_rights($v);
				$mods[$mod] = true;
				
				if(d_is_file($v)) $fsizes[] = show_size($v, false);
				else $dsizes[] = show_size($v, false);
			}
			
			light_message('<h3>Properties for selected items</h3>
			<p>size of '.sizeof($fsizes).' selected files: <b>'.show_size(0,false,array_sum($fsizes)).'</b></p>
			<p>size of '.sizeof($dsizes).' selected dirs: <b>'.show_size(0,false,array_sum($dsizes)).'</b></p>
			<p>total size: <b>'.show_size(0,false,array_sum($fsizes)+array_sum($dsizes)).'</b></p>
			'.(sizeof($mods)==1 ? '<p>mod: <b>'.get_rights($v,false).' ('.get_rights($v).')</b></p>' : '').'
			'.(sizeof($owners)==1 ? '<p>owner: <b>'.get_owner($v).'</b></p>' : '').'
			'.(sizeof($groups)==1 ? '<p>group: <b>'.get_group($v).'</b></p>' : '') );
			
			
		}
		break;
	case 'terminal':
		if(!empty($_REQUEST['cmd']))
		{
			$res = exec_command($_REQUEST['cmd']);
		}else
		{
			$res = array('cmd'=>'', 'output'=>'', 'dir'=> getcwd_short());
		}
Beispiel #2
0
/**
 * Function shows the contents of $dirs or $files array (formatted, of course). 'dirs' will show $dirs, 'files' will show $files
 *
 * @param string $what
 */
function light_show($what)
{
	global $fsizes,$dsizes;
	static $i=0;
	switch($what)
	{
	case 'dirs':
		global $dirs,$f,$drives;
		foreach($dirs as $v){ if(SHOW_DIRSIZE)$sz=(isset($dsizes[$v])?show_size('',true,$dsizes[$v]):show_size($v)); $i++;
		if($_SESSION['DIR']!='My computer') $v = $_SESSION['DIR'].'/'.$v;
		$f=rawurlencode($v);
		?>
	   <?tr($i,'dir');?>
	    <td><div style="overflow: hidden;" class="filename"><nobr><input type="checkbox" name="files[]" id="c<?php 
echo $i;
?>
" value="<?php 
echo htmlspecialchars($v);
?>
" onclick="c_sel(this);" align="absmiddle"><img src="images/<?php 
echo !empty($drives) ? 'hdd' : 'dir';
?>
.png" width="16" height="16" alt="Directory" align="absmiddle"> <a href="index.php?DIR=<?php 
echo $f;
?>
" title="Open directory"><?php 
echo htmlspecialchars(basename($v));
?>
</a></nobr></div></td>
	    <td width="75"><nobr>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php 
echo SHOW_DIRSIZE ? $sz : '<a href="index.php?act=show-size&amp;file=' . $f . '" class="show"><i>show</i></a>';
?>
&nbsp;&nbsp;</nobr></td>
	   </tr>
	   <?}
		break;
	case 'files':
	    global $files,$f;
		foreach($files as $v){ $sz=(isset($fsizes[$v])?show_size('',true,$fsizes[$v]):show_size($v)); $i++;
		if($_SESSION['DIR']!='My computer') $v = $_SESSION['DIR'].'/'.$v;
		$f=rawurlencode($v);
		?>
	   <?tr($i,'file');?>
	    <td><div style="overflow: hidden;" class="filename"><nobr><input type="checkbox" name="files[]" id="c<?php 
echo $i;
?>
" value="<?php 
echo htmlspecialchars($v);
?>
" onclick="c_sel(this);" align="absmiddle"><img src="images/file.png" width="16" height="16" alt="File" align="absmiddle"> <a href="index.php?act=edit&amp;file=<?php 
echo $f;
?>
" title="Edit file"><?php 
echo htmlspecialchars(basename($v));
?>
</a></nobr></div></td>
	    <td align="left" width="75"><nobr><a href="system/download.php?file=<?php 
echo $f;
?>
&amp;<?php 
echo session_name();
?>
=<?php 
echo session_id();
?>
" title="Download"><img src="images/download.png" width="16" height="16" border="0"></a><?php 
echo $sz;
?>
&nbsp;&nbsp;</nobr></td>
	   </tr>
	   <?}
		break;
	}
}
Beispiel #3
0
	
	if(is_array($_SESSION['SPCACHE'] = multipart_cont($_SESSION['SPCACHE'])))
	{
		$end = false;
	}else
	{
		$success = $_SESSION['SPCACHE'] !== false;
		$_SESSION['SPCACHE'] = false;
		unset($_SESSION['SPCACHE']);
		$end = true;
	}
	
	$_RESULT = array(
	'dirs'   => $_SESSION['DIRS'],
	'files'  => $_SESSION['FILES'],
	'total'  => show_size(false,true,$_SESSION['TOTAL_BYTES']),
	'uids'   => implode(', ', $_SESSION['UIDS']),
	'gids'   => implode(', ', $_SESSION['GIDS']),
	'rights' => implode(', ', $_SESSION['RIGHTS']),
	'mod'    => d_get_rights($fz[0]),
	'end'    => $end,
	'success' => $success,
	'dir'    => sizeof($fz) == 1 ? d_is_dir($fz[0]) : true,
	);
	break;
case 'save-file':
	$f = clean(urldecode($_REQUEST['filename_encoded']));
	
	if(!d_file_put_contents($f, $_REQUEST['content']))
	{
		echo 'Cannot edit file.'.reason();
Beispiel #4
0
function get_files_info($files, $dir = null) {
    if (!count($files)) return array();

    if (!isset($dir)) $dir = $_SESSION['DIR'];
    $old_dir = getcwd();
    if (!chdir($dir)) return d_error('Cannot change directory');
    $result = array();
    $sizes = array();
    // a more reliable way of computing size
    if (is_callable('exec') && in_array(php_uname('s'), array('Linux', 'FreeBSD', 'Darwin'))) {
        $filepaths = array();
        foreach ($files as $f) $filepaths[] = escapeshellarg('./' . $f);
        exec("stat -f '%z' " . implode(' ', $filepaths), $out, $retval);
        if ($retval == 0 && count($out) == count($files)) {
            foreach ($out as $i => $sz) {
                $sizes[$files[$i]] = $sz;
            }
        }
    }

    foreach ($files as $f) {
        $result[$f] = array(
            'modified' => human_date(filemtime($f)),
            'size'     => show_size($f, true, isset($sizes[$f]) ? $sizes[$f] : filesize($f)),
            'type'     => is_dir($f) ? 'dir' : 'file',
        );
    }
    chdir($old_dir);
    return $result;
}
Beispiel #5
0
function get_info($f)
{
	global $descr;
	
	if(!isset($_REQUEST['type'])) $_REQUEST['type'] = determine_type($f);
	
	if(isset($_REQUEST['file'])) $f = clean($_REQUEST['file'], true);
	
	if($f == lang('My computer'))
	{
		$_RESULT = array(
		'name' => 'details',
		'filename' => htmlspecialchars($f),
		'dir' => false,
		'type' => lang('System folder'),
		);
	}else if(in_array($_REQUEST['type'],array(tDIR,tFILE)))
	{
		if(!@lstat($f)) return null;
		
		$ext=pathinfo($f); @$ext=strtolower($ext['extension']);
		$imgext = array('jpeg','jpe','gif','png','jpg');
		
		if(preg_match('/Darwin/is', PHP_OS)) $imgext = array_merge($imgext, explode(' ','pdf doc docx ppt pptx xls xlsx tiff tif bmp mov avi mpg mp4 tga psd svg eps key pages html'));
		
		$img=in_array($ext,$imgext);
		
		//echo $f;
		
		$real_link = $link_raw = @is_link($f) && function_exists('readlink') ? readlink($f) : false;
		
		if($link_raw !== false && $link_raw[0] != '/') // not absolute link
		{
			$link_raw = abs_path( dirname($f).'/'.$link_raw );
		}
		
		$_RESULT=array(
		'name' => 'details',
		'filename' => htmlspecialchars(basename($f)),
		'filename_encoded' => rawurlencode($f),
		'fullpath' => $f,
		'link' => $link_raw !== false ? htmlspecialchars($real_link) : false,
		'link_raw' => $link_raw,
		'md5(filename)' => md5($f),
		'dir'  => d_is_dir($f),
		'type' => (d_is_dir($f) ? false : get_type($f)),
		'changed' => ((@$t=filemtime($f)) ? date('d F Y, H:i',$t) : false),
		'size' => ( (d_is_dir($f) && !SHOW_DIRSIZE) ? (/*no subdirectories*/!empty($GLOBALS['files']) && sizeof($GLOBALS['dirs'])==0 && !empty($GLOBALS['sz']) ? show_size(true,true,$GLOBALS['sz']) : false) : show_size($f)),
		'size_bytes' => d_filesize($f),
		'thumb' => ($img ? '<div style="padding-bottom: 10px;" align="center"><img src="system/preview.php?file='.rawurlencode($f).'&size=small" align="center"></div>' : false),
		'id3' => (($img && d_filesize($f) < 15*1024*1024 && @$sz=getimagesize($f)) ? 'Dimensions: '.$sz[0].'x'.$sz[1] : ''),
		'owner' => get_owner($f),
		'group' => get_group($f),
		'rights' => d_get_rights($f, false),
		);
	}else if($_REQUEST['type']==tDRIVE)
	{
		$_RESULT=array(
		'name' => 'details',
		'filename' => !empty($_REQUEST['name']) ? $_REQUEST['name'] : $_SESSION['DIR'],
		'type' => $descr[$_REQUEST['icon']],
		'dir' => false,
		);
		if(!empty($_REQUEST['fs'])) $_RESULT['fs'] = $_REQUEST['fs'];
		if($s = disk_free_space($f)) $_RESULT['free']=show_size(true,true,$s);
		if($s = disk_total_space($f)) $_RESULT['total']=show_size(true,true,$s);
	}
	
	return $_RESULT;
}