<?PHP

/**************************************
    Webutler V3.0 - www.webutler.de
    Copyright (c) 2008 - 2014
    Autor: Sven Zinke
    Free for any use
    Lizenz: GPL
**************************************/

if(preg_match('#/admin/browser/assets/functions.php#i', $_SERVER['REQUEST_URI']))
    exit('no access');

class WebutlerMBrowserClass extends WebutlerAdminClass
{
    //var $config;
    var $jsalert = '';
    var $AllowedExtensions;
    var $AvailableIcons;
    var $AllowedTypes;
    var $MediaDirectory;
    var $type;
    var $urltype;
    var $getthumb;
    
	function __construct() {
        require_once dirname(dirname(dirname(dirname(__FILE__)))).'/admin/browser/config.php';
    }
    
    function sendalert($text) {
    	$this->jsalert = "alert('".$text."');";
    }
    
    function filterzahlen($variablezahlen) {
    	$variablezahlen = preg_replace('/[^0-9]/', '', $variablezahlen);
    	return $variablezahlen;
    }
    
    function filterupload($variableupload) {
    	$extension = strtolower(substr($variableupload, strrpos($variableupload, '.') + 1));
    	$filename = substr($variableupload, 0, strrpos($variableupload, '.'));
        
    	$filename = str_replace(' ', '_', $filename);
    	$filename = strtolower($filename);
    	$filename = preg_replace('/[^a-z0-9_]/', '', $filename);
        
    	return $filename.'.'.$extension;
    }
    
    function cleanpathfromget($path)
    {
    	$path = utf8_decode($path);
    	$path = rawurldecode($path);
    	$path = strip_tags($path);
    	$path = stripslashes($path);
    	$path = str_replace( $this->config['server_path'], '', $path );
    	$path = str_replace( $this->config['homepage'], '', $path );
    	$path = str_replace( '../', '', $path );
    	
    	return $path;
    }
    	
    function cke_getvars()
    {
        $getvars = '';
        $getvars .= isset($_GET['CKEditor']) ? '&CKEditor='.$_GET['CKEditor'] : '';
        $getvars .= isset($_GET['CKEditorFuncNum']) ? '&CKEditorFuncNum='.$_GET['CKEditorFuncNum'] : '';
        $getvars .= isset($_GET['langCode']) ? '&langCode='.$_GET['langCode'] : '';
        
    	return $getvars;
    }
    	
    function makeurlfolder($urlfolder)
    {
    	$urlfolder = rawurlencode(utf8_encode($urlfolder));
    	return $urlfolder;
    }
    
    function actualfolder()
    {
    	if(isset($_GET['actualfolder']))
    	{
    		$actualfolder = $this->cleanpathfromget($_GET['actualfolder']);
    		if(!preg_match('#/$#', $actualfolder))
    		{
    			$actualfolder .= '/';
    		}
    		if(strpos($actualfolder, '/') !== 0)
    		{
    			$actualfolder = '/'.$actualfolder;
    		}
    		return $actualfolder;
    	}
    	else
    	{
    		return '/';
    	}
    }
    
    function lastfolder()
    {
    	$folderpath = $this->actualfolder();
    	$killlastslash = substr($folderpath, 0, -1);
    	$lastfolder = substr($killlastslash, 0, strrpos($killlastslash, '/'));
    	return $lastfolder.'/';
    }
    
    function seticon($datei)
    {
    	$icon = substr($datei, strrpos($datei, '.') + 1);
    	$icon = strtolower($icon);
    	if(in_array($icon, $this->AvailableIcons))
    	{
    		return $icon;
    	}
    	else
    	{
    		return 'default';
    	}
    }
    
    function fileactionpath()
    {
    	$fileactionpath = $this->MediaDirectory.$this->type.$this->cleanpathfromget($this->actualfolder());
    
    	return $fileactionpath;
    }
    
