Location: PHPKode > projects > HuMo-gen > admin/include/thumbs.php
<?php
// *** Safety line ***
if (!defined('ADMIN_PAGE')){ exit; }

echo '<h1 align=center>'.$language["thumbs_name"].'</h1>';

echo $language["thumbs_intro"];
echo ' <i>extension=php.gd2.dll</i>';

print "<p><form method='post' action='".$_SERVER['PHP_SELF']."'>";
echo '<input type="hidden" name="page" value="'.$page.'">';

// *** Select folder ***
$dataqry='SELECT * FROM humo_trees GROUP BY tree_pict_path';
@$datasql = mysql_query($dataqry,$db);
echo $language["thumbs_path"];
echo ' <select size="1" name="afbpad">';
while ($dataDb=mysql_fetch_object($datasql)){
	$pad=$dataDb->tree_pict_path;
	if (file_exists('../'.$pad)){
		$selected='';
		if (isset($_POST['afbpad'])){ if ($_POST['afbpad']==$pad){ $selected=' SELECTED'; } }
		echo '<option value="'.$pad.'"'.$selected.'>'.
		@$pad.'</option>';
	}
}
echo '</select><br>';

// *** Thumb height ***
//$thumb_height=100;
$thumb_height=120;
if (isset($_POST['breedte']) AND is_numeric($_POST['breedte'])){ $thumb_height=$_POST['breedte']; }
echo $language["thumbs_height"].' <input type="text" name="breedte" value="'.$thumb_height.'" size="4"> pixels <br>';
print '<input type="Submit" name="thumbnail" value="'.$language["thumbs_make"].'">';
print "</form>";

$teller=0;
if (isset($_POST["thumbnail"])){
	$pad=$_POST['afbpad'];

	@set_time_limit(3000);
	$fotomapkeuze='../'.$pad;
	
	// *** Extra safety check if folder exists ***
	if (file_exists($fotomapkeuze)){

		$dh  = opendir($fotomapkeuze);
		while (false !== ($filename = readdir($dh))) {
			if (strtolower(substr($filename, -3)) == "jpg"){
				$pad_afbeelding='../'.$pad."/$filename";        //ORIGINEEL
				$pad_thumb='../'.$pad."/thumb_$filename"; //THUMB

				//*** Eventueel een thumb maken ***
				//if (!file_exists($pad_thumb) AND substr ($filename, 0, 5)!='thumb'){
				if (substr ($filename, 0, 5)!='thumb'){
					//Breedte en hoogte origineel bepalen
					list($width, $height) = getimagesize($pad_afbeelding);

					//Formaat bereken met vaste breedte:
					//$newwidth=$thumb_height;
					//$factor=$width/$newwidth;
					//$newheight=$height/($factor);
						
					$newheight=$thumb_height;
					$factor=$height/$newheight;
					$newwidth=$width/$factor;						

					//LET OP: Dit deel werkt alleen als de fotoMAP op internet rwxrwxrwx heeft!!!
					//Als deze functies niet werken:
					//in php.ini de ; bij deze regel weghalen:
					//extension=php.gd2.dll
					//$thumb = imagecreate($newwidth, $newheight);
					$thumb = imagecreatetruecolor($newwidth, $newheight);
					$source = imagecreatefromjpeg($pad_afbeelding);

					// Resize
					imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
					@imagejpeg($thumb, $pad_thumb);
				}

				//Anders komt er ook een link naar de thumbs :-)
				if (substr ($filename, 0, 5)!='thumb'){
					print "<IMG SRC=\"$pad_thumb\">";
				}

			}
		}
		
	}
	else{
		echo 'Deze map bestaat niet - this folder does not exists!';
	}	
		
}

?>
Return current item: HuMo-gen