Example #1
0
		{
			$nomain=false;
			
			$_POST['files']=$_SESSION['chmod_files'];
			$_SESSION['chmod_files']=false;
			unset($_SESSION['chmod_files']);
			
			if($_POST['mod'] == $_POST['mod_old'])
			{
				$_POST['mod'] = decoct(array_sum($_POST['mod_smart']));
			}
			
			$error=false;
			foreach($_POST['files'] as $k=>$v)
			{
				$func = d_is_dir(clean($v)) && isset($_POST['recurse']) ? 'd_chmod_recursive' : 'd_chmod';
				if(!@$func(clean($v),$_POST['mod'])) $error=true;
			}
			if(!$error) light_message('All files have been CHMOD\'ed successfully.');
			else light_message('Could not CHMOD files.'.reason());
		}else
		{
			$nomain=false;
			
			light_message('Choose at least one file!');
		}
		break;
	case 'properties':
		if(empty($_REQUEST['files']))
		{
			$nomain=false;
Example #2
0
		$_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();
		$_RESULT = false;
	}else $_RESULT = true;
	break;
case 'exec':
	session_write_close();
	$_RESULT = exec_command($_REQUEST['cmd']);
	break;
Example #3
0
/**
 * Copy not only files, but folders too. See copy() description for details
 *
 * @param string $src
 * @param string $dest
 * @return bool
 */
function d_copy($src,$dest)
{
	if(!$src||!$dest) return false; /* this is very important function and must be protected from stupid errors */
	$src = abs_path($src,false);
	$dest = abs_path($dest,false);
	
	setwritable(dirname($dest),true);
	setreadable($src,true); /* we need to have read permissions! */
	
	if(d_is_file($src)) return (!FIX && @copy($src,$dest)) || @d_ftpcom('copy',$src,$dest);
	
	if(!d_is_dir($src)) return d_error($src.' does not exist');
	
	$dest.='/';
	$src .='/';
	if(substr($dest,0,strlen($src))==$src) return d_error('Cannot copy the directory inside itself.');
	
	if(!d_is_dir($dest) && !d_mkdir($dest)) return false;
	
	$t = d_filelist_fast($src);
	
	foreach(array_merge($t['files'],$t['dirs']) as $f) if(!d_copy($src.basename($f),$dest.basename($f))) $error=true;
	
	return !isset($error);
}
Example #4
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;
}