    function fileexists($file)
    {
    	$file = $this->cleanpathfromget($file);
    	$file = str_replace( '/', '', $file );
    
    	if(file_exists($this->fileactionpath().$file)) 
    	{
    		return $file;
    	}
    	else
    	{
    	    $this->sendalert(_WBLANGADMIN_BROWSER_FILENOTEXISTS_);
    	}
    }
    
    function renamefileto($oldname, $newname)
    {
        $path = $this->MediaDirectory.$this->type.$this->cleanpathfromget($this->actualfolder());
        if(strrpos($oldname, '.') == '')
        {
            $newfile = $newname;
        }
        else
        {
    		$extension = substr($oldname, strrpos($oldname, '.') + 1);
        	$extension = strtolower($extension);
            $newfile = $newname.'.'.$extension;
        }
        rename($path.$oldname, $path.$newfile);
    }
    
    function copyfilefromto($data, $unlink = false)
    {
        $file = explode('|', $data);
        $filepath = $file[0];
        $filename = $file[1];
        $frompath = $this->MediaDirectory.$this->type.$filepath;
        $topath = $this->MediaDirectory.$this->type.$this->cleanpathfromget($this->actualfolder());
        
        if($frompath == $topath)
            return false;
        
        $filefrom = $frompath.$filename;
        $fileto = $topath.$filename;
        
		if(file_exists($fileto))
            unlink($fileto);
        
        copy($filefrom, $fileto);
		if($unlink)
            unlink($filefrom);
        
	    if($this->type == 'image')
	    {
            $boxfilefrom = $frompath.'.box/'.$filename;
            $boxfolder = $topath.'.box/';
            $boxfileto = $boxfolder.$filename;
            
			if(!file_exists($boxfolder)) 
			{
				$oldumask = umask(0);
				mkdir($boxfolder, $this->config['chmod'][0]);
				umask($oldumask);
			}
            
    		if(file_exists($boxfileto))
                unlink($boxfileto);
            
    		if(file_exists($boxfilefrom)) {
                copy($boxfilefrom, $boxfileto);
        		if($unlink)
                    unlink($boxfilefrom);
            }
	    }
    }
    
    function delete($file)
    {
		if($this->fileexists($file))
		{
			$datei = $this->fileactionpath().$file;
			$candelete = true;
			$error = false;
				
			if(is_dir($datei.'/'))
			{
				$verzeichnis = opendir($datei);
				while(false !== ($inhalt = readdir($verzeichnis)))
				{
					if ($inhalt != '' && $inhalt != '.' && $inhalt != '..')
					{
						$candelete = false;
					}
				}
				closedir($verzeichnis);
				
				if(!$candelete)
				{
					$error = true;
					$this->sendalert(_WBLANGADMIN_BROWSER_DELONLYEMPTY_);
				}
				else
				{
					if(!rmdir($datei.'/'))
					{
						$error = true;
						$this->sendalert(_WBLANGADMIN_BROWSER_THISFOLDER_.' '.$file.' '._WBLANGADMIN_BROWSER_NOTDELETEABLE_);
					}
				}
			}
			else
			{
				$datei = $this->fileactionpath().$file;
				$format = GetImageSize($datei);
				if($format)
				{
					$boxfile = $this->fileactionpath().'.box/'.$file;
					if(file_exists($boxfile))
					{
						unlink($boxfile);
					}
				}
				
				if(!unlink($datei))
				{
					$error = true;
					$this->sendalert(_WBLANGADMIN_BROWSER_THISFILE_.' '.$file.' '._WBLANGADMIN_BROWSER_NOTDELETEABLE_);
				}
			}
			
			if(!$error) {
				$location = $this->getserverlocation();
				header('Location: '.$location);
				unset($_GET['delete']);
				$getvars = array();
				foreach($_GET as $key => $val)
				{
					$getvars[] = $key.'='.($key == 'actualfolder' ? $this->makeurlfolder($val) : $val);
				}
				
				header('Location: '.$location.'?'.implode('&', $getvars));
			}
		}
    }
    
