mise a jour pour mtweb.0.9.0
[mw_pages] / app / out / default / tiny_mce / plugins / tinybrowser / upload_process.php
diff --git a/app/out/default/tiny_mce/plugins/tinybrowser/upload_process.php b/app/out/default/tiny_mce/plugins/tinybrowser/upload_process.php
new file mode 100644 (file)
index 0000000..971e37f
--- /dev/null
@@ -0,0 +1,99 @@
+<?php\r
+require_once('config_tinybrowser.php');\r
+require_once('fns_tinybrowser.php');\r
+\r
+// delay script if set\r
+if($tinybrowser['delayprocess']>0) sleep($tinybrowser['delayprocess']);\r
+\r
+// Initialise files array and error vars\r
+$files = array();\r
+$good = 0;\r
+$bad = 0;\r
+$dup = 0;\r
+$total = (isset($_GET['filetotal']) ? $_GET['filetotal'] : 0);\r
+\r
+\r
+// Assign get variables\r
+$folder = $tinybrowser['docroot'].urldecode($_GET['folder']);\r
+$foldernow = urlencode(str_replace($tinybrowser['path'][$_GET['type']],'',urldecode($_GET['folder'])));\r
+$passfeid = (isset($_GET['feid']) ? '&feid='.$_GET['feid'] : '');\r
+\r
+if ($handle = opendir($folder))\r
+       {\r
+       while (false !== ($file = readdir($handle)))\r
+               {\r
+               if ($file != "." && $file != ".." && substr($file,-1)=='_')\r
+                       {\r
+                       //-- File Naming\r
+                       $tmp_filename = $folder.$file;\r
+                       $dest_filename   = $folder.rtrim($file,'_');\r
+        \r
+                       //-- Duplicate Files\r
+                       if(file_exists($dest_filename)) { unlink($tmp_filename); $dup++; continue; }\r
+\r
+                       //-- Bad extensions\r
+                       $nameparts = explode('.',$dest_filename);\r
+                       $ext = end($nameparts);\r
+                       \r
+                       if(!validateExtension($ext, $tinybrowser['prohibited'])) { unlink($tmp_filename); continue; }\r
+        \r
+                       //-- Rename temp file to dest file\r
+                       rename($tmp_filename, $dest_filename);\r
+                       $good++;\r
+                       \r
+                       //-- if image, perform additional processing\r
+                       if($_GET['type']=='image')\r
+                               {\r
+                               //-- Good mime-types\r
+                               $imginfo = getimagesize($dest_filename);\r
+                       if($imginfo === false) { unlink($dest_filename); continue; }\r
+                               $mime = $imginfo['mime'];\r
+\r
+                               // resize image to maximum height and width, if set\r
+                               if($tinybrowser['imageresize']['width'] > 0 || $tinybrowser['imageresize']['height'] > 0)\r
+                                       {\r
+                                       // assign new width and height values, only if they are less than existing image size\r
+                                       $widthnew  = ($tinybrowser['imageresize']['width'] > 0 && $tinybrowser['imageresize']['width'] < $imginfo[0] ? $tinybrowser['imageresize']['width'] : $imginfo[0]);\r
+                                       $heightnew = ($tinybrowser['imageresize']['height'] > 0 && $tinybrowser['imageresize']['height'] < $imginfo[1] ? $tinybrowser['imageresize']['height'] :  $imginfo[1]);\r
+\r
+                                       // only resize if width or height values are different\r
+                                       if($widthnew != $imginfo[0] || $heightnew != $imginfo[1])\r
+                                               {\r
+                                               $im = convert_image($dest_filename,$mime);\r
+                                               resizeimage($im,$widthnew,$heightnew,$dest_filename,$tinybrowser['imagequality'],$mime);\r
+                                               imagedestroy($im);\r
+                                               }\r
+                                       }\r
+\r
+                               // generate thumbnail\r
+                               $thumbimg = $folder.'_thumbs/_'.rtrim($file,'_');\r
+                               if (!file_exists($thumbimg))\r
+                                       {\r
+                                       $im = convert_image($dest_filename,$mime);\r
+                                       resizeimage     ($im,$tinybrowser['thumbsize'],$tinybrowser['thumbsize'],$thumbimg,$tinybrowser['thumbquality'],$mime);\r
+                                       imagedestroy ($im);\r
+                                       }\r
+                               }\r
+\r
+       }\r
+               }\r
+       closedir($handle);\r
+       }\r
+$bad = $total-($good+$dup);\r
+\r
+// Check for problem during upload\r
+if($total>0 && $bad==$total) Header('Location: ./upload.php?type='.$_GET['type'].$passfeid.'&permerror=1&total='.$total);\r
+else Header('Location: ./upload.php?type='.$_GET['type'].$passfeid.'&folder='.$foldernow.'&badfiles='.$bad.'&goodfiles='.$good.'&dupfiles='.$dup);\r
+?>\r
+\r
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\r
+       <head>\r
+       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\r
+       <meta http-equiv="Pragma" content="no-cache" />\r
+               <title>TinyBrowser :: Process Upload</title>\r
+       </head>\r
+       <body>\r
+               <p>Sorry, there was an error processing file uploads.</p>\r
+       </body>\r
+</html>\r