Vz7: Fatal error: Cannot redeclare resizeimage() previously declared

Beitrag lesen

Wie sieht denn der Inhalt von 'isp_image_resize.php' aus?

Ist ziemlich lang. Die Datei greift auch noch auf eine weitere Datei zu. 'isp_image_resize_func', welche die Fehlermeldung überhaupt verursacht.

Das hier ist 'isp_image_resize.php':

<?php

// Query, if configuration file exists
if(!file_exists("upload/config_isp_image_resize.php")) {
echo "config_isp_image_resize ist nicht vorhanden.";
echo "config_isp_image_resize does not exist.";
exit();
}

// Query, if  funktion file exists
if(!file_exists("upload/isp_image_resize_func.php")) {
echo "Resizefunktion isp_image_resize_func.php ist nicht vorhanden.";
echo " function does not exist.";
exit();
}

require("upload/config_isp_image_resize.php"); 	// Configuration file loading
require("upload/isp_image_resize_func.php"); 	// Resize function file loading

if ($lang == "de" or $lang == "") {require("upload/lang_de.php");}
if ($lang == "en" or $lang == "") {require("upload/lang_en.php");}

// Action query - required for global off register
if(isset($HTTP_POST_VARS['action'])) {$action = $HTTP_POST_VARS['action']; }
if(isset($HTTP_GET_VARS['action'])) {$action = $HTTP_GET_VARS['action']; }

if(!isset($action) or $action == "") $action = "isp_resize_form";

// Permitted filetype identify and output in the form
if(count($allowedfiletype) > 1) {
$msg = "$txt_dateitypen";
$msg .= implode(', ', $allowedfiletype);
}
elseif  (count($allowedfiletype) == 1) $action = "isp_resize_form";

// Check upload dir, if not create
if (is_dir($uploaddir)) {}
else {mkdir ($uploaddir);}


//----------------------------------------------------------------------------------------
// Check image upload and
//
if($action == "isp_image_upload_check") {
$error = "";
$ok = 1;

if($_FILES['image']['error'] == 1 and $ok == 1) {
$ok = 0;
$error = "$txt_error_1";
}

if($_FILES['image']['error'] == 3 and $ok == 1) {
$ok = 0;
$error = "$txt_error_3";
}

if($_FILES['image']['error'] == 4 and $ok == 1) {
$ok = 0;
$error = "$txt_error_4";
}

// check image type
If ($ok == 1) {
$filename = $_FILES["image"]["name"]; 	// original image name
$fileext = explode(".", $filename); 	// From the original image ext. determine

$fileext_1 = $fileext[1]; 				// ext. to reassign
$fileext_1 = strtolower($fileext_1); 	// for Unix Server

if (!in_array($fileext_1, $allowedfiletype)) {

if(count($allowedfiletype) > 1) {
$bild_typ = implode(', ', $allowedfiletype);
}
elseif (count($allowedfiletype) == 1) $bild_typ = $allowedfiletype[0];
$ok = 0;
$error = "$txt_error_file_typ";
}}
// end image typ check

// Image File Größe prüfen
if(filesize($_FILES['image']['tmp_name'])/1024/1024 >= $maxfilesize and $ok == 1) {
$ok = 0;
$error = "$txt_error_size";
}
// end image typ check

// If ok upload file
if($ok) {

$image_file_pfad = "{$uploaddir}/{$filename}";
move_uploaded_file($_FILES['image']['tmp_name'], $image_file_pfad);

// Examine whether the image in the size needs to be changed
$size = @GetImageSize($image_file_pfad);
$width = $size[0];
$height = $size[1];
$value = true;

// Maybe call  function
if($width <> $uploadMaxWidth || $height <> $uploadMaxHeight){$value = ResizeImage($image_file_pfad, $image_file_pfad, $uploadMaxWidth, $uploadMaxHeight);}

// Return value of the  function query
If ($value == true) {
$hinweis = "$txt_hinweis_1";
$action = "isp_resize_form";
} else {
unlink($image_file_pfad);
$hinweis .= "$txt_hinweis_2";
$action = "isp_resize_form";
}
} else {
$action = "isp_resize_form";
}}



//----------------------------------------------------------------------------------------
// ISP image  form
//
if($action == "isp_resize_form") {

if ($uploaddir == "" or $filename == "") $outimage = "";
else $outimage = "<img src=\"$uploaddir/$filename\" border=\"0\">";

// Output Form
echo "
<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd\">
<html>
<head>
<title>ISP image upload and  PHP script</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
<meta name=\"description\" content=\"Image upload and  PHP script - Bild bzw. Image Resize PHP Programm, Bildgröße mit PHP verändern\">
<meta name=\"publisher\" content=\"ISP www.neusser-marktplatz.de\">
<link href=\"isp_resize.css\" rel=\"stylesheet\" type=\"text/css\">
</head>

<body>
<div id=\"content\">
<table cellspacing=\"1\" cellpadding=\"0\" style=\"border: 1px solid #c0c0c0;\">
<tr><td class=\"red\">$error</td></tr>
<tr><td class=\"hinweis\">$hinweis</td></tr>
<tr><td>$txt_form_1 $maxfilesize MB</td></tr>
<tr><td>$msg</td></tr>
<form action=\"isp_image_resize.php\" enctype=\"multipart/form-data\" method=\"post\" class=\"form\">
<tr><td><input type=\"file\" name=\"image\" size=\"60\" class=\"formular\"></td></tr>
<tr><td>&nbsp;</td></tr>
<tr><td align=\"center\"><input type=\"submit\" name=\"submit\" value=\"$txt_form_2\" class=\"submit\"> </td></tr>
<input type=\"hidden\" name=\"action\" value=\"isp_image_upload_check\">
</form>
<tr><td>&nbsp;</td></tr>
</table>
<p>&nbsp;</p>
$outimage
</div>
</body></html>";
}
?>