    function getserverlocation()
    {
        $location = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://');
        $location.= $_SERVER['HTTP_HOST'];
        $location.= $_SERVER['REDIRECT_URL'];
        
        return $location;
    }
    
    function makefolder($name)
    {
		/*
		$name = strip_tags($name);
		$name = stripslashes($name);
		$name = trim($name);
		$name = str_replace('.', ' ', $name);
		$name = str_replace('-', ' ', $name);
		$name = preg_replace('/( +)/', '_', $name);
		$name = $this->filterupload($name);
		*/
		$name = preg_replace('/[^a-z0-9_]/', '', strtolower($name));
		
		if($name != '') 
		{
			$newfolder = $this->fileactionpath().$name;
			if(!file_exists($newfolder)) 
			{
				$oldumask = umask(0);
				if(mkdir($newfolder, $this->config['chmod'][0]))
				{
					umask($oldumask);
					$this->sendalert(_WBLANGADMIN_BROWSER_FOLDERADDED1_.' '.$name.' '._WBLANGADMIN_BROWSER_FOLDERADDED2_);
				}
				else
				{
					$this->sendalert(_WBLANGADMIN_BROWSER_FOLDERNOTADDED1_.' '.$name.' '._WBLANGADMIN_BROWSER_FOLDERNOTADDED2_);
				}
			}
			else
			{ 
				$this->sendalert(_WBLANGADMIN_BROWSER_FOLDEREXISTS1_.' '.$name.' '._WBLANGADMIN_BROWSER_FOLDEREXISTS2_);
			}
		}  
		else
		{
			$this->sendalert(_WBLANGADMIN_BROWSER_NOFOLDERNAME_);
		}
    }
    
