array(), 'message' => array() ); $deleteqty = 0; $renameqty = 0; $resizeqty = 0; $rotateqty = 0; $moveqty = 0; $errorqty = 0; // Set when rotating images to force thumbnail refresh $imagerefresh =''; // Delete any checked files if(isset($_POST['deletefile'])) { foreach($_POST['deletefile'] as $delthis => $val) { $delthisfile = $tinybrowser['docroot'].$editpath.$_POST['actionfile'][$delthis]; if (file_exists($delthisfile) && unlink($delthisfile)) $deleteqty++; else $errorqty++; if($typenow=='image') { $delthisthumb = $tinybrowser['docroot'].$editpath.'_thumbs/_'.$_POST['actionfile'][$delthis]; if (file_exists($delthisthumb)) unlink($delthisthumb); } } } // Rename any files with changed name if(isset($_POST['renamefile'])) { foreach($_POST['renamefile'] as $namethis => $newname) { if($_POST['actionfile'][$namethis] != $newname.$_POST['renameext'][$namethis]) { $namethisfilefrom = $tinybrowser['docroot'].$editpath.$_POST['actionfile'][$namethis]; $namethisfileto = $tinybrowser['docroot'].$editpath.clean_filename($newname.$_POST['renameext'][$namethis]); if (file_exists($namethisfilefrom) && rename($namethisfilefrom,$namethisfileto)) $renameqty++; else $errorqty++; if($typenow=='image') { $namethisthumbfrom = $tinybrowser['docroot'].$editpath.'_thumbs/_'.$_POST['actionfile'][$namethis]; $namethisthumbto = $tinybrowser['docroot'].$editpath.'_thumbs/_'.clean_filename($newname.$_POST['renameext'][$namethis]); if (file_exists($namethisthumbfrom)) rename($namethisthumbfrom,$namethisthumbto); } } } } // Move any checked files if(isset($_POST['movefile'])) { foreach($_POST['movefile'] as $movethis => $val) { $movethisfile = $tinybrowser['docroot'].$editpath.$_POST['actionfile'][$movethis]; $movefiledest = $tinybrowser['docroot'].$destfolder.$_POST['actionfile'][$movethis]; if (!file_exists($movefiledest) && file_exists($movethisfile) && copy($movethisfile,$movefiledest)) { $moveqty++; unlink($movethisfile); if($typenow=='image') { $movethisthumb = $tinybrowser['docroot'].$editpath.'_thumbs/_'.$_POST['actionfile'][$movethis]; $movethumbdest = $tinybrowser['docroot'].$destfolder.'_thumbs/_'.$_POST['actionfile'][$movethis]; if (file_exists($movethisthumb) && copy($movethisthumb,$movethumbdest)) unlink($movethisthumb); } } else $errorqty++; } } // Resize any files with new size if(isset($_POST['resizefile'])) { foreach($_POST['resizefile'] as $sizethis => $newsize) { $newsize = intval($newsize); if($newsize) { // detect silly sizes if($newsize > $tinybrowser['thumbsize']) { // do image resize $targetimg = $tinybrowser['docroot'].$editpath.$_POST['actionfile'][$sizethis]; if (file_exists($targetimg)) { $mime = getimagesize($targetimg); if($_POST['resizetype'][$sizethis]=='width') { $rw = $newsize; $rh = $mime[1]; } else { $rw = $mime[0]; $rh = $newsize; } $im = convert_image($targetimg,$mime['mime']); resizeimage($im,$rw,$rh,$targetimg,$tinybrowser['imagequality'],$mime['mime']); imagedestroy($im); $resizeqty++; } else $errorqty++; } else $errorqty++; } } } // Rotate any selected files if(isset($_POST['rotatefile'])) { $imagerefresh = '?refresh='.uniqid(''); foreach($_POST['rotatefile'] as $rotatethis => $direction) { if($direction != 'none') { $targetimg = $tinybrowser['docroot'].$editpath.$_POST['actionfile'][$rotatethis]; if (file_exists($targetimg)) { // rotate image if($direction == 'clock') $degree=270; else $degree=90; $mime = getimagesize($targetimg); $im = convert_image($targetimg,$mime['mime']); // additional processing for png / gif transparencies (credit to Dirk Bohl) if($mime['mime'] == 'image/x-png' || $mime['mime'] == 'image/png') { imagealphablending($newim, false); imagesavealpha($newim, true); } elseif($mime['mime'] == 'image/gif') { $originaltransparentcolor = imagecolortransparent( $im ); if($originaltransparentcolor >= 0 && $originaltransparentcolor < imagecolorstotal( $im )) { $transparentcolor = imagecolorsforindex( $im, $originaltransparentcolor ); $newtransparentcolor = imagecolorallocate($newim,$transparentcolor['red'],$transparentcolor['green'],$transparentcolor['blue']); imagefill( $newim, 0, 0, $newtransparentcolor ); imagecolortransparent( $newim, $newtransparentcolor ); } } $newim = imagerotate($im, $degree, 0); imagedestroy($im); if($mime['mime'] == 'image/pjpeg' || $mime['mime'] == 'image/jpeg') imagejpeg ($newim,$targetimg,$tinybrowser['imagequality']); elseif($mime['mime'] == 'image/x-png' || $mime['mime'] == 'image/png') imagepng ($newim,$targetimg,substr($tinybrowser['imagequality'],0,1)); elseif($mime['mime'] == 'image/gif') imagegif ($newim,$targetimg); imagedestroy($newim); $rotateqty++; // delete and recreate thumbnail image $targetthumb = $tinybrowser['docroot'].$editpath.'_thumbs/_'.$_POST['actionfile'][$rotatethis]; if (file_exists($targetthumb)) unlink($targetthumb); $mime = getimagesize($targetimg); $im = convert_image($targetimg,$mime['mime']); resizeimage($im,$tinybrowser['thumbsize'],$tinybrowser['thumbsize'],$targetthumb,$tinybrowser['thumbquality'],$mime['mime']); imagedestroy($im); } else $errorqty++; } } } // Read directory contents and populate $file array $dh = opendir($tinybrowser['docroot'].$editpath); $file = array(); while (($filename = readdir($dh)) !== false) { // get file extension $nameparts = explode('.',$filename); $ext = end($nameparts); // filter directories and prohibited file types if($filename != '.' && $filename != '..' && !is_dir($tinybrowser['docroot'].$editpath.$filename) && !in_array($ext, $tinybrowser['prohibited']) && ($typenow == 'file' || strpos(strtolower($tinybrowser['filetype'][$typenow]),strtolower($ext)))) { // search file name if search term entered if($findnow) $exists = strpos(strtolower($filename),strtolower($findnow)); // assign file details to array, for all files or those that match search if(!$findnow || ($findnow && $exists !== false)) { $file['name'][] = $filename; $file['sortname'][] = strtolower($filename); $file['modified'][] = filemtime($tinybrowser['docroot'].$editpath.$filename); $file['size'][] = filesize($tinybrowser['docroot'].$editpath.$filename); // image specific info or general if($typenow=='image' && $imginfo = getimagesize($tinybrowser['docroot'].$editpath.$filename)) { $file['width'][] = $imginfo[0]; $file['height'][] = $imginfo[1]; $file['dimensions'][] = $imginfo[0] + $imginfo[1]; $file['type'][] = $imginfo['mime']; } else { $file['width'][] = 'N/A'; $file['height'][] = 'N/A'; $file['dimensions'][] = 'N/A'; $file['type'][] = returnMIMEType($filename); } } } } closedir($dh); // Assign directory structure to array $editdirs=array(); dirtree($editdirs,$tinybrowser['filetype'][$typenow],$tinybrowser['docroot'],$tinybrowser['path'][$typenow]); // generate alert if files deleted if($deleteqty>0) { $notify['type'][]='success'; $notify['message'][]=sprintf(TB_MSGDELETE, $deleteqty); } // generate alert if files renamed elseif($renameqty>0) { $notify['type'][]='success'; $notify['message'][]=sprintf(TB_MSGRENAME, $renameqty); } // generate alert if files renamed elseif($moveqty>0) { $notify['type'][]='success'; $notify['message'][]=sprintf(TB_MSGMOVE, $moveqty); } // generate alert if images resized elseif($resizeqty>0) { $notify['type'][]='success'; $notify['message'][]=sprintf(TB_MSGRESIZE, $resizeqty); } // generate alert if images rotated elseif($rotateqty>0) { $notify['type'][]='success'; $notify['message'][]=sprintf(TB_MSGROTATE, $rotateqty); } // generate alert if file errors encountered if($errorqty>0) { $notify['type'][]='failure'; $notify['message'][]=sprintf(TB_MSGEDITERR, $errorqty); } // determine sort order $sortorder = ($sorttypenow == 'asc' ? SORT_ASC : SORT_DESC); $num_of_files = (isset($file['name']) ? count($file['name']) : 0); if($num_of_files>0) { // sort files by selected order sortfileorder($sortbynow,$sortorder,$file); } // determine pagination if($tinybrowser['pagination']>0) { $showpagestart = ($showpagenow ? ($_REQUEST['showpage']*$tinybrowser['pagination'])-$tinybrowser['pagination'] : 0); $showpageend = $showpagestart+$tinybrowser['pagination']; if($showpageend>$num_of_files) $showpageend = $num_of_files; } else { $showpagestart = 0; $showpageend = $num_of_files; } ?> TinyBrowser :: <?php echo TB_EDIT; ?> 0) alert($notify); form_open('foldertab',false,'edit.php','?type='.$typenow.$passfeid); ?>
0) { $pagelimit = ceil($num_of_files/$tinybrowser['pagination'])+1; $page = array(); for($i=1;$i<$pagelimit;$i++) { $page[] = array($i,TB_PAGE.' '.$i); } if($i>2) form_select($page,'showpage',SHOW,$showpagenow,true); } ?>
'; if($typenow=='image') echo ''; else echo ''; echo '' .'\n"; } echo "
> > >
' .truncate_text($file['name'][$i],30).''.truncate_text($file['name'][$i],30).''.bytestostring($file['size'][$i],1).''.$file['type'][$i].''; form_hidden_input('actionfile['.$i.']',$file['name'][$i]); switch($actionnow) { case 'delete': echo ''; break; case 'rename': // get file extension $nameparts = explode('.',$file['name'][$i]); $ext = end($nameparts); form_hidden_input('renameext['.$i.']',$ext); form_text_input('renamefile['.$i.']',false,basename($file['name'][$i],$ext),30,120); echo $ext; break; case 'resize': form_text_input('resizefile['.$i.']',false,'',4,4); form_select($selectresize,'resizetype['.$i.']',false,'',false); break; case 'rotate': echo ''.TB_ROTATECW.''.TB_ROTATECCW.''.TB_NONE.''; break; case 'move': echo ''; break; default: // do nothing } echo "
\n".'
'; if($tinybrowser['allowdelete'] || $tinybrowser['allowedit']) { form_hidden_input('sortby',$sortbynow); form_hidden_input('sorttype',$sorttypenow); form_hidden_input('find',$findnow); form_hidden_input('showpage',$showpagenow); form_hidden_input('action',$actionnow); form_submit_button('commit',$actionhead.' '.TB_FILES,'edit'); } ?>