3 or ($member_db[1] != 1 and $action == "doimagedelete")){ msg("error", $echo['accessDenied'], $echo['errorAction']); } $imagePreview = $echo['imagePreview']; $allowed_extensions = array("gif", "jpg", "bmp", "png", "jpe", "jpeg"); $static_path_image_upload = $config_path_image_upload; $folder = $_GET['folder']; $config_path_image_upload = $config_path_image_upload.($folder == '' ? '' : '/'.$folder); //Create /thumbs folder if(!file_exists($config_path_image_upload.'/thumbs')) @mkdir($config_path_image_upload.'/thumbs'); //Create .htaccess file create_htaccess($config_path_image_upload.'/thumbs/.htaccess'); // ******************************************************************************** // Show Preview of Image // ******************************************************************************** if($action == "preview"){ echo << $imagePreview PREVIEWHTML; } // ******************************************************************************** // Show Images List // ******************************************************************************** elseif($action != "doimagedelete") { if($action == "quick") { echo" ".$echo['insertTitle']." "; } else { echoheader("images", $echo['header']); } // ******************************************************************************** // Upload Image(s) // ******************************************************************************** //Rename image if ($action == 'rename' and $image and $name){ $dir = end(explode("/", $path)); @rename($path.'/'.$image, $path.'/'.$name); @rename($path.'/thumbs/'.$image, $path.'/thumbs/'.$name); echo ''; } //Rename subfolder if ($action == 'change_dir' and $new_name){ $new_name = str_replace(" ", "_", $new_name); $path_arr = explode("/", $config_path_image_upload); $length = strlen(end($path_arr))+1; $new_path = substr($config_path_image_upload, 0, -$length); if(file_exists($new_path.'/'.$new_name)) echo "".$echo['error'].", ".$new_name." ".$echo['exist'].""; else { @rename($config_path_image_upload, $new_path.'/'.$new_name); echo ''; } } //Create subfolder if ($action == 'create_dir' and $new_dir){ $new_dir = str_replace(" ", "_", $new_dir); if(file_exists($config_path_image_upload.'/'.$new_dir)) echo "".$echo['error'].", ".$new_dir." ".$echo['exist'].""; else { @mkdir($config_path_image_upload.'/'.$new_dir); echo ''; create_htaccess($config_path_image_upload.'/'.$new_dir.'/.htaccess'); } } //Delete empty subfolder if ($action == "delete_dir"){ unlink($config_path_image_upload.'/thumbs/.htaccess'); rmdir($config_path_image_upload.'/thumbs'); unlink($config_path_image_upload.'/.htaccess'); rmdir($config_path_image_upload); echo ''; } //Move file if ($action == "move_file"){ if(!file_exists($config_path_image_upload.'/'.$file)){ copy($old_path.'/'.$file, $config_path_image_upload.'/'.$file); copy($old_path.'/thumbs/'.$file, $config_path_image_upload.'/thumbs/'.$file); unlink($old_path.'/'.$file); unlink($old_path.'/thumbs/'.$file); //echo ''; } } //Upload image if($subaction == "upload") { for ($i = 0; $i < count($_FILES['image']['name'])-1; $i++) { $image = $_FILES['image']['tmp_name'][$i]; $image_name = $_FILES['image']['name'][$i]; $image_name = str_replace(" ", "_", $image_name); $img_name_arr = explode(".",$image_name); $type = end($img_name_arr); if($image_name == ""){ $img_result .= "
$current_image -> ".$echo['notPicked'].""; } elseif( !isset($overwrite) and file_exists($config_path_image_upload."/".$image_name)){ $img_result .= "
$image_name -> ".$echo['existAllredy']."";} elseif( !(in_array($type, $allowed_extensions) or in_array(strtolower($type), $allowed_extensions)) ){ $img_result .= "
$image_name ->".$echo['badFormat'].""; } else { @copy($image, $config_path_image_upload.'/'.$image_name) or $img_result = "".$echo['cannotCopy'].""; //Add watermark (text) if ($watermark and $watermark_text != "") { if($watermark_font == "none") { @add_watermark($config_path_image_upload.'/'.$image_name, $watermark_text, $hotspot1, ($textcolor ? $textcolor : 'FFFFFF'), ($textsize ? $textsize : '12')); } else { @add_watermark($config_path_image_upload.'/'.$image_name, $watermark_text, $hotspot1, ($textcolor ? $textcolor : 'FFFFFF'), ($textsize ? $textsize : '12'), 'data/watermark/'.$watermark_font); } } //Add watermark (image) if ($merge) { @mergePix($config_path_image_upload.'/'.$image_name, 'data/watermark/'.$watermark_image, $config_path_image_upload.'/'.$image_name, $hotspot2, ($merge_transition ? $merge_transition : '40')); } //Make thumb if ($max < 1 or $max == "") {$max = 100;} if ($square == "yes") { make_thumb($config_path_image_upload."/".$image_name, $config_path_image_upload."/thumbs/".$image_name, $max, 'square'); } else make_thumb($config_path_image_upload."/".$image_name, $config_path_image_upload."/thumbs/".$image_name, $max, 'normal'); //Shadow if ($shadow == "yes") { shadow($config_path_image_upload."/".$image_name); shadow($config_path_image_upload."/thumbs/".$image_name); } if(file_exists($config_path_image_upload."/".$image_name)) { $img_result .= "
$image_name -> ".$echo['uploadOK'].""; }//if file is uploaded succesfully } } } /////////////////////////////////////////////////// // Upload Form /////////////////////////////////////////////////// ?>
".$echo['imageProperties']."


 
 




 

