array(), 'message' => array() ); $newthumbqty = 0; // read folder contents if folder exists if(file_exists($tinybrowser['docroot'].$browsepath)) { // Read directory contents and populate $file array $dh = opendir($tinybrowser['docroot'].$browsepath); $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'].$browsepath.$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'].$browsepath.$filename); $file['size'][] = filesize($tinybrowser['docroot'].$browsepath.$filename); // image specific info or general if($typenow=='image' && $imginfo = getimagesize($tinybrowser['docroot'].$browsepath.$filename)) { $file['width'][] = $imginfo[0]; $file['height'][] = $imginfo[1]; $file['dimensions'][] = $imginfo[0] + $imginfo[1]; $file['type'][] = $imginfo['mime']; // Check a thumbnail exists if(!file_exists($tinybrowser['docroot'].$browsepath.'_thumbs/')) createfolder($tinybrowser['docroot'].$browsepath.'_thumbs/',$tinybrowser['unixpermissions']); $thumbimg = $tinybrowser['docroot'].$browsepath.'_thumbs/_'.$filename; if (!file_exists($thumbimg)) { $nothumbimg = $tinybrowser['docroot'].$browsepath.$filename; $mime = getimagesize($nothumbimg); $im = convert_image($nothumbimg,$mime['mime']); resizeimage($im,$tinybrowser['thumbsize'],$tinybrowser['thumbsize'],$thumbimg,$tinybrowser['thumbquality'],$mime['mime']); imagedestroy($im); $newthumbqty++; } } else { $file['width'][] = 'N/A'; $file['height'][] = 'N/A'; $file['dimensions'][] = 'N/A'; $file['type'][] = returnMIMEType($filename); } } } } closedir($dh); } // create file upload folder else { $success = createfolder($tinybrowser['docroot'].$browsepath,$tinybrowser['unixpermissions']); if($success) { if($typenow=='image') createfolder($tinybrowser['docroot'].$browsepath.'_thumbs/',$tinybrowser['unixpermissions']); $notify['type'][]='success'; $notify['message'][]=sprintf(TB_MSGMKDIR, $browsepath); } else { $notify['type'][]='error'; $notify['message'][]=sprintf(TB_MSGMKDIRFAIL, $browsepath); } } // Assign directory structure to array $browsedirs=array(); dirtree($browsedirs,$tinybrowser['filetype'][$typenow],$tinybrowser['docroot'],$tinybrowser['path'][$typenow]); // generate alert if new thumbnails created if($newthumbqty>0) { $notify['type'][]='info'; $notify['message'][]=sprintf(TB_MSGNEWTHUMBS, $newthumbqty); } // 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) { $showpage_start = ($showpagenow ? ($_REQUEST['showpage']*$tinybrowser['pagination'])-$tinybrowser['pagination'] : 0); $showpage_end = $showpage_start+$tinybrowser['pagination']; if($showpage_end>$num_of_files) $showpage_end = $num_of_files; } else { $showpage_start = 0; $showpage_end = $num_of_files; } ?>