X-Git-Url: http://git.dj3c1t.com/index.cgi?a=blobdiff_plain;f=mw%2Flibs%2Ftiny_mce%2Fplugins%2Ftinybrowser%2Fupload_process.php;fp=mw%2Flibs%2Ftiny_mce%2Fplugins%2Ftinybrowser%2Fupload_process.php;h=971e37fc8c0fe3fa61e6d920758c4a61bcb585f3;hb=36ed114046cbe3d72a3589230e9f306a54fcc79d;hp=0000000000000000000000000000000000000000;hpb=281c96e95451269f2614684b8de5be25862c8374;p=mtweb diff --git a/mw/libs/tiny_mce/plugins/tinybrowser/upload_process.php b/mw/libs/tiny_mce/plugins/tinybrowser/upload_process.php new file mode 100644 index 0000000..971e37f --- /dev/null +++ b/mw/libs/tiny_mce/plugins/tinybrowser/upload_process.php @@ -0,0 +1,99 @@ +0) sleep($tinybrowser['delayprocess']); + +// Initialise files array and error vars +$files = array(); +$good = 0; +$bad = 0; +$dup = 0; +$total = (isset($_GET['filetotal']) ? $_GET['filetotal'] : 0); + + +// Assign get variables +$folder = $tinybrowser['docroot'].urldecode($_GET['folder']); +$foldernow = urlencode(str_replace($tinybrowser['path'][$_GET['type']],'',urldecode($_GET['folder']))); +$passfeid = (isset($_GET['feid']) ? '&feid='.$_GET['feid'] : ''); + +if ($handle = opendir($folder)) + { + while (false !== ($file = readdir($handle))) + { + if ($file != "." && $file != ".." && substr($file,-1)=='_') + { + //-- File Naming + $tmp_filename = $folder.$file; + $dest_filename = $folder.rtrim($file,'_'); + + //-- Duplicate Files + if(file_exists($dest_filename)) { unlink($tmp_filename); $dup++; continue; } + + //-- Bad extensions + $nameparts = explode('.',$dest_filename); + $ext = end($nameparts); + + if(!validateExtension($ext, $tinybrowser['prohibited'])) { unlink($tmp_filename); continue; } + + //-- Rename temp file to dest file + rename($tmp_filename, $dest_filename); + $good++; + + //-- if image, perform additional processing + if($_GET['type']=='image') + { + //-- Good mime-types + $imginfo = getimagesize($dest_filename); + if($imginfo === false) { unlink($dest_filename); continue; } + $mime = $imginfo['mime']; + + // resize image to maximum height and width, if set + if($tinybrowser['imageresize']['width'] > 0 || $tinybrowser['imageresize']['height'] > 0) + { + // assign new width and height values, only if they are less than existing image size + $widthnew = ($tinybrowser['imageresize']['width'] > 0 && $tinybrowser['imageresize']['width'] < $imginfo[0] ? $tinybrowser['imageresize']['width'] : $imginfo[0]); + $heightnew = ($tinybrowser['imageresize']['height'] > 0 && $tinybrowser['imageresize']['height'] < $imginfo[1] ? $tinybrowser['imageresize']['height'] : $imginfo[1]); + + // only resize if width or height values are different + if($widthnew != $imginfo[0] || $heightnew != $imginfo[1]) + { + $im = convert_image($dest_filename,$mime); + resizeimage($im,$widthnew,$heightnew,$dest_filename,$tinybrowser['imagequality'],$mime); + imagedestroy($im); + } + } + + // generate thumbnail + $thumbimg = $folder.'_thumbs/_'.rtrim($file,'_'); + if (!file_exists($thumbimg)) + { + $im = convert_image($dest_filename,$mime); + resizeimage ($im,$tinybrowser['thumbsize'],$tinybrowser['thumbsize'],$thumbimg,$tinybrowser['thumbquality'],$mime); + imagedestroy ($im); + } + } + + } + } + closedir($handle); + } +$bad = $total-($good+$dup); + +// Check for problem during upload +if($total>0 && $bad==$total) Header('Location: ./upload.php?type='.$_GET['type'].$passfeid.'&permerror=1&total='.$total); +else Header('Location: ./upload.php?type='.$_GET['type'].$passfeid.'&folder='.$foldernow.'&badfiles='.$bad.'&goodfiles='.$good.'&dupfiles='.$dup); +?> + + + + + + + TinyBrowser :: Process Upload + + +

Sorry, there was an error processing file uploads.

+ +