".$echo['altText']."
".$echo['align']."
".$echo['border']." ".$echo['pixels']."
".$echo['hSpace']." ".$echo['pixels']."
".$echo['vSpace']." ".$echo['pixels']."
"; } echo ""; //////////////////////// //Prepare image showing //////////////////////// //Show folder dropdown echo ""; } //Show folder creation if($action != "quick" and $_GET['folder'] == ""){ echo ''; echo ' '; echo ''; echo ' '; echo ""; } //Show delete button if(dir_is_empty($config_path_image_upload) and $_GET['folder'] != ""){ echo '"; } echo"".((dir_is_empty($config_path_image_upload) and $_GET['folder'] != "") ? '' : '
"; //Show folder changing if($action != "quick" and $_GET['folder'] != ""){ echo '
'; echo ''; echo ''; echo ' '; echo "
'; echo ''; echo ''; echo "
'.$echo['uploadedImages'].'')."
"; if ($action != 'quick'){ echo ""; } echo" "; $img_dir = opendir($config_path_image_upload); $i = 0; while ($file = readdir($img_dir)) { $img_name_arr = explode(".",$file); $img_type = end($img_name_arr); $img_name = substr($file, 0, -(strlen($img_type)+1)); if ((in_array($img_type, $allowed_extensions) or in_array(strtolower($img_type), $allowed_extensions)) and $file != ".." and $file != "." and $file != ".htaccess" and $file != "index.html" and is_file($config_path_image_upload."/".$file)) //Yes we'll store them in array for sorting $images_in_dir[] = $file; } if($images_in_dir){ natcasesort($images_in_dir); reset($images_in_dir); //Pagination $images_per_page = ($images_per_page ? $images_per_page : 21); $start_from = ($start_from ? $start_from : ''); $i = $start_from; $j = 0; //End Pagination foreach ($images_in_dir as $file) { //Add missing thumbs if(!file_exists($config_path_image_upload.'/thumbs/'.$file)) make_thumb($config_path_image_upload.'/'.$file, $config_path_image_upload.'/thumbs/'.$file, $config_missing_thumbs_size, $config_missing_thumbs_format); //Add missing thumbs //Pagination if ($j < $start_from){ $j++; continue; } //End Pagination $i++; $this_size = filesize($config_path_image_upload."/".$file); $total_size += $this_size; $img_info = getimagesize($config_path_image_upload."/".$file); $img_info_thumb = getimagesize($config_path_image_upload."/thumbs/".$file); if( $i%2 != 0 ){ $bg = "class=\"alternate\""; } else{ $bg = "class=\"alternate2\""; } ///////////////////////////////// //List images in addnews/editnews ///////////////////////////////// if($action == "quick") { $my_area = str_replace("_", " ", $area); $path_big = ""; $path_thumb = "thumbs/"; //If popup_in_news if ($config_popup_in_news == "yes") { $link1 = htmlspecialchars(''); } //Else else { $link1 = htmlspecialchars(''); } $link2 = ''; $empty_link = ""; //If popup_in_manager if($config_popup_in_manager == "yes") { echo" "; } //Else else { echo" "; } echo" "; } /////////////////////////////// //List images in image manager /////////////////////////////// else { echo" "; } //Pagination if ($i >= $images_per_page + $start_from){ break; } //End Pagination }//End foreach }//End if($images_in_dir) //Pagination if ($start_from > 0){ $previous = $start_from - $images_per_page; $npp_nav .= '<<'; } if (count($images_in_dir) > $images_per_page){ $npp_nav .= ' [ '; $enpages_count = @ceil(count($images_in_dir) / $images_per_page); $enpages_start_from = 0; $enpages = ''; for ($j = 1; $j <= $enpages_count; $j++){ if ($enpages_start_from != $start_from){ $enpages .= ''.$j.' '; } else { $enpages .= ' '.$j.' '; } $enpages_start_from += $images_per_page; } $npp_nav .= $enpages; $npp_nav .= ' ] '; } if (count($images_in_dir) > $i){ $npp_nav .= '>>'; } //End pagination if($i > 0){ echo""; } echo"'; } echo'
  Miniaturka Plik główny Operacje rozmiar wielkość 
    $file
    $file "; echo " $img_info[0]x$img_info[1]    ". formatsize($this_size) ."  
  $file ".$echo['moveFiles']."
