<?PHP
$new_width = 300;  ##################################################Auskommentieren!!!
if(isset($type) && isset($path) && !isset($kopi))
	{
	echo "<head>\n<meta http-equiv=\"refresh\" content=\"1; URL=hdd.php?type=$type&path=$path&kopi=true\">\n</head>\n";
	echo "<br><br><br><br><br><br><br><br>\n<div align=\"center\"><font size=4 color =#FF0000>Einen Moment bitte........</font></div>\n";
	}
if($kopi == true)
	{
	$execute = "find $path -maxdepth 1 -name '*.$type'";
	$find_result = `$execute`;
	$find_result = explode("\n",$find_result);
	if($type == jpg)
		{
		for($x=0; $x<count($find_result)-1; $x++)
			{
			$file = "config/includes/pics_name";
			list($pics_count) = @file($file);
			$pics_count++;
			$fp = fopen("$file","w");
			fwrite($fp,$pics_count);
			fclose($fp);

			$execute = "cp -p $find_result[$x] tmp/jpg/jpg_pic$pics_count.jpg";
			exec("$execute");

			$info = getimagesize("tmp/jpg/jpg_pic$pics_count.jpg");
			$old_width = "$info[0]";
			$old_high = "$info[1]";
			$faktor = $old_width / $new_width;
			$new_high= $old_high / $faktor;
			$image = imagecreatefromjpeg("tmp/jpg/jpg_pic$pics_count.jpg");
			$image1 = imagecreate($new_width,$new_high);
			imagecopyresized($image1, $image, 0,0, 0,0,$new_width,$new_high, $old_width,$old_high);
			imagejpeg($image1,"tmp/thumbs/thumb_pic$pics_count.jpg");
			}
		}
	if($type == tif)
		{
		for($x=0; $x<count($find_result)-1; $x++)
			{
			$file = "config/includes/pics_name";
			list($pics_count) = @file($file);
			$pics_count++;
			$fp = fopen("$file","w");
			fwrite($fp,$pics_count);
			fclose($fp);

			$execute = "cp -p $find_result[$x] tmp/tif/tif_pic$pics_count.tif";
			exec("$execute");
			
			$convert = "convert tmp/tif/tif_pic$pics_count.tif tmp/jpg/jpg_pic$pics_count.jpg";
			exec("$convert");

			$info = getimagesize("tmp/jpg/jpg_pic$pics_count.jpg");
			$old_width = "$info[0]";
			$old_high = "$info[1]";
			$faktor = $old_width / $new_width;
			$new_high= $old_high / $faktor;
			$image = imagecreatefromjpeg("tmp/jpg/jpg_pic$pics_count.jpg");
			$image1 = imagecreate($new_width,$new_high);
			imagecopyresized($image1, $image, 0,0, 0,0,$new_width,$new_high, $old_width,$old_high);
			imagejpeg($image1,"tmp/thumbs/thumb_pic$pics_count.jpg");
			}
		}
	echo "<head>\n<meta http-equiv=\"refresh\" content=\"1; URL=index.php\">\n</head>\n";
	}
?>
