I need a help please
an error occured while a user used the MOD :
Fatal error: Cannot redeclare ann_rename() (previously declared in /home/emarati2/public_html/gallery/includes/annotate.php:9) in /home/emarati2/public_html/gallery/includes/annotate.php on line 9
and this is the file annotate.php
<?php
# v.1.4a - updated by v@no - im fix * file rename fix
if (!defined('ROOT_PATH')) {
die("Security violation");
}
=====>> function ann_rename($old, $new){
$oldWD = getcwd();
chdir(realpath(dirname($old)));
$ok = (rename(basename($old), basename($new))) ? 1 : 0;
chdir($oldWD);
return $ok;
}
function annotate_image($file) {
global $convert_options, $config, $ann_user_name, $ann_dest;
$ann_dest = $file;
$file_bak = $file.".bak";
if (!ann_rename($file, $file_bak)) {
return false;
}
if (annotate_it($file_bak, $file, $convert_options['convert_tool'])) {
@chmod($file, CHMOD_FILES);
@unlink($file_bak);
return true;
}
else {
ann_rename($file_bak, $file);
return false;
}
}
function ImageColorResolveAlphaHex($image, $color, $alpha){
$color = str_replace("#","",$color);
$red = hexdec(substr($color,0,2)); $green = hexdec(substr($color,2,2)); $blue = hexdec(substr($color,4,2));
$out = ImageColorAllocate($image, $red, $green, $blue);
$out = ImageColorResolveAlpha($image, $red, $green, $blue, round($alpha * 127));
return($out);
}
function annotate_it($ann_src, $ann_dest, $ann_tool) {
global $convert_options, $config, $ann_user_name, $ann_dest, $script_url;
$ann_mode = $config['annotation_mode'];
$ann_embed_image = $config['annotation_embed_image'];
$annotation_embed_image_opacity = $config['annotation_embed_image_opacity'];
$annotation_embed_image_bg = $config['annotation_embed_image_bg'];
$ann_text = $config['annotation_text'];
$ann_font_path = $config['annotation_font'];
$ann_font_size = $config['annotation_font_size'];
$ann_image_quality = $config['annotation_image_quality'];
$use_shadow = $config['annotation_use_shadow'];
$shadow_offset = $config['annotation_shadow_offset'];
$ann_fill_color = $config['annotation_fill_color'];
$ann_shadow_color = $config['annotation_shadow_color'];
$ann_fill_alpha = $config['annotation_fill_alpha'];
$ann_shadow_alpha = $config['annotation_shadow_alpha'];
$ann_top_offset = $config['annotation_top_offset'];
$ann_bottom_offset = $config['annotation_bottom_offset'];
$ann_left_offset = $config['annotation_left_offset'];
$ann_right_offset = $config['annotation_right_offset'];
$vertical = $config['annotation_v_alignment'];
$horisontal = $config['annotation_h_alignment'];
$ann_url = str_replace ("http://", "", $script_url);
$ann_date = date($config['date_format']);
$ann_time = date($config['time_format']);
$ann_site_name = $config['site_name'];
$ann_user = $user_info['user_id'];
$ann_vars = array ("'%D'", "'%T'", "'%N'", "'%H'", "'%U'", "'%S'", "'%B'");
$ann_repl = array ("$ann_date", "$ann_time", "$ann_site_name", "$script_url", "$ann_url", "$ann_user_name", "\n\r");
$ann_text = str_replace ($ann_vars, $ann_repl, $ann_text);
if ('IN_CP') {
$ann_user_name = "Administrator";
$ann_text = str_replace ("/admin/plugins", "", $ann_text);
}
if ($ann_tool == "im") { $ann_text = str_replace ("\n\r", "\\n\r", $ann_text); }
switch ($ann_mode) {
case "text" : $use_text = 1; $use_image = 0; break;
case "image" : $use_text = 0; $use_image = 1; break;
}
$isz = 0; $isz= @getimagesize($ann_src);
if ($use_text) {
if ($ann_tool != "netpbm") {
$ann_box = ImageTTFBBox($ann_font_size, 0, $ann_font_path, $ann_text);
$ann_text_width=$ann_box[4]-$ann_box[6]; $ann_text_height=$ann_box[0]-$ann_box[7];
switch ($horisontal) {
case "left" : $h_offset = $ann_left_offset; break;
case "center" : $h_offset = (($isz[0]/2) - ($ann_text_width/2)); break;
case "right" : $h_offset = ($isz[0] - $ann_text_width - $ann_right_offset); break;
}
switch ($vertical) {
case "top" : $v_offset = $ann_text_height + $ann_top_offset; break;
case "middle" : $v_offset = (($isz[1]/2) - ($ann_text_height/2)); break;
case "bottom" : $v_offset = $isz[1] - ($ann_text_height/2) - $ann_bottom_offset; break;
}
} else {
switch ($horisontal) {
case "left" : $h_offset = $ann_left_offset; $h_align="-align=left"; break;
case "center" : $h_offset = $ann_left_offset; $h_align="-align=center"; break;
case "right" : $h_offset = 0-$ann_right_offset; $h_align="-align=right"; break;
}
switch ($vertical) {
case "top" : $v_offset = $ann_top_offset; $v_align="-valign=top"; break;
case "middle" : $v_offset = $ann_top_offset; $v_align="-valign=middle"; break;
case "bottom" : $v_offset = 0-$ann_bottom_offset; $v_align="-valign=bottom"; break;
}
}
}
else {
$ann_box = @getimagesize($ann_embed_image);
$ann_text_width=$ann_box[0]; $ann_text_height=$ann_box[1];
switch ($horisontal) {
case "left" : $h_offset = $ann_left_offset; break;
case "center" : $h_offset = (($isz[0]/2) - ($ann_text_width/2)); break;
case "right" : $h_offset = ($isz[0] - $ann_text_width - $ann_right_offset); break;
}
switch ($vertical) {
case "top" : $v_offset = $ann_top_offset; break;
case "middle" : $v_offset = (($isz[1]/2) - ($ann_text_height/2)); break;
case "bottom" : $v_offset = $isz[1] - $ann_text_height - $ann_bottom_offset; break;
}
}
$h_offset = round($h_offset); $v_offset = round($v_offset);
if ($isz[0] > $ann_text_width) {
if ($ann_tool == "im") {
if ($use_image) {
$command = $convert_options['convert_path']." -quality ".$ann_image_quality." -draw \"image CopyOpacity $h_offset,$v_offset 0,0 $ann_embed_image\" \"$ann_src\" \"$ann_dest\"";
system($command);
} else {
if (!$use_shadow) {
$command = $convert_options['convert_path']." -quality ".$ann_image_quality." -antialias -density 90 -font '$ann_font_path' -fill '$ann_fill_color' -pointsize $ann_font_size -draw \"text $h_offset,$v_offset '$ann_text'\" \"$ann_src\" \"$ann_dest\"";
system($command);
} else {
$command = $convert_options['convert_path']." -quality ". 100 ." -antialias -density 90 -font '$ann_font_path' -fill '$ann_shadow_color' -pointsize $ann_font_size -draw \"text $h_offset,$v_offset '$ann_text'\" \"$ann_src\" \"$ann_dest\"";
system($command);
$file_shd = $ann_dest.".shd";
ann_rename('./'.$ann_dest, './'.$file_shd);
$h_offset = $h_offset - $shadow_offset; $v_offset = $v_offset - $shadow_offset;
$command = $convert_options['convert_path']." -quality ".$ann_image_quality." -antialias -density 90 -font '$ann_font_path' -fill '$ann_fill_color' -pointsize $ann_font_size -draw \"text $h_offset,$v_offset '$ann_text'\" \"$file_shd\" \"$ann_dest\"";
system($command);
@chmod($ann_dest, CHMOD_FILES);
@unlink($file_shd);
}
}
} else if ($ann_tool == "gd") {
$tmp_image = @ImageCreateFromJpeg ($ann_src);
$ann_fill_color = ImageColorResolveAlphaHex ($tmp_image, $ann_fill_color, $ann_fill_alpha);
$ann_shadow_color = ImageColorResolveAlphaHex ($tmp_image, $ann_shadow_color, $ann_shadow_alpha);
if ($use_image) {
$ann_embed_image = @ImageCreateFromPNG($ann_embed_image);
$ann_image_width=imageSX($ann_embed_image);
$ann_image_height=imageSY($ann_embed_image);
$bg_color = str_replace("#","",$annotation_embed_image_bg);
$bg_red = hexdec(substr($bg_color,0,2));
$bg_green = hexdec(substr($bg_color,2,2));
$bg_blue = hexdec(substr($bg_color,4,2));
$bg_trans_color = ImageColorAllocate ($ann_embed_image, $bg_red, $bg_green, $bg_blue);
ImageColorTransparent($ann_embed_image, $bg_trans_color);
ImageCopyMerge($tmp_image, $ann_embed_image, $h_offset, $v_offset, 0, 0, $ann_image_width, $ann_image_height, $annotation_embed_image_opacity);
ImageJpeg($tmp_image, $ann_dest, $ann_image_quality);
ImageDestroy($tmp_image);
} else {
if ($use_shadow) {ImageTTFText ($tmp_image, $ann_font_size, 0, ($h_offset+$shadow_offset), ($v_offset+$shadow_offset), $ann_shadow_color, $ann_font_path, $ann_text);}
ImageTTFText ($tmp_image, $ann_font_size, 0, $h_offset, $v_offset, $ann_fill_color, $ann_font_path, $ann_text);
ImageJpeg($tmp_image, $ann_dest, $ann_image_quality);
ImageDestroy($tmp_image);
}
} else if ($ann_tool == "netpbm") {
if ($use_text) {
$command = $convert_options['convert_path']."/pbmtext -quiet -font ".$ann_font_path." '".$ann_text."' > ".ROOT_PATH.MEDIA_DIR."/ann-mask.pnm";
system($command);
$command = $convert_options['convert_path']."/ppmchange -quiet #000000 ".$ann_fill_color." ".ROOT_PATH.MEDIA_DIR."/ann-mask.pnm > ".ROOT_PATH.MEDIA_DIR."/ann-text.pnm";
system($command);
if ($use_shadow) {$command = $convert_options['convert_path']."/ppmchange -quiet #000000 ".$ann_shadow_color." ".ROOT_PATH.MEDIA_DIR."/ann-mask.pnm > ".ROOT_PATH.MEDIA_DIR."/ann-text-shd.pnm";
system($command); }
$command = $convert_options['convert_path']."/jpegtopnm -quiet ".$ann_src." | ";
if ($use_shadow) { $command .= $convert_options['convert_path']."/pnmcomp -quiet -invert -opacity=".(1-$ann_shadow_alpha)." -alpha ".ROOT_PATH.MEDIA_DIR."/ann-mask.pnm ".$h_align." ".$v_align." -xoff=".($h_offset+$shadow_offset)." -yoff=".($v_offset+$shadow_offset)." ".ROOT_PATH.MEDIA_DIR."/ann-text-shd.pnm | "; }
$command .= $convert_options['convert_path']."/pnmcomp -quiet -invert -opacity=".(1-$ann_fill_alpha)." -alpha ".ROOT_PATH.MEDIA_DIR."/ann-mask.pnm ".$h_align." ".$v_align." -xoff=".$h_offset." -yoff=".$v_offset." ".ROOT_PATH.MEDIA_DIR."/ann-text.pnm | ";
$command .= $convert_options['convert_path']."/pnmtojpeg -quiet -quality=".$ann_image_quality." -optimize > ".$ann_dest;
system($command);
@unlink(ROOT_PATH.MEDIA_DIR."/ann-mask.pnm");
@unlink(ROOT_PATH.MEDIA_DIR."/ann-text.pnm");
if ($use_shadow) {@unlink(ROOT_PATH.MEDIA_DIR."/ann-text-shd.pnm"); }
} if ($use_image) {
$command = $convert_options['convert_path']."/pngtopnm -quiet ".$ann_embed_image." > ".ROOT_PATH.MEDIA_DIR."/ann-logo.pnm";
system($command);
$command = $convert_options['convert_path']."/ppmcolormask -quiet ".$annotation_embed_image_bg." ".ROOT_PATH.MEDIA_DIR."/ann-logo.pnm > ".ROOT_PATH.MEDIA_DIR."/ann-mask.pnm";
system($command);
$command = $convert_options['convert_path']."/jpegtopnm -quiet ".$ann_src." | ";
$command .= $convert_options['convert_path']."/pnmcomp -quiet -opacity=".($annotation_embed_image_opacity/100)." -alpha ".ROOT_PATH.MEDIA_DIR."/ann-mask.pnm -xoff=".$h_offset." -yoff=".$v_offset." ".ROOT_PATH.MEDIA_DIR."/ann-logo.pnm | ";
$command .= $convert_options['convert_path']."/pnmtojpeg -quiet -quality=".$ann_image_quality." -optimize > ".$ann_dest;
system($command);
@unlink(ROOT_PATH.MEDIA_DIR."/ann-mask.pnm");
@unlink(ROOT_PATH.MEDIA_DIR."/ann-logo.pnm");
}
}
return (file_exists($ann_dest)) ? 1 : 0;
}
}
?>