".$echo['rename']."
$img_info[0]x$img_info[1]  ". formatsize($this_size) ."   
$npp_nav"; if($action != "quick"){ echo"
   
".$echo['total']."

". formatsize($total_size) .'  
'; if($action != "quick"){ echofooter(); } } // ******************************************************************************** // Delete Image // ******************************************************************************** elseif($action == "doimagedelete") { if(!isset($images)){ msg("info",$echo['notPicked'],$echo['notPickedInfo'], "$PHP_SELF?mod=images"); } foreach($images as $image){ unlink($config_path_image_upload."/".$image) or print($echo['cannotDelete']." $file"); unlink($config_path_image_upload."/thumbs/".$image) or print($echo['cannotDeleteThumb']." $file"); } msg("info",$echo['deletedHeader'],$echo['deletedOK'], "$PHP_SELF?mod=images"); } ///////////// //Functions// ///////////// /////////////////////////// //Function: get_subfolder //Creates a dropdown for all subfolders /////////////////////////// function get_subfolder($path, $old_path = false, $move = false, $image = false){ $dir = opendir($path); while ($subfolder = readdir($dir)) { if(is_dir($path.'/'.$subfolder) and $subfolder != "." and $subfolder != ".." and $subfolder != "thumbs"){ $all_subfolders .= ""; } } return $all_subfolders; } /////////////////////////// //Function: dir_is_empty //Checks if dir is empty /////////////////////////// function dir_is_empty($path){ $dir = opendir($path); $i = 0; while ($files_in_subfolder = readdir($dir)) { if($files_in_subfolder != "." and $files_in_subfolder != ".." and $files_in_subfolder != "thumbs" and $files_in_subfolder != ".htaccess"){ $i++; } } if($i == 0) return true; else return false; } /////////////////////////// //Function: create_htaccess //Creates a .htaccess file /////////////////////////// function create_htaccess($path_to_file){ if(!file_exists($path_to_file)){ $ht_file = @fopen($path_to_file, w); $htaccess = "Order Deny,Allow\nAllow from all"; @fwrite($ht_file, $htaccess); @fclose($path_to_file); } } ////////////////////// //Function: make_thumb //Creates a thumbnail ////////////////////// function make_thumb($src, $dest, $new_size, $way) { global $type; $size = getimagesize($src); $img_width = $size[0]; $img_height = $size[1]; if(($img_width > $new_size) or ($img_height > $new_size)){ //Keep dimensions if($way == "normal"){ $ratio = $new_size/$img_width; $new_width = $new_size; $new_height = $img_height*$ratio; $off_w = 0; $off_h = 0; } //Crop else { if($img_width > $img_height){ $new_width = $new_size; $new_height = $new_size; $off_w = ($img_width-$img_height)/2; $off_h = 0; $img_width = $img_height; } else if ($img_height > $img_width){ $new_width = $new_size; $new_height = $new_size; $off_w = 0; $off_h = ($img_height - $img_width)/2; $img_height = $img_width; } else{ $new_width = $new_size; $new_height = $new_size; $off_w = 0; $off_h = 0; } } if (strtolower($type) == "gif") { $im_in = @imagecreatefromgif($src); } else { $im_in = @imagecreatefromjpeg($src); } $im_out = @imagecreatetruecolor($new_width, $new_height); @imagecopyresampled($im_out, $im_in, 0, 0, $off_w, $off_h, $new_width, $new_height, $img_width, $img_height); } else { @copy($src, $dest); } if (strtolower($type) == "gif") { @imagegif($im_out, $dest); } else { @imagejpeg($im_out, $dest); } } /////////////////////////// //Function dropshadow //Adds a dropshadow to the thumb //Code taken from http://codewalkers.com/tutorials/83/1.html ////////////////////////////////// function shadow($thumb_in) { global $type; define("DS_OFFSET", 5); define("DS_STEPS", 10); define("DS_SPREAD", 1); $background = array("r" => 255, "g" => 255, "b" => 255); list($o_width, $o_height) = getimagesize($thumb_in); $width = $o_width + DS_OFFSET; $height = $o_height + DS_OFFSET; $image_sh = @imagecreatetruecolor($width, $height); $step_offset = array("r" => ($background["r"] / DS_STEPS), "g" => ($background["g"] / DS_STEPS), "b" => ($background["b"] / DS_STEPS)); $current_color = $background; for ($i = 0; $i <= DS_STEPS; $i++) { $colors[$i] = @imagecolorallocate($image_sh, round($current_color["r"]), round($current_color["g"]), round($current_color["b"])); $current_color["r"] -= $step_offset["r"]; $current_color["g"] -= $step_offset["g"]; $current_color["b"] -= $step_offset["b"]; } @imagefilledrectangle($image_sh, 0,0, $width, $height, $colors[0]); for ($i = 0; $i < count($colors); $i++) { @imagefilledrectangle($image_sh, DS_OFFSET, DS_OFFSET, $width, $height, $colors[$i]); $width -= DS_SPREAD; $height -= DS_SPREAD; } if (strtolower($type) == "gif") { $original_image = @imagecreatefromgif($thumb_in); } else { $original_image = @imagecreatefromjpeg($thumb_in); } @imagecopymerge($image_sh, $original_image, 0,0, 0,0, $o_width, $o_height, 100); if (strtolower($type) == "gif") { @imagegif($image_sh, $thumb_in); } else { @imagejpeg($image_sh, $thumb_in); } } ///////////////// //Function Watermark //Code taken from http://edge.dev.box.sk/smsread.php?newsid=310 /////////////////// function add_watermark($thumb_in,$text="[date]",$hotspot=8,$rgbtext="FFFFFF",$font_size=12,$font="Arial.TTF",$datfmt="d-m-Y",$rgbtsdw="000000",$txp=25,$typ=15,$sxp=1,$syp=1) { $suffx=substr($thumb_in,strlen($thumb_in)-4,4); $suffx = strtolower($suffx); if ($suffx==".jpg" || $suffx=="jpeg" || $suffx==".png" || $suffx==".gif") { $text2 = $text; $text=str_replace("[date]",date($datfmt),$text); if ($suffx==".jpg" || $suffx=="jpeg") { $image=imagecreatefromjpeg($thumb_in); } if ($suffx==".png") { $image=imagecreatefrompng($thumb_in); } if ($suffx == ".gif") { $image=imagecreatefromgif($thumb_in); } $rgbtext=HexDec($rgbtext); $txtr=floor($rgbtext/pow(256,2)); $txtg=floor(($rgbtext%pow(256,2))/pow(256,1)); $txtb=floor((($rgbtext%pow(256,2))%pow(256,1))/pow(256,0)); $rgbtsdw=HexDec($rgbtsdw); $tsdr=floor($rgbtsdw/pow(256,2)); $tsdg=floor(($rgbtsdw%pow(256,2))/pow(256,1)); $tsdb=floor((($rgbtsdw%pow(256,2))%pow(256,1))/pow(256,0)); $coltext = imagecolorallocate($image,$txtr,$txtg,$txtb); $coltsdw = imagecolorallocate($image,$tsdr,$tsdg,$tsdb); if ($hotspot!=0) { $ix=imagesx($image); $iy=imagesy($image); $tsw=($text2 == "[date]" ? strlen($text)+2 : strlen($text))*$font_size/imagefontwidth($font)*3; $tsh=$font_size/imagefontheight($font); switch ($hotspot) { case 1: $txp=$txp; $typ=$tsh*$tsh+imagefontheight($font)*2+$typ; break; case 2: $txp=floor(($ix-$tsw)/2); $typ=$tsh*$tsh+imagefontheight($font)*2+$typ; break; case 3: $txp=$ix-$tsw-$txp; $typ=$tsh*$tsh+imagefontheight($font)*2+$typ; break; case 4: $txp=$txp; $typ=floor(($iy-$tsh)/2); break; case 5: $txp=floor(($ix-$tsw)/2); $typ=floor(($iy-$tsh)/2); break; case 6: $txp=$ix-$tsw-$txp; $typ=floor(($iy-$tsh)/2); break; case 7: $txp=$txp; $typ=$iy-$tsh-$typ; break; case 8: $txp=floor(($ix-$tsw)/2); $typ=$iy-$tsh-$typ; break; case 9: $txp=$ix-$tsw-$txp; $typ=$iy-$tsh-$typ; break; } } ImageTTFText($image,$font_size,0,$txp+$sxp,$typ+$syp,$coltsdw,$font,$text); ImageTTFText($image,$font_size,0,$txp,$typ,$coltext,$font,$text); if ($suffx==".jpg" || $suffx=="jpeg") { imagejpeg($image, $thumb_in); } if ($suffx==".png") { imagepng($image, $thumb_in); } if ($suffx == ".gif") { imagegif($image, $thumb_in); } } } //////////////////// //Function mergePix //Taken from http://de3.php.net/manual/de/function.imagecopymerge.php /////////////////////// function mergePix($sourcefile,$insertfile, $targetfile, $pos=0,$transition=30) { //Get the resource id?s of the pictures switch (strtolower(end(explode('.', $sourcefile)))) { case 'gif': $sourcefile_id = imageCreateFromGIF($sourcefile); break; case 'jpg': $sourcefile_id = imageCreateFromJPEG($sourcefile); break; case 'png': $sourcefile_id = imageCreateFromPNG($sourcefile); break; } switch (strtolower(end(explode('.', $insertfile)))) { case 'gif': $insertfile_id = imageCreateFromGIF($insertfile); break; case 'jpg': $insertfile_id = imageCreateFromJPEG($insertfile); break; case 'png': $insertfile_id = imageCreateFromPNG($insertfile); break; } //Get the sizes of both pix $sourcefile_width=imageSX($sourcefile_id); $sourcefile_height=imageSY($sourcefile_id); $insertfile_width=imageSX($insertfile_id); $insertfile_height=imageSY($insertfile_id); //middle if( $pos == 0 ) { $dest_x = ( $sourcefile_width / 2 ) - ( $insertfile_width / 2 ); $dest_y = ( $sourcefile_height / 2 ) - ( $insertfile_height / 2 ); } //top left if( $pos == 1 ) { $dest_x = 10; $dest_y = 10; } //top right if( $pos == 2 ) { $dest_x = $sourcefile_width - $insertfile_width - 10; $dest_y = 10; } //bottom right if( $pos == 3 ) { $dest_x = $sourcefile_width - $insertfile_width - 10; $dest_y = $sourcefile_height - $insertfile_height - 10; } //bottom left if( $pos == 4 ) { $dest_x = 10; $dest_y = $sourcefile_height - $insertfile_height - 10; } //top middle if( $pos == 5 ) { $dest_x = ( ( $sourcefile_width - $insertfile_width ) / 2 ); $dest_y = 10; } //middle right if( $pos == 6 ) { $dest_x = $sourcefile_width - $insertfile_width - 10; $dest_y = ( $sourcefile_height / 2 ) - ( $insertfile_height / 2 ); } //bottom middle if( $pos == 7 ) { $dest_x = ( ( $sourcefile_width - $insertfile_width ) / 2 ); $dest_y = $sourcefile_height - $insertfile_height - 10; } //middle left if( $pos == 8 ) { $dest_x = 10; $dest_y = ( $sourcefile_height / 2 ) - ( $insertfile_height / 2 ); } //The main thing : merge the two pix imageCopyMerge($sourcefile_id, $insertfile_id,$dest_x,$dest_y,0,0,$insertfile_width,$insertfile_height,$transition); //Create a jpeg/gif/png out of the modified picture switch (strtolower(end(explode('.', $sourcefile)))) { case 'gif': imagegif ($sourcefile_id,"$targetfile"); break; case 'jpg': imagejpeg ($sourcefile_id,"$targetfile"); break; case 'png': imagepng ($sourcefile_id,"$targetfile"); break; } } ?>