Und das ist die func:


function ResizeImage($old_image_name, $new_image_name, $new_image_x_size, $new_image_y_size) {
// $old_image_name = orginal Image Name
// $new_image_name  = saved Image Name
// $new_image_x_size  = new x size
// $new_image_y_size  = new y size

global $image_prop;

// what version of GDLIB is installed on the server
if(@imagecreatetruecolor(1,1)) $GDLIB_VERS = 2;
else $GDLIB_VERS = 1;

// Image load and determine image type
$file = basename($old_image_name);
$image_ext = explode(".", $file);

// ------------------------------------------------------------------------
// GIF image load and resize
if($image_ext[1] == "gif" || $image_ext[1] == "GIF") {

if(function_exists ("ImageCreateFromGIF")) {
$imgA = ImageCreateFromGIF ($old_image_name);

// height and width recalculate
$org_x = ImageSX($imgA);
$org_y = ImageSY($imgA);

if($org_x >= $org_y && $image_prop == "ja") {
$new_image_x_size = $new_image_x_size;
$new_image_y_size = $org_y / ($org_x / $new_image_x_size);
$new_image_y_size = floor($new_image_y_size);
}

if($org_x < $org_y && $image_prop == "ja") {
$new_image_y_size = $new_image_y_size;
$new_image_x_size = $org_x / ($org_y / $new_image_y_size);
$new_image_x_size = floor($new_image_x_size);
}
// end calculation

// GIF resize
if($GDLIB_VERS == 2) {
$imgB = imagecreatetruecolor($new_image_x_size,$new_image_y_size);
imagecopyresampled($imgB,$imgA,0,0,0,0, $new_image_x_size, $new_image_y_size, $org_x ,$org_y);
} else {
$imgB = imagecreate($new_image_x_size,$new_image_y_size);
imagecopyresized($imgB, $imgA,0,0,0,0, $new_image_x_size, $new_image_y_size, $org_x ,$org_y);
}
if($imgB) imagegif($imgB, $new_image_name);

} else {
return false;
} // end function_exists
} // end image typ GIF and resize



// ------------------------------------------------------------------------
// JPG image load and resize
if($image_ext[1] == "jpg" || $image_ext[1] == "jpeg" || $image_ext[1] == "JPG" || $image_ext[1] == "JPEG") {

if(function_exists ("ImageCreateFromJPEG")) {
$imgA = ImageCreateFromJPEG ($old_image_name);

// height and width recalculate
$org_x = ImageSX($imgA);
$org_y = ImageSY($imgA);

if($org_x >= $org_y && $image_prop == "ja") {
$new_image_x_size = $new_image_x_size;
$new_image_y_size = $org_y / ($org_x / $new_image_x_size);
$new_image_y_size = floor($new_image_y_size);
}

if($org_x < $org_y && $image_prop == "ja") {
$new_image_y_size = $new_image_y_size;
$new_image_x_size = $org_x / ($org_y / $new_image_y_size);
$new_image_x_size = floor($new_image_x_size);
}
// end calculation

// JPG resize
$quality = 100;
if($GDLIB_VERS == 2) {
$imgB = imagecreatetruecolor($new_image_x_size,$new_image_y_size);
imagecopyresampled($imgB, $imgA,0,0,0,0, $new_image_x_size, $new_image_y_size, $org_x ,$org_y);
} else {
$imgB = imagecreate($new_image_x_size,$new_image_y_size);
imagecopyresized($imgB, $imgA,0,0,0,0, $new_image_x_size, $new_image_y_size, $org_x ,$org_y);
}
imagejpeg($imgB, $new_image_name, $quality);

} else {
return false;
} // end function_exists
} // end image typ JPG and resize



// ------------------------------------------------------------------------
// PNG image load and resize
if($image_ext[1] == "png" || $image_ext[1] == "PNG") {

if(function_exists ("ImageCreateFromPNG")) {
$imgA = ImageCreateFromPNG ($old_image_name);

// height and width recalculate
$org_x = ImageSX($imgA);
$org_y = ImageSY($imgA);

if($org_x >= $org_y && $image_prop == "ja") {
$new_image_x_size = $new_image_x_size;
$new_image_y_size = $org_y / ($org_x / $new_image_x_size);
$new_image_y_size = floor($new_image_y_size);
}

if($org_x < $org_y && $image_prop == "ja") {
$new_image_y_size = $new_image_y_size;
$new_image_x_size = $org_x / ($org_y / $new_image_y_size);
$new_image_x_size = floor($new_image_x_size);
}
// end calculation

// PNG resize
if($GDLIB_VERS == 2) {
$imgB = imagecreatetruecolor($new_image_x_size,$new_image_y_size);
imagecopyresampled($imgB, $imgA,0,0,0,0, $new_image_x_size, $new_image_y_size, $org_x ,$org_y);
} else {
$imgB = imagecreate($new_image_x_size,$new_image_y_size);
imagecopyresized($imgB, $imgA,0,0,0,0, $new_image_x_size, $new_image_y_size, $org_x ,$org_y);
}
imagepng($imgB, $new_image_name);

} else {
return false;
} // end function_exists
} // end image typ PNG and resize

// If image typ not available, send false
if(!$imgA) {return false;}

// If ok send true
return true;
}
?>