3 or ($member_db[1] != 1 and $action == "doimagedelete")){ msg("error", "Access Denied", "You don't have permission to manage images"); } $allowed_extensions = array("gif", "jpg", "bmp", "png", "jpe", "jpeg"); ///////////////////////// //Configuration of popups ///////////////////////// $popup_in_news = true; $popup_in_manager = true; $images_per_page = 10; ///////////////////////// $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 << Image Preview PREVIEWHTML; } // ******************************************************************************** // Show Images List // ******************************************************************************** elseif($action != "doimagedelete") { if($action == "quick") { echo" Insert Image "; }else{ echoheader("images","Manage Images"); } // ******************************************************************************** // 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 "Error, ".$new_name." already exists."; 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 "Error, ".$new_dir." already exists."; 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 -> No File Specified For Upload!"; } elseif( !isset($overwrite) and file_exists($config_path_image_upload."/".$image_name)){ $img_result .= "
$image_name -> Image already exist!";} elseif( !(in_array($type, $allowed_extensions) or in_array(strtolower($type), $allowed_extensions)) ){ $img_result .= "
$image_name ->This type of file is not allowed !!!"; } else { @copy($image, $config_path_image_upload.'/'.$image_name) or $img_result = "Not able to upload image.
Make sure that file upload is enabled or contact your server administrator."; //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."/thumbs/".$image_name); } if(file_exists($config_path_image_upload."/".$image_name)) { $img_result .= "
$image_name -> Image was uploaded"; }//if file is uploaded succesfully } } } ////////////// //Upload Form ////////////// echo<< "; //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'] != "") ? '' : '')."
Upload Image
Width of the thumb
 
$img_result
HTML; ////////////////// //Image properties ////////////////// if($action == "quick"){ echo"
Image Properties
Alt. Text:
Image Align
Border pixels
hspace pixels
vspace pixels
"; } //////////////////////// //Prepare image showing //////////////////////// echo"

"; //Show folder changing if($action != "quick" and $_GET['folder'] != ""){ echo '
'; echo ''; echo ''; echo ' '; echo "
'; echo ''; echo ' '; echo "

Uploaded Images
"; $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) { //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 = "bgcolor=#F7F6F4"; } else{ $bg = ""; } ///////////////////////////////// //List images in addnews/editnews ///////////////////////////////// if($action == "quick") { $my_area = str_replace("_", " ", $area); $path_big = ""; $path_thumb = "thumbs/"; //If popup_in_news if ($popup_in_news == true) { $link1 = htmlspecialchars(''); } //Else else { $link1 = htmlspecialchars(''); } $link2 = ''; $empty_link = ""; //If popup_in_manager if($popup_in_manager == true) { 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'
  $file"; } //Else else { echo"
  $file"; } echo"      "; echo " $img_info[0]x$img_info[1]    ". formatsize($this_size) ."
  $file Move to
[rename] $img_info[0]x$img_info[1]  ". formatsize($this_size) ."
$npp_nav"; if($action != "quick"){ echo"
   
Total size
   
". formatsize($total_size) .'
'; if($action != "quick"){ echofooter(); } } // ******************************************************************************** // Delete Image // ******************************************************************************** elseif($action == "doimagedelete") { if(!isset($images)){ msg("info","No Images selected","You must select images to be deleted.", "$PHP_SELF?mod=images"); } foreach($images as $image){ unlink($config_path_image_upload."/".$image) or print("Could not delete image $file"); unlink($config_path_image_upload."/thumbs/".$image) or print("Could not delete thumb $file"); } msg("info","Image(s) Deleted","The image was successfully deleted.", "$PHP_SELF?mod=images"); } ///////////// //Functions// ///////////// /////////////////////////// //Function: get_subfolder //Creates a dropdown for all subfolders /////////////////////////// function get_subfolder($path, $old_path, $move = false, $image){ $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); } } ?>