2 require_once('config_tinybrowser.php');
\r
3 require_once('fns_tinybrowser.php');
\r
5 // delay script if set
\r
6 if($tinybrowser['delayprocess']>0) sleep($tinybrowser['delayprocess']);
\r
8 // Initialise files array and error vars
\r
13 $total = (isset($_GET['filetotal']) ? $_GET['filetotal'] : 0);
\r
16 // Assign get variables
\r
17 $folder = $tinybrowser['docroot'].urldecode($_GET['folder']);
\r
18 $foldernow = urlencode(str_replace($tinybrowser['path'][$_GET['type']],'',urldecode($_GET['folder'])));
\r
19 $passfeid = (isset($_GET['feid']) ? '&feid='.$_GET['feid'] : '');
\r
21 if ($handle = opendir($folder))
\r
23 while (false !== ($file = readdir($handle)))
\r
25 if ($file != "." && $file != ".." && substr($file,-1)=='_')
\r
28 $tmp_filename = $folder.$file;
\r
29 $dest_filename = $folder.rtrim($file,'_');
\r
31 //-- Duplicate Files
\r
32 if(file_exists($dest_filename)) { unlink($tmp_filename); $dup++; continue; }
\r
35 $nameparts = explode('.',$dest_filename);
\r
36 $ext = end($nameparts);
\r
38 if(!validateExtension($ext, $tinybrowser['prohibited'])) { unlink($tmp_filename); continue; }
\r
40 //-- Rename temp file to dest file
\r
41 rename($tmp_filename, $dest_filename);
\r
44 //-- if image, perform additional processing
\r
45 if($_GET['type']=='image')
\r
47 //-- Good mime-types
\r
48 $imginfo = getimagesize($dest_filename);
\r
49 if($imginfo === false) { unlink($dest_filename); continue; }
\r
50 $mime = $imginfo['mime'];
\r
52 // resize image to maximum height and width, if set
\r
53 if($tinybrowser['imageresize']['width'] > 0 || $tinybrowser['imageresize']['height'] > 0)
\r
55 // assign new width and height values, only if they are less than existing image size
\r
56 $widthnew = ($tinybrowser['imageresize']['width'] > 0 && $tinybrowser['imageresize']['width'] < $imginfo[0] ? $tinybrowser['imageresize']['width'] : $imginfo[0]);
\r
57 $heightnew = ($tinybrowser['imageresize']['height'] > 0 && $tinybrowser['imageresize']['height'] < $imginfo[1] ? $tinybrowser['imageresize']['height'] : $imginfo[1]);
\r
59 // only resize if width or height values are different
\r
60 if($widthnew != $imginfo[0] || $heightnew != $imginfo[1])
\r
62 $im = convert_image($dest_filename,$mime);
\r
63 resizeimage($im,$widthnew,$heightnew,$dest_filename,$tinybrowser['imagequality'],$mime);
\r
68 // generate thumbnail
\r
69 $thumbimg = $folder.'_thumbs/_'.rtrim($file,'_');
\r
70 if (!file_exists($thumbimg))
\r
72 $im = convert_image($dest_filename,$mime);
\r
73 resizeimage ($im,$tinybrowser['thumbsize'],$tinybrowser['thumbsize'],$thumbimg,$tinybrowser['thumbquality'],$mime);
\r
82 $bad = $total-($good+$dup);
\r
84 // Check for problem during upload
\r
85 if($total>0 && $bad==$total) Header('Location: ./upload.php?type='.$_GET['type'].$passfeid.'&permerror=1&total='.$total);
\r
86 else Header('Location: ./upload.php?type='.$_GET['type'].$passfeid.'&folder='.$foldernow.'&badfiles='.$bad.'&goodfiles='.$good.'&dupfiles='.$dup);
\r
89 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
90 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
\r
92 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
93 <meta http-equiv="Pragma" content="no-cache" />
\r
94 <title>TinyBrowser :: Process Upload</title>
\r
97 <p>Sorry, there was an error processing file uploads.</p>
\r