    function resizeimage($imagefile, $measure)
    {
    	$format = getimagesize($imagefile);
    	list($width_orig, $height_orig) = $format;
    	
    	if($width_orig >= $measure || $height_orig >= $measure)
    	{
    		if($width_orig >= $height_orig)
    		{
    			$width = $measure;
    			$height = (int) (($measure / $width_orig) * $height_orig);
    		}
    		else
    		{
    			$width = (int) (($measure / $height_orig) * $width_orig);
    			$height = $measure;
    		}
    		
    		if ($format[2] == 1)
    		{
    			$image_p = imagecreate($width, $height);
    			$black = imagecolorallocate($image_p, 0x00, 0x00, 0x00);
    			$trans = imagecolortransparent($image_p, $black);
    			imagefill($image_p, 0, 0, $trans);
    			$image = imagecreatefromgif($imagefile);
    			imagecopyresized($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
    			imagegif($image_p, $imagefile);
    		}
    		elseif ($format[2] == 2)
    		{
    			$image_p = imagecreatetruecolor($width, $height);
    			$image = imagecreatefromjpeg($imagefile);
    			imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
    			imagejpeg($image_p, $imagefile, 80);
    		}
    		elseif ($format[2] == 3)
    		{
    			$image_p = imagecreatetruecolor($width, $height);
    			imagealphablending($image_p, false);
    			imagesavealpha($image_p, true);
    			$image = imagecreatefrompng($imagefile);
    			imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
    			imagepng($image_p, $imagefile);
    		}
    	}
    }
    
    function resourcetype($type)
    {
    	if($type == 'file') {
    		$resource = _WBLANGADMIN_BROWSER_RESOURCE_FILE_;
    	}
    	if($type == 'image') {
    		$resource = _WBLANGADMIN_BROWSER_RESOURCE_IMAGE_;
    	}
    	if($type == 'flash') {
    		$resource = _WBLANGADMIN_BROWSER_RESOURCE_FLASH_;
    	}
    	if($type == 'track') {
    		$resource = _WBLANGADMIN_BROWSER_RESOURCE_TRACK_;
    	}
    	return $resource;
    }
    
    function resourcetitle($type)
    {
        $title = _WBLANGADMIN_BROWSER_RESOURCE_FORMATS_.': ';
        $laenge = count($this->AllowedExtensions[$type]);
        
        for($i = 0; $i < $laenge; $i++)
        {
            $title .= $this->AllowedExtensions[$type][$i];
            if($i < ($laenge-1))
            {
                $title .= ', ';
            }
        }
    
    	return $title;
    }
    
	function uploadfile($filename, $filetype, $imgwidth = '')
    {
		if($filename != '')
		{
			$filename = rawurldecode($filename);
			$filename = preg_replace('/\\.(?![^.]*$)/', '_', $filename);
			
			$orgSize = $this->filterzahlen($this->config['imgorgsize']);
			$size = $this->filterzahlen($imgwidth);
			
			$extension = substr($filename, strrpos($filename, '.') + 1);
			$extension = strtolower($extension);
			
			$nameneu = $this->filterupload($filename);
			$dateipath = $this->fileactionpath().$nameneu;
			
			if(!file_exists($dateipath))
			{
				if(in_array($extension, $this->AllowedExtensions[$this->type]))
				{
					if($this->type == 'image' && $this->actualfolder() != '/tpl_icons/')
					{
						$boxfolder = $this->fileactionpath().'.box/';
						if(!file_exists($boxfolder)) 
						{
							$oldumask = umask(0);
							mkdir($boxfolder, $this->config['chmod'][0]);
							umask($oldumask);
						}
						$dateiboxpath = $boxfolder.$nameneu;
						
						$file = fopen($dateiboxpath, 'w');
						fclose($file);
						$this->setchmodaftersave($dateiboxpath);
						
						$upload = fopen('php://input', 'r');
						while(!feof($upload)) {
							file_put_contents($dateiboxpath, fread($upload, 4096), FILE_APPEND);
						}
						fclose($upload);
						
						if($orgSize != '' && $orgSize != '0')
						{	
							 $this->resizeimage($dateiboxpath, $orgSize);
						}
						
						if(copy($dateiboxpath, $dateipath))
						{
							if($size != '' && $size != '0')
							{	
								$this->resizeimage($dateipath, $size);
							}
							
							$this->setchmodaftersave($dateipath);
						}
				
						echo _WBLANGADMIN_BROWSER_FILEUPLOADED1_.' '.$nameneu.' '._WBLANGADMIN_BROWSER_FILEUPLOADED2_;
					}
					else
					{
						$file = fopen($dateipath, 'w');
						fclose($file);
						$this->setchmodaftersave($dateipath);
						
						$upload = fopen('php://input', 'r');
						while(!feof($upload)) {
							file_put_contents($dateipath, fread($upload, 4096), FILE_APPEND);
						}
						fclose($upload);
						
						if($this->actualfolder() == '/tpl_icons/')
						{
							if($size != '' && $size != '0')
							{	
								$this->resizeimage($dateipath, $size);
							}
						}
				
						echo _WBLANGADMIN_BROWSER_FILEUPLOADED1_.' '.$nameneu.' '._WBLANGADMIN_BROWSER_FILEUPLOADED2_;
					}
				}
				else
				{
					echo _WBLANGADMIN_BROWSER_FILEWRONGFORMAT1_.' '.$extension.' '._WBLANGADMIN_BROWSER_FILEWRONGFORMAT2_.' '.$this->resourcetype($this->type).' '._WBLANGADMIN_BROWSER_FILEWRONGFORMAT3_;
				}
			}
			else
			{
				echo _WBLANGADMIN_BROWSER_FILEEXISTS1_.' '.$nameneu.' '._WBLANGADMIN_BROWSER_FILEEXISTS2_;
			}
		}
		else
		{
			echo _WBLANGADMIN_BROWSER_NOFILE_;
		}
    }
    
    function get_folders($dateien)
    {
        $result = '';
        
        if(is_dir($dateien))
        {
            $verzeichnis = opendir($dateien);
            while(false !== ($inhalt = readdir($verzeichnis)))
            {
            	if($inhalt != '.' && $inhalt != '..' && $inhalt != '.box')
            	{
            		if(is_dir($dateien.'/'.$inhalt.'/'))
            		{
            			if(($inhalt == 'tpl_icons' && ($this->config['admin_erweitert'] != '1' || (isset($_SESSION['loggedin']['userisadmin']) && $_SESSION['loggedin']['userisadmin'] == '1'))) || $inhalt != 'tpl_icons')
            			{
                			$result.= '<tr>';
                			$result.= '<td width="21"><img alt="" src="images/Folder.gif" style="margin-right: 5px" /></td>';
                			$result.= '<td nowrap><a href="index.php?'.$this->urltype.'&actualfolder='.$this->makeurlfolder($this->actualfolder().$inhalt.'/').$this->getthumb.$this->cke_getvars().'">'.$inhalt.'</a>';
                            $result.= ($inhalt != 'tpl_icons') ? '<img alt="" src="images/edit.png" onclick="renamepopupopen(\''.$inhalt.'\')" class="renameedit" />' : '';
                            $result.= '</td>';
                			$result.= '<td>&nbsp;</td>';
                			$result.= '<td>&nbsp;</td>';
                			if($this->type == 'image')
                			{
                				$result.= '<td>&nbsp;</td>';
                			}
                			if($inhalt == 'tpl_icons')
                			{
                				$result.= '<td>&nbsp;</td>';
                			}
                			else
                            {
                                $result.= '<td width="18">&nbsp;</td>
                                    <td width="18">&nbsp;</td>
                                    <td width="18"><a href="#" onclick="DeleteFile(\''.$inhalt.'\');return false;"><img alt="" src="images/trash.gif" style="margin: 0px 0px 0px 3px" /></a></td>';
                			}
                			$result.= '</tr>';
            			}
            		}
            	}
            }
            closedir($verzeichnis);
        }
        
        return $result;
    }
    
    function get_files($dateien)
    {
        $result = '';
        
        if(is_dir($dateien))
        {
    		if(isset($_GET['vorschau']) && $this->type == 'image') {
    			$result.= '<tr>
    			  <td colspan="6">';
    		}
            $verzeichnis = opendir($dateien);
            while(false !== ($inhalt = readdir($verzeichnis)))
            {
            	if($inhalt != '.' && $inhalt != '..' && $inhalt != '.box')
            	{
            		if(is_file($dateien.'/'.$inhalt))
            		{
            			$icon = $this->seticon($inhalt);
            			$format = GetImageSize($dateien.'/'.$inhalt);
                    	$wh = ($format[0] >= $format[1]) ? 'width' : 'height';
            			$filesize = round(filesize($dateien.'/'.$inhalt)/1024, 0);
            			if($filesize <= 0) $filesize = str_replace('.', ',', round(filesize($dateien.'/'.$inhalt)/1024, 1));
            			
            			if(isset($_GET['vorschau']) && $this->type == 'image') {
                		  $result.= '<div style="float: left; width: 125px; margin: 5px; border: 1px solid #373737">
                        	<table border="0" cellspacing="5" cellpadding="0">
                        	  <tr>
                        		<td style="width: 115px; height: 115px; background-color: #e9e9e9; text-align: center">';
                                if($this->actualfolder() == '/tpl_icons/') {
                				    $result.= '<a href="#" onclick="setTplIcon(\''.$inhalt.'\');return false;"><img title="'.$inhalt.'" alt="" style="'.$wh.': 109px; margin: 3px" src="'.$this->config['homepage'].'/content/media/'.$this->type.$this->cleanpathfromget($this->actualfolder()).$inhalt.'" /></a>';
                                    //$result.= '<img title="'.$inhalt.'" alt="" style="'.$wh.': 109px; margin: 3px" src="'.$this->config['homepage'].'/content/media/'.$this->type.$this->cleanpathfromget($this->actualfolder()).$inhalt.'" />';
                                } else {
                                    $result.= '<a title="'.$inhalt.' einf&uuml;gen" href="#" onclick="OpenFile(\'content/media/'.$this->type.$this->cleanpathfromget($this->actualfolder()).$inhalt.'\');return false;"><img alt="" style="'.$wh.': 109px; margin: 3px" src="'.$this->config['homepage'].'/content/media/'.$this->type.$this->cleanpathfromget($this->actualfolder()).$inhalt.'" /></a>';
                                }
                                $result.= '</td>
                        	  </tr>
                        	  <tr>
                        		<td style="height: 15px; text-align: right; vertical-align: bottom"><img alt="" src="images/icons/'.$icon.'.gif" style="margin: 0px 3px -2px 0px" /> '.$filesize.'KB <a href="#" onclick="OpenEditWin(\''.$this->config['homepage'].'\', \''.$this->cleanpathfromget($this->actualfolder()).$inhalt.'\');return false;"><img alt="" src="images/brush.gif" style="margin: 0px 3px -1px 3px" /></a> <a href="#" onclick="DeleteFile(\''.$inhalt.'\');return false;"><img alt="" src="images/trash.gif" style="margin-bottom: -2px" /></a></td>
                        	  </tr>
                        	</table>
                		  </div>';
            			}
            			else {
                			$result.= '<tr>';
                			if($icon == 'flv' && (!isset($_GET['types']) || $_GET['types'] == ''))
                			{
                				$result.= '<td style="width: 21px"><img alt="" src="images/icons/'.$icon.'.gif" style="margin-right: 5px" /></td>
                				  <td style="word-space: nowrap"><a href="#" onclick="OpenFile(\'includes/javascript/player/flvplayer.swf?flv=/content/media/'.$this->type.$this->cleanpathfromget($this->actualfolder()).$inhalt.'\');return false;">'.$inhalt.'</a><img alt="" src="images/edit.png" onclick="renamepopupopen(\''.$inhalt.'\')" class="renameedit" /></td>';
                			}
                			elseif($icon == 'mp3' && (!isset($_GET['types']) || $_GET['types'] == ''))
                			{
                				$result.= '<td style="width: 21px"><img alt="" src="images/icons/'.$icon.'.gif" style="margin-right: 5px" /></td>
                				  <td style="word-space: nowrap"><a href="#" onclick="OpenFile(\'includes/javascript/player/mp3player.swf?mp3=/content/media/'.$this->type.$this->cleanpathfromget($this->actualfolder()).$inhalt.'\');return false;">'.$inhalt.'</a><img alt="" src="images/edit.png" onclick="renamepopupopen(\''.$inhalt.'\')" class="renameedit" /></td>';
                			}
                			else
                			{
                				$result.= '<td style="width: 21px"><img alt="" src="images/icons/'.$icon.'.gif" style="margin-right: 5px" /></td>
                                <td style="word-space: nowrap">';
                                if($this->actualfolder() == '/tpl_icons/') {
                				    $result.= '<a href="#" onclick="setTplIcon(\''.$inhalt.'\');return false;">'.$inhalt.'</a>';
                				    //$result.= $inhalt;
								}
                                else {
                				    $result.= '<a href="#" onclick="OpenFile(\'content/media/'.$this->type.$this->cleanpathfromget($this->actualfolder()).$inhalt.'\');return false;">'.$inhalt.'</a>';
								}
                                    
                                $result.= '<img alt="" src="images/edit.png" onclick="renamepopupopen(\''.$inhalt.'\')" class="renameedit" /></td>';
                			}
                			$result.= '<td style="text-align: right; word-space: nowrap">'.$filesize.' KB</td>';
                			if($icon == 'flv')
                			{
                				$result.= '<td style="width: 21px"><a href="#" onclick="OpenWindow(\''.$this->config['homepage'].'/includes/javascript/player/flvplayer.swf?flv=/content/media/'.$this->type.$this->cleanpathfromget($this->actualfolder()).$inhalt.'\', \''._WBLANGADMIN_BROWSER_PREVIEW_.'\', \'true\')"><img alt="" src="images/show.gif" style="margin: 0px 3px" /></a></td>';
                			}
                			elseif($icon == 'mp3')
                			{
                				$result.= '<td style="width: 21px"><a href="#" onclick="OpenWindow(\''.$this->config['homepage'].'/includes/javascript/player/mp3player.swf?mp3=/content/media/'.$this->type.$this->cleanpathfromget($this->actualfolder()).$inhalt.'\', \''._WBLANGADMIN_BROWSER_PREVIEW_.'\', \'true\')"><img alt="" src="images/show.gif" style="margin: 0px 3px" /></a></td>';
                			}
                			else
                			{
                				$result.= '<td style="width: 21px"><a href="#" onclick="OpenWindow(\''.$this->config['homepage'].'/content/media/'.$this->type.$this->cleanpathfromget($this->actualfolder()).$inhalt.'\', \''._WBLANGADMIN_BROWSER_PREVIEW_.'\', \'false\')"><img alt="" src="images/show.gif" style="margin: 0px 3px" /></a></td>';
                			}
                			if($this->type == 'image')
                			{
                				$result.= '<td style="width: 21px"><a href="#" onclick="OpenEditWin(\''.$this->config['homepage'].'\', \''.$this->cleanpathfromget($this->actualfolder()).$inhalt.'\');return false;"><img alt="" src="images/brush.gif" style="margin: 0px 3px" /></a></td>';
                			}
                            $result.= '<td style="width: 21px">';
                            if(isset($_SESSION['copy'.$this->type]) && $_SESSION['copy'.$this->type] == $this->cleanpathfromget($this->actualfolder()).'|'.$inhalt)
                            {
                                $result.= '<img alt="" src="images/copied.png" style="margin: 0px 3px" />';
                            }
                            else
                            {
                                $result.= '<form method="post"><input type="hidden" name="copyfile" value="'.$this->cleanpathfromget($this->actualfolder()).'|'.$inhalt.'" /><input type="image" name="copy" src="images/copy.png" style="margin: 0px 3px" /></form>';
                            }
                            $result.= '</td>
                                <td style="width: 21px">';
                            if(isset($_SESSION['cut'.$this->type]) && $_SESSION['cut'.$this->type] == $this->cleanpathfromget($this->actualfolder()).'|'.$inhalt)
                            {
                                $result.= '<img alt="" src="images/cutted.png" style="margin: 0px 3px" />';
                            }
                            else
                            {
                                //$result.= '<form method="post"><input type="image" name="cutout['.$this->type.']" value="'.$this->cleanpathfromget($this->actualfolder()).'|'.$inhalt.'" src="images/cutout.png" /></form>';
                                $result.= '<form method="post"><input type="hidden" name="cutoutfile" value="'.$this->cleanpathfromget($this->actualfolder()).'|'.$inhalt.'" /><input type="image" name="cutout" src="images/cutout.png" style="margin: 0px 3px" /></form>';
                            }
                            $result.= '</td>
                                <td style="width: 18px"><a href="#" onclick="DeleteFile(\''.$inhalt.'\');return false;"><img alt="" src="images/trash.gif" style="margin: 0px 0px 0px 3px" /></a></td>
                			  </tr>';
            			}
            		}
            	}
            }
            closedir($verzeichnis);
    		if(isset($_GET['vorschau']) && $this->type == 'image') {
    			$result.= '</td>
    			  </tr>';
    		}
        }
        
        return $result;
    }
}

?>
