示例#1
0
function d_filelist_all($dir)
{
    setreadable($dir, true);
    if (!@($dh = opendir($dir)) && !@($ftp_list = d_ftplist($dir))) {
        return false;
    }
    if ($dh) {
        $dirs = $files = $fsizes = array();
        /* chdir($dir); */
        while (false !== @($file = readdir($dh))) {
            if ($file == '.' || $file == '..') {
                continue;
            }
            if (is_dir($dir . '/' . $file)) {
                $dirs[] = $dir . '/' . $file;
            } else {
                $files[] = $dir . '/' . $file;
            }
            $fsizes[$dir . '/' . $file] = filesize($dir . '/' . $file);
        }
        closedir($dh);
    } else {
        extract($ftp_list);
    }
    foreach ($dirs as $v) {
        $res = d_filelist_all($v);
        $dirs = array_merge($dirs, $res['dirs']);
        $files = array_merge($files, $res['files']);
        $fsizes = array_merge($fsizes, $res['fsizes']);
    }
    return array('dirs' => $dirs, 'files' => $files, 'fsizes' => $fsizes);
}
示例#2
0
<?
require('core.php');
session_write_close();

$f=clean($_GET['file']);

//ob_start();

if(@$_GET['size']=='small' || !empty($_GET['info'])) list($w,$h)=array(160,120);
else if(@$_GET['size']=='normal') list($w,$h)=array(220,220);
else if(@$_GET['size']=='big') list($w,$h)=array(620,460);
else die();

$ret = -1;

setreadable($f, true);

if(preg_match('/Darwin/is', PHP_OS))
{
	$cmd = ROOT.'/full/thumbnailer '.escapeshellarg(abs_path($f)).' '.escapeshellarg($pr = get_tmp_dir().'/'.uniqid(rand()).'.jpg').' '.$w.' '.$h;
	
	//echo $cmd."<bR>";
	
	/* Code specially for MAMP, which spoils some environment variables... */
	
	putenv("DYLD_LIBRARY_PATH=");
	
	exec($cmd, $out, $ret);
	
	if($ret == 0)
	{
示例#3
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();
}