<?php
include("config/includes/linkleiste");
$start = "/home";
if(!isset($path))
	{
	$path = $start;
	}
echo "<br><br>\n";
if($type == jpg)
	{
	echo "<a href=\"copy.php?type=jpg&path=$path\"><img border=0 src=\"gifs/jpg_checked.gif\"></a><br>\n";
	}
else
	{
	echo "<a href=\"copy.php?type=jpg&path=$path\"><img border=0 src=\"gifs/jpg_check.gif\"></a><br>\n";
	}
#if($type == gif)
#	{
#	echo "<a href=\"copy.php?type=gif&path=$path\"><img border=0 src=\"gifs/gif_checked.gif\"></a><br>\n";
#	}
#else
#	{
#	echo "<a href=\"copy.php?type=gif&path=$path\"><img border=0 src=\"gifs/gif_check.gif\"></a><br>\n";
#	}
if($type == tif)
	{
	echo "<a href=\"copy.php?type=tif&path=$path\"><img border=0 src=\"gifs/tif_checked.gif\"></a><br>\n";
	}
else
	{
	echo "<a href=\"copy.php?type=tif&path=$path\"><img border=0 src=\"gifs/tif_check.gif\"></a><br>\n";
	}
echo "<br><br><div align=\"center\"><table border=\"0\" width=\"80%\" bgcolor=\"#EEEED2\"><tr><td><div align=\"center\"><font size=\"4\" color=\"#008080\">Verzeichnis: </font><font size=\"4\"> $path</font></div></td></tr></table></div>\n<br><br><br>";
$execute = "find $path -type d -maxdepth 1";
$find_result = `$execute`;
$find_result = explode("\n",$find_result);
$check = explode("/",$find_result[0]);
#####################
###	Verzeichnisstruktur printen!

echo "<div align=\"center\"><table width=\"90%\" border=\"1\"><tr><td><table width=\"90%\" border=\"0\">\n<tr>\n";
echo "<td valign=\"top\" width=\"20%\"><strong>Verzeichnisse</strong><br><br>\n<a href=\"copy.php?type=$type&path=";
if(count($check) < 3)
	{
	echo "/";
	}
else
	{
	for($x=1; $x<count($check)-1; $x++)
		{
		echo "/$check[$x]";
		}
	}

echo "\"><img border=0 src=\"gifs/small_folder.gif\">..</a><br>\n";
for($x=1; $x<count($find_result)-1; $x++)
	{
	$y = $x-1;
	$next_dir = explode("/",$find_result[$x]);
	$path_count = count($next_dir)-1;
	echo "<a href=copy.php?type=$type&path=$find_result[$x]><img border=0 src=\"gifs/small_folder.gif\">$next_dir[$path_count]<br>\n";
	}
echo "</td>\n";
if(isset($type))
	{
	echo "<td valign=\"top\" width=\"20%\"><strong>Dateien</strong><br><br>\n";
	$execute = "find $path -maxdepth 1 -name '*.$type'";
	$find_result = `$execute`;
	$find_result = explode("\n",$find_result);
	for($x=0; $x<count($find_result)-1; $x++)
		{
		$pic = explode("/",$find_result[$x]);
		$slash_count = count($pic)-1;
		echo "<img border=0 src=\"gifs/pic.gif\"><font color=\"#800080\"> $pic[$slash_count]<br>\n";
		}
	echo "</td>\n";
	if(count($find_result) > 1)
		{
		echo "<td valign=\"top\" width=\"60%\">\n";
		if(count($find_result) > 10)
			{
			echo "<br><br><div align=\"center\"><font size=\"4\" color=\"#008080\">Alle $type-Bilder aus diesem Verzeichnis in die Tabellen übernehmen</font><br>\n";
			echo "<form action=\"hdd.php?type=$type&path=$path\" method=\"post\">\n";
			echo "<input type=\"submit\" value=\"Los!\">";
			}
		echo "<font size=\"4\">\n";
		for($x=0; $x<count($find_result)-3; $x++)
			{
			echo "<br>\n";
			}
		echo "</font>\n";
		echo "<div align=\"center\"><font size=\"4\" color=\"#008080\">Alle $type-Bilder aus diesem Verzeichnis in die Tabellen übernehmen</font><br>\n";
		echo "<form action=\"hdd.php?type=$type&path=$path\" method=\"post\">\n";
		echo "<input type=\"submit\" value=\"Los!\">";
		}
	}
echo "</tr>\n";
echo "</table></td></tr></table></div>\n";
?>
