<?PHP

//////////////////////////////////////////////////////////
        include("config/includes/linkleiste");
        echo "<link rel=stylesheet type=\"text/css\" href=\"config/includes/style.css\">\n";
//////////////////////////////////////////////////////////
$read_write = "config/tables/$kopier_bereich";
if(isset($kopier_bereich))
{
$counters = count($_POST);
for($x=0; $x<$counters; $x++){
$naked = split("[_/.]",current($_POST));
$thumb = current($_POST);
$jpg = "jpg_$naked[1].jpg";
$tif = "tif_$naked[1].tif";

$date = filemtime("tmp/jpg/$jpg");
$pic_date = date("d m y",$date);
$pics_date = explode(" ",$pic_date);

clearstatcache();


copy ("tmp/jpg/$jpg","eigene_bilder/$kopier_bereich/jpg/$jpg");
unlink("tmp/jpg/$jpg");
copy ("tmp/thumbs/$thumb","eigene_bilder/$kopier_bereich/thumbs/$thumb");
unlink("tmp/thumbs/$thumb");
if(file_exists("tmp/tif/$tif"))
{
copy("tmp/tif/$tif","eigene_bilder/$kopier_bereich/tif/$tif");
unlink("tmp/tif/$tif");
}
$new_array = "$naked[1]\$%\$\$%\$\$%\$$pics_date[0].$pics_date[1].$pics_date[2]\$%\$\n";
$fp = fopen("$read_write","a-");
fwrite($fp,$new_array);
fclose($fp);
next($_POST);
}
echo "<br><br><br><div align=center><font class=h1>Die Bilder sind in den Bereich \"$kopier_bereich\" integriert worden.<br><br></font>\n";
echo "<font class=anweis>Was wollen Sie jetzt tun?<br><br></font>\n";
echo "<form action=index.php method=post class=action>\n";
echo "<input type=submit value=\"Mehr Bilder holen / verschieben\"></form><br>\n";
echo "<form action=tab_show.php?kopier_bereich=$kopier_bereich method=post class=action>\n";
echo "<input type=submit value=\"Die Tabelle anschauen oder bearbeiten\"></form><br><br></div>\n";
}
else
{
if($_POST["bereich"] == "----------------")
{
echo "<br><br><br><p class=error>Sie müssen einen Bereich auswählen, in den die Bilder kopiert werden</p>\n";
echo "<p class=anweis>Tut mir ja leid...</p><p class=error><a href=javascript:history.back()>Zurück</a></p>\n";
}
else
	{
	$path = $_POST["bereich"];
	array_pop($_POST);
	$counters = count($_POST);
		if(empty($_POST))
		        {
                        echo "<p class=error>Keine Bilder ausgewählt! <br><br><a href=javascript:history.back()>Zur&uuml;ck</a></p>\n";
		        }
		else
			{
			$tmp_pics = array();
			echo "<div align=center><br>\n";
                        echo "<br><div align=center><font class=h1>Bilder in die Tabellen integrieren</font><br>\n";
			echo "<br><br><font class=anweis>Diese Bilder in den Bereich \"$path\" integrieren?</font><br><br>\n";
                        echo "<font class=text><a href=#unten>(jump down)</a></font><br><br>\n";
			echo "<form action=move.php?kopier_bereich=$path method=post class=action>\n";
                        echo "<table class=rahmenverz cellspacing=5 cellpadding=4>\n";
			for($x=0; $x<$counters; $x++)
                                {
			        echo "<tr><td class=verz><img src=tmp/thumbs/";
			        echo current($_POST) . ">";
			        $pics = current($_POST);
			        array_push($tmp_pics,"$pics");
			        echo "</td></tr><input type=hidden name=pics$x value=$pics>\n";
			        next($_POST);
			        }
			echo "</table><br><input type=submit value=\"Jep, so solls sein!\"></form><br>\n";
			echo "<form action=index.php method=post class=action>\n";
			for($x=0; $x<count($tmp_pics); $x++)
				{
				echo "<input type=hidden name=pics$x value=$tmp_pics[$x]>\n";
				}
                        echo "<input type=\"image\" src=\"gifs/stop.gif\"></form><a name=unten><font color=#FFFFFF>.</font></a>\n";
        		}
	}
}
?>
