Exemplo n.º 1
0
			case 'jpe':
			case 'jpg':
			case 'gif':
			case 'png':
				@$sz=getimagesize($f);
				light_message('<h3>Preview of '.show_file($f).'</h3>
				<a href="system/download.php?file='.rawurlencode($f).'&'.session_name().'='.session_id().'"><img src="system/preview.php?file='.rawurlencode($f).'&size=normal" border="0" alt="Download the full image" title="Download the full image ('.($sz ? $sz[0].'x'.$sz[1].', ' : '').show_size($f).')"></a>');
				break;
			default:
				if(d_filesize($f)>102400)
				{
					header('location: system/download.php?file='.rawurlencode($f).'&'.session_name().'='.session_id());
					break;
				}
				
				$wr = setwritable($f,true);
				
				light_message('<h3>Edit '.show_file($f).' <small>(<a href="?act=properties&files[]='.rawurlencode($f).'&back='.rawurlencode('?act=edit&file='.rawurlencode($f)).'">info</a>)</small></h3>
				<form action="index.php?act=edit&apply=true&file='.rawurlencode($f).'" method="POST">
				<textarea name="content" id="content" rows=10 cols=40>'.htmlspecialchars(d_file_get_contents($f)).'</textarea>
				
				<script><!--
				/* for stupid IE <= 6 */
				var checkf = function()
				{
					if(!document.getElementById) return false;
					var el = document.getElementById("content");
					if(get_width()>=800) el.style.width = "750px";
					else /*if(el.clientWidth>(get_width()-50))*/ el.style.width = (get_width()-50)+"px";
					return true;
				}
Exemplo n.º 2
0
function cpcont($name, &$data)
{
	static $fps = false, $fpd = false; /* File Pointer for Source, ... Destination */
	static $lastfile = false;
	
	global $__perms;
	
	//echo 'Fdadfas';
	
	setwritable(dirname(getcwd().'/'.$name), true);
	
	/* an array( source dir => dest dir ); -- to make copy into the same directory possible */
	if(!isset($data['dirs_replace'])) $data['dirs_replace'] = array();
	
	if(isset($data['lastnewname']))
	{
		$lastnewname = $data['lastnewname'];
	}else
	{
		$lastnewname = false;
	}
	
	if(empty($data['lastfile']) || $data['lastfile'] != $name)
	{
		if(abs_path($data['newdir']) == abs_path(dirname(getcwd().'/'.$name)))
		{
			$lastnewname = abs_path(gen_copy_name($data['newdir'], getcwd().'/'.$name));
			
			$data['dirs_replace'][abs_path(getcwd().'/'.$name)] = abs_path($lastnewname);
		}else
		{
			$lastnewname = abs_path($data['newdir'].'/'.$name);
			
			foreach($data['dirs_replace'] as $k=>$v)
			{
				if(strlen($lastnewname) < strlen($k)) continue;
				
				if(substr($lastnewname,0,strlen($k)) == $k)
				{
					$lastnewname = $v.substr($lastnewname, strlen($k));
					break;
				}
			}
		}
	}
	
	$newname = $data['lastnewname'] = $lastnewname;
	
	if(is_dir($name))
	{
		$lastfile = $data['lastfile'] = $name;
		$_SESSION['DIRS']++;
		return d_mkdir($newname, d_get_rights($name));
	}
	
	if($lastfile != $name)
	{
		if(is_resource($fps)) fclose($fps);
		if(is_resource($fpd)) fclose($fpd);
		
		$lastfile = $data['lastfile'] = $name;
		
		setreadable($name, true);
		
		if(!$fps = fopen($name, 'rb')) return false;
		
		//error_log('name: '.$name.', newname: '.$newname);
		
		setwritable($dn = dirname($newname), true);
		
		//if(!d_chmod($dn, 777)) echo 'F**k!'.reason()."\n";
		
		//echo "rights: ". get_rights($dn,false) ."\n";
		
		if(file_exists($newname))
		{
			setwritable($newname, true);
            $info = get_files_info(array(basename($newname)), $dn);

			if(fseek($fps, sprintf('%u',filesize($newname))) < 0) return false;
		}else
		{
			$_SESSION['FILES']++;
		}
		
		if(!$fpd = fopen($newname, 'ab'))
		{
			$_SESSION['FILES']--; /* this file was counted, so we cancel it's count */
			return false;
		}
		
		$__perms[$newname] = get_rights($name);
	}
	
	$_SESSION['TOTAL_BYTES'] += fwrite($fpd, fread($fps, 65536));
	
	if(feof($fps)) return true;
	
	return array();
}