2 require_once('config_tinybrowser.php');
\r
4 if(isset($tinybrowser['language']) && file_exists('langs/'.$tinybrowser['language'].'.php'))
\r
6 require_once('langs/'.$tinybrowser['language'].'.php');
\r
10 require_once('langs/en.php'); // Falls back to English
\r
12 require_once('fns_tinybrowser.php');
\r
14 // Check session, if it exists
\r
15 if(session_id() != '')
\r
17 if(!isset($_SESSION[$tinybrowser['sessioncheck']]))
\r
24 // Assign file operation variables
\r
25 $validtypes = array('image','media','file');
\r
26 $typenow = ((isset($_GET['type']) && in_array($_GET['type'],$validtypes)) ? $_GET['type'] : 'image');
\r
27 $standalone = ((isset($_GET['feid']) && $_GET['feid']!='') ? true : false);
\r
28 $foldernow = str_replace(array('../','..\\','./','.\\'),'',($tinybrowser['allowfolders'] && isset($_REQUEST['folder']) ? urldecode($_REQUEST['folder']) : ''));
\r
32 $passfeid = '&feid='.$_GET['feid'];
\r
33 $rowhlightinit = ' onload="rowHighlight();"';
\r
38 $rowhlightinit = '';
\r
41 // Assign browsing options
\r
42 $sortbynow = (isset($_REQUEST['sortby']) ? $_REQUEST['sortby'] : $tinybrowser['order']['by']);
\r
43 $sorttypenow = (isset($_REQUEST['sorttype']) ? $_REQUEST['sorttype'] : $tinybrowser['order']['type']);
\r
44 $sorttypeflip = ($sorttypenow == 'asc' ? 'desc' : 'asc');
\r
45 $viewtypenow = (isset($_REQUEST['viewtype']) ? $_REQUEST['viewtype'] : $tinybrowser['view']['image']);
\r
46 $findnow = (isset($_POST['find']) && !empty($_POST['find']) ? $_POST['find'] : false);
\r
47 $showpagenow = (isset($_REQUEST['showpage']) ? $_REQUEST['showpage'] : 0);
\r
49 // Assign url pass variables
\r
50 $passfolder = '&folder='.urlencode($foldernow);
\r
51 $passfeid = (isset($_GET['feid']) && $_GET['feid']!='' ? '&feid='.$_GET['feid'] : '');
\r
52 $passviewtype = '&viewtype='.$viewtypenow;
\r
53 $passsortby = '&sortby='.$sortbynow.'&sorttype='.$sorttypenow;
\r
55 // Assign view, thumbnail and link paths
\r
56 $browsepath = $tinybrowser['path'][$typenow].$foldernow;
\r
57 $linkpath = $tinybrowser['link'][$typenow].$foldernow;
\r
58 $thumbpath = $tinybrowser[$tinybrowser['thumbsrc']][$typenow].$foldernow;
\r
60 // Assign sort parameters for column header links
\r
61 $sortbyget = array();
\r
62 $sortbyget['name'] = '&viewtype='.$viewtypenow.'&sortby=name';
\r
63 $sortbyget['size'] = '&viewtype='.$viewtypenow.'&sortby=size';
\r
64 $sortbyget['type'] = '&viewtype='.$viewtypenow.'&sortby=type';
\r
65 $sortbyget['modified'] = '&viewtype='.$viewtypenow.'&sortby=modified';
\r
66 $sortbyget['dimensions'] = '&viewtype='.$viewtypenow.'&sortby=dimensions';
\r
67 $sortbyget[$sortbynow] .= '&sorttype='.$sorttypeflip;
\r
69 // Assign css style for current sort type column
\r
71 $thclass['name'] = '';
\r
72 $thclass['size'] = '';
\r
73 $thclass['type'] = '';
\r
74 $thclass['modified'] = '';
\r
75 $thclass['dimensions'] = '';
\r
76 $thclass[$sortbynow] = ' class="'.$sorttypenow.'"';
\r
78 // Initalise alert array
\r
81 'message' => array()
\r
85 // read folder contents if folder exists
\r
86 if(file_exists($tinybrowser['docroot'].$browsepath))
\r
88 // Read directory contents and populate $file array
\r
89 $dh = opendir($tinybrowser['docroot'].$browsepath);
\r
91 while (($filename = readdir($dh)) !== false)
\r
93 // get file extension
\r
94 $nameparts = explode('.',$filename);
\r
95 $ext = end($nameparts);
\r
97 // filter directories and prohibited file types
\r
98 if($filename != '.' && $filename != '..' && !is_dir($tinybrowser['docroot'].$browsepath.$filename) && !in_array($ext, $tinybrowser['prohibited']) && ($typenow == 'file' || strpos(strtolower($tinybrowser['filetype'][$typenow]),strtolower($ext))))
\r
100 // search file name if search term entered
\r
101 if($findnow) $exists = strpos(strtolower($filename),strtolower($findnow));
\r
103 // assign file details to array, for all files or those that match search
\r
104 if(!$findnow || ($findnow && $exists !== false))
\r
106 $file['name'][] = $filename;
\r
107 $file['sortname'][] = strtolower($filename);
\r
108 $file['modified'][] = filemtime($tinybrowser['docroot'].$browsepath.$filename);
\r
109 $file['size'][] = filesize($tinybrowser['docroot'].$browsepath.$filename);
\r
111 // image specific info or general
\r
112 if($typenow=='image' && $imginfo = getimagesize($tinybrowser['docroot'].$browsepath.$filename))
\r
114 $file['width'][] = $imginfo[0];
\r
115 $file['height'][] = $imginfo[1];
\r
116 $file['dimensions'][] = $imginfo[0] + $imginfo[1];
\r
117 $file['type'][] = $imginfo['mime'];
\r
119 // Check a thumbnail exists
\r
120 if(!file_exists($tinybrowser['docroot'].$browsepath.'_thumbs/')) createfolder($tinybrowser['docroot'].$browsepath.'_thumbs/',$tinybrowser['unixpermissions']);
\r
121 $thumbimg = $tinybrowser['docroot'].$browsepath.'_thumbs/_'.$filename;
\r
122 if (!file_exists($thumbimg))
\r
124 $nothumbimg = $tinybrowser['docroot'].$browsepath.$filename;
\r
125 $mime = getimagesize($nothumbimg);
\r
126 $im = convert_image($nothumbimg,$mime['mime']);
\r
127 resizeimage($im,$tinybrowser['thumbsize'],$tinybrowser['thumbsize'],$thumbimg,$tinybrowser['thumbquality'],$mime['mime']);
\r
134 $file['width'][] = 'N/A';
\r
135 $file['height'][] = 'N/A';
\r
136 $file['dimensions'][] = 'N/A';
\r
137 $file['type'][] = returnMIMEType($filename);
\r
144 // create file upload folder
\r
147 $success = createfolder($tinybrowser['docroot'].$browsepath,$tinybrowser['unixpermissions']);
\r
150 if($typenow=='image') createfolder($tinybrowser['docroot'].$browsepath.'_thumbs/',$tinybrowser['unixpermissions']);
\r
151 $notify['type'][]='success';
\r
152 $notify['message'][]=sprintf(TB_MSGMKDIR, $browsepath);
\r
156 $notify['type'][]='error';
\r
157 $notify['message'][]=sprintf(TB_MSGMKDIRFAIL, $browsepath);
\r
161 // Assign directory structure to array
\r
162 $browsedirs=array();
\r
163 dirtree($browsedirs,$tinybrowser['filetype'][$typenow],$tinybrowser['docroot'],$tinybrowser['path'][$typenow]);
\r
165 // generate alert if new thumbnails created
\r
168 $notify['type'][]='info';
\r
169 $notify['message'][]=sprintf(TB_MSGNEWTHUMBS, $newthumbqty);
\r
173 // determine sort order
\r
174 $sortorder = ($sorttypenow == 'asc' ? SORT_ASC : SORT_DESC);
\r
175 $num_of_files = (isset($file['name']) ? count($file['name']) : 0);
\r
177 if($num_of_files>0)
\r
179 // sort files by selected order
\r
180 sortfileorder($sortbynow,$sortorder,$file);
\r
183 // determine pagination
\r
184 if($tinybrowser['pagination']>0)
\r
186 $showpage_start = ($showpagenow ? ($_REQUEST['showpage']*$tinybrowser['pagination'])-$tinybrowser['pagination'] : 0);
\r
187 $showpage_end = $showpage_start+$tinybrowser['pagination'];
\r
188 if($showpage_end>$num_of_files) $showpage_end = $num_of_files;
\r
192 $showpage_start = 0;
\r
193 $showpage_end = $num_of_files;
\r
196 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
197 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
\r
199 <title>TinyBrowser :: <?php echo TB_BROWSE; ?></title>
\r
200 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
201 <meta http-equiv="Pragma" content="no-cache" />
\r
203 if(!$standalone && $tinybrowser['integration']=='tinymce')
\r
205 ?><script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
\r
206 <link rel="stylesheet" type="text/css" media="all" href="<?php echo $tinybrowser['tinymcecss']; ?>" /><?php
\r
210 ?><link rel="stylesheet" type="text/css" media="all" href="css/stylefull_tinybrowser.css" /><?php
\r
213 <link rel="stylesheet" type="text/css" media="all" href="css/style_tinybrowser.css.php" />
\r
214 <script language="javascript" type="text/javascript" src="js/tinybrowser.js.php?<?php echo substr($passfeid,1); ?>"></script>
\r
216 <body<?php echo $rowhlightinit; ?>>
\r
218 if(count($notify['type'])>0) alert($notify);
\r
219 form_open('foldertab',false,'tinybrowser.php','?type='.$typenow.$passviewtype.$passsortby.$passfeid);
\r
223 <li id="browse_tab" class="current"><span><a href="tinybrowser.php?type=<?php echo $typenow.$passfolder.$passfeid; ?>"><?php echo TB_BROWSE; ?></a></span></li><?php
\r
224 if($tinybrowser['allowupload'])
\r
226 ?><li id="upload_tab"><span><a href="upload.php?type=<?php echo $typenow.$passfolder.$passfeid; ?>"><?php echo TB_UPLOAD; ?></a></span></li><?php
\r
228 if($tinybrowser['allowedit'] || $tinybrowser['allowdelete'])
\r
230 ?><li id="edit_tab"><span><a href="edit.php?type=<?php echo $typenow.$passfolder.$passfeid; ?>"><?php echo TB_EDIT; ?></a></span></li><?php
\r
232 if($tinybrowser['allowfolders'])
\r
234 ?><li id="folders_tab"><span><a href="folders.php?type=<?php echo $typenow.$passfolder.$passfeid; ?>"><?php echo TB_FOLDERS; ?></a></span></li><?php
\r
236 // Display folder select, if multiple exist
\r
237 if(count($browsedirs)>1)
\r
239 ?><li id="folder_tab" class="right"><span><?php
\r
240 form_select($browsedirs,'folder',TB_FOLDERCURR,urlencode($foldernow),true);
\r
241 ?></span></li><?php
\r
247 <div class="panel_wrapper">
\r
248 <div id="general_panel" class="panel currentmod">
\r
250 <legend><?php echo TB_BROWSEFILES; ?></legend>
\r
252 form_open('browse','custom','tinybrowser.php','?type='.$typenow.$passfolder.$passfeid);
\r
254 <div class="pushleft">
\r
257 // Offer view type if file type is image
\r
258 if($typenow=='image')
\r
261 array('thumb',TB_THUMBS),
\r
262 array('detail',TB_DETAILS)
\r
264 form_select($select,'viewtype',TB_VIEW,$viewtypenow,true);
\r
267 // Show page select if pagination is set
\r
268 if($tinybrowser['pagination']>0)
\r
270 $pagelimit = ceil($num_of_files/$tinybrowser['pagination'])+1;
\r
272 for($i=1;$i<$pagelimit;$i++)
\r
274 $page[] = array($i,TB_PAGE.' '.$i);
\r
276 if($i>2) form_select($page,'showpage',TB_SHOW,$showpagenow,true);
\r
278 ?></div><div class="pushright"><?php
\r
280 form_hidden_input('sortby',$sortbynow);
\r
281 form_hidden_input('sorttype',$sorttypenow);
\r
282 form_text_input('find',false,$findnow,25,50);
\r
283 form_submit_button('search',TB_SEARCH,'');
\r
288 // if image show dimensions header
\r
289 if($typenow=='image')
\r
291 $imagehead = '<th><a href="?type='.$typenow.$passfolder.$passfeid.$sortbyget['dimensions'].'"'.$thclass['dimensions'].'>'.TB_DIMENSIONS.'</a></th>';
\r
293 else $imagehead = '';
\r
295 echo '<div class="tabularwrapper"><table class="browse">'
\r
296 .'<tr><th><a href="?type='.$typenow.$passfolder.$passfeid.$sortbyget['name'].'"'.$thclass['name'].'>'.TB_FILENAME.'</a></th>'
\r
297 .'<th><a href="?type='.$typenow.$passfolder.$passfeid.$sortbyget['size'].'"'.$thclass['size'].'>'.TB_SIZE.'</a></th>'
\r
299 .'<th><a href="?type='.$typenow.$passfolder.$passfeid.$sortbyget['type'].'"'.$thclass['type'].'>'.TB_TYPE.'</th>'
\r
300 .'<th><a href="?type='.$typenow.$passfolder.$passfeid.$sortbyget['modified'].'"'.$thclass['modified'].'>'.TB_DATE.'</th></tr>';
\r
302 // show image thumbnails, unless detail view is selected
\r
303 if($typenow=='image' && $viewtypenow != 'detail')
\r
305 echo '</table></div>';
\r
307 for($i=$showpage_start;$i<$showpage_end;$i++)
\r
309 echo '<div class="img-browser"><a href="#" onclick="selectURL(\''.$linkpath.$file['name'][$i].'\');" title="'.TB_FILENAME.': '.$file['name'][$i]
\r
310 .' '.TB_DIMENSIONS.': '.$file['width'][$i].' x '.$file['height'][$i]
\r
311 .' '.TB_DATE.': '.date($tinybrowser['dateformat'],$file['modified'][$i])
\r
312 .' '.TB_TYPE.': '.$file['type'][$i]
\r
313 .' '.TB_SIZE.': '.bytestostring($file['size'][$i],1)
\r
314 .'"><img src="'.$thumbpath.'_thumbs/_'.$file['name'][$i]
\r
315 .'" /><div class="filename">'.$file['name'][$i].'</div></a></div>';
\r
320 for($i=$showpage_start;$i<$showpage_end;$i++)
\r
322 $alt = (IsOdd($i) ? 'r1' : 'r0');
\r
323 echo '<tr class="'.$alt.'">';
\r
324 if($typenow=='image') echo '<td><a class="imghover" href="#" onclick="selectURL(\''.$linkpath.$file['name'][$i].'\');" title="'.$file['name'][$i].'"><img src="'.$thumbpath.'_thumbs/_'.$file['name'][$i].'" alt="" />'.truncate_text($file['name'][$i],30).'</a></td>';
\r
325 else echo '<td><a href="#" onclick="selectURL(\''.$linkpath.$file['name'][$i].'\');" title="'.$file['name'][$i].'">'.truncate_text($file['name'][$i],30).'</a></td>';
\r
326 echo '<td>'.bytestostring($file['size'][$i],1).'</td>';
\r
327 if($typenow=='image') echo '<td>'.$file['width'][$i].' x '.$file['height'][$i].'</td>';
\r
328 echo '<td>'.$file['type'][$i].'</td>'
\r
329 .'<td>'.date($tinybrowser['dateformat'],$file['modified'][$i]).'</td></tr>'."\n";
\r
331 echo '</table></div>';
\r
334 </fieldset></div></div>
\r
335 <form name="passform"><input name = "fileurl" type="hidden" value= "" /></form>
\r