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 if(!$tinybrowser['allowedit'] && !$tinybrowser['allowdelete'])
\r
30 // Assign file operation variables
\r
31 $validtypes = array('image','media','file');
\r
32 $typenow = ((isset($_GET['type']) && in_array($_GET['type'],$validtypes)) ? $_GET['type'] : 'image');
\r
33 $foldernow = str_replace(array('../','..\\','./','.\\'),'',($tinybrowser['allowfolders'] && isset($_REQUEST['folder']) ? urldecode($_REQUEST['folder']) : ''));
\r
34 $destfolder = (isset($_POST['destination']) ? $tinybrowser['path'][$typenow].urldecode($_POST['destination']) : '');
\r
35 $destfoldernow = (isset($_POST['destination']) ? urldecode($_POST['destination']) : $foldernow);
\r
37 // Assign edit and thumbnail path
\r
38 $editpath = $tinybrowser['path'][$typenow].$foldernow;
\r
39 $thumbpath = $tinybrowser[$tinybrowser['thumbsrc']][$typenow].$foldernow;
\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 = 'detail';
\r
46 $findnow = (isset($_REQUEST['find']) && !empty($_REQUEST['find']) ? $_REQUEST['find'] : false);
\r
47 $actionnow = (isset($_REQUEST['action']) ? $_REQUEST['action'] : $tinybrowser['defaultaction'] );
\r
48 $showpagenow = (isset($_REQUEST['showpage']) ? $_REQUEST['showpage'] : 0);
\r
50 // Assign url pass variables
\r
51 $passfolder = '&folder='.urlencode($foldernow);
\r
52 $passfeid = (isset($_GET['feid']) && $_GET['feid']!='' ? '&feid='.$_GET['feid'] : '');
\r
53 $passaction = '&action='.$actionnow;
\r
54 $passsortby = '&sortby='.$sortbynow.'&sorttype='.$sorttypenow;
\r
56 // Assign sort parameters for column header links
\r
57 $sortbyget = array();
\r
58 $sortbyget['name'] = '&sortby=name';
\r
59 $sortbyget['size'] = '&sortby=size';
\r
60 $sortbyget['type'] = '&sortby=type';
\r
61 $sortbyget['modified'] = '&sortby=modified';
\r
62 $sortbyget['dimensions'] = '&sortby=dimensions';
\r
63 $sortbyget[$sortbynow] .= '&sorttype='.$sorttypeflip;
\r
65 // Assign css style for current sort type column
\r
67 $thclass['name'] = '';
\r
68 $thclass['size'] = '';
\r
69 $thclass['type'] = '';
\r
70 $thclass['modified'] = '';
\r
71 $thclass['dimensions'] = '';
\r
72 $thclass[$sortbynow] = ' class="'.$sorttypenow.'"';
\r
74 // Initalise alert array
\r
77 'message' => array()
\r
86 // Set when rotating images to force thumbnail refresh
\r
89 // Delete any checked files
\r
90 if(isset($_POST['deletefile']))
\r
92 foreach($_POST['deletefile'] as $delthis => $val)
\r
94 $delthisfile = $tinybrowser['docroot'].$editpath.$_POST['actionfile'][$delthis];
\r
95 if (file_exists($delthisfile) && unlink($delthisfile)) $deleteqty++; else $errorqty++;
\r
96 if($typenow=='image')
\r
98 $delthisthumb = $tinybrowser['docroot'].$editpath.'_thumbs/_'.$_POST['actionfile'][$delthis];
\r
99 if (file_exists($delthisthumb)) unlink($delthisthumb);
\r
104 // Rename any files with changed name
\r
105 if(isset($_POST['renamefile']))
\r
107 foreach($_POST['renamefile'] as $namethis => $newname)
\r
109 if($_POST['actionfile'][$namethis] != $newname.$_POST['renameext'][$namethis])
\r
111 $namethisfilefrom = $tinybrowser['docroot'].$editpath.$_POST['actionfile'][$namethis];
\r
112 $namethisfileto = $tinybrowser['docroot'].$editpath.clean_filename($newname.$_POST['renameext'][$namethis]);
\r
113 if (file_exists($namethisfilefrom) && rename($namethisfilefrom,$namethisfileto)) $renameqty++; else $errorqty++;
\r
114 if($typenow=='image')
\r
116 $namethisthumbfrom = $tinybrowser['docroot'].$editpath.'_thumbs/_'.$_POST['actionfile'][$namethis];
\r
117 $namethisthumbto = $tinybrowser['docroot'].$editpath.'_thumbs/_'.clean_filename($newname.$_POST['renameext'][$namethis]);
\r
118 if (file_exists($namethisthumbfrom)) rename($namethisthumbfrom,$namethisthumbto);
\r
124 // Move any checked files
\r
125 if(isset($_POST['movefile']))
\r
127 foreach($_POST['movefile'] as $movethis => $val)
\r
129 $movethisfile = $tinybrowser['docroot'].$editpath.$_POST['actionfile'][$movethis];
\r
130 $movefiledest = $tinybrowser['docroot'].$destfolder.$_POST['actionfile'][$movethis];
\r
131 if (!file_exists($movefiledest) && file_exists($movethisfile) && copy($movethisfile,$movefiledest))
\r
134 unlink($movethisfile);
\r
135 if($typenow=='image')
\r
137 $movethisthumb = $tinybrowser['docroot'].$editpath.'_thumbs/_'.$_POST['actionfile'][$movethis];
\r
138 $movethumbdest = $tinybrowser['docroot'].$destfolder.'_thumbs/_'.$_POST['actionfile'][$movethis];
\r
139 if (file_exists($movethisthumb) && copy($movethisthumb,$movethumbdest)) unlink($movethisthumb);
\r
146 // Resize any files with new size
\r
147 if(isset($_POST['resizefile']))
\r
149 foreach($_POST['resizefile'] as $sizethis => $newsize)
\r
151 $newsize = intval($newsize);
\r
154 // detect silly sizes
\r
155 if($newsize > $tinybrowser['thumbsize'])
\r
158 $targetimg = $tinybrowser['docroot'].$editpath.$_POST['actionfile'][$sizethis];
\r
159 if (file_exists($targetimg))
\r
161 $mime = getimagesize($targetimg);
\r
162 if($_POST['resizetype'][$sizethis]=='width')
\r
172 $im = convert_image($targetimg,$mime['mime']);
\r
173 resizeimage($im,$rw,$rh,$targetimg,$tinybrowser['imagequality'],$mime['mime']);
\r
184 // Rotate any selected files
\r
185 if(isset($_POST['rotatefile']))
\r
187 $imagerefresh = '?refresh='.uniqid('');
\r
188 foreach($_POST['rotatefile'] as $rotatethis => $direction)
\r
190 if($direction != 'none')
\r
192 $targetimg = $tinybrowser['docroot'].$editpath.$_POST['actionfile'][$rotatethis];
\r
193 if (file_exists($targetimg))
\r
196 if($direction == 'clock') $degree=270; else $degree=90;
\r
197 $mime = getimagesize($targetimg);
\r
198 $im = convert_image($targetimg,$mime['mime']);
\r
200 // additional processing for png / gif transparencies (credit to Dirk Bohl)
\r
201 if($mime['mime'] == 'image/x-png' || $mime['mime'] == 'image/png')
\r
203 imagealphablending($newim, false);
\r
204 imagesavealpha($newim, true);
\r
206 elseif($mime['mime'] == 'image/gif')
\r
208 $originaltransparentcolor = imagecolortransparent( $im );
\r
209 if($originaltransparentcolor >= 0 && $originaltransparentcolor < imagecolorstotal( $im ))
\r
211 $transparentcolor = imagecolorsforindex( $im, $originaltransparentcolor );
\r
212 $newtransparentcolor = imagecolorallocate($newim,$transparentcolor['red'],$transparentcolor['green'],$transparentcolor['blue']);
\r
213 imagefill( $newim, 0, 0, $newtransparentcolor );
\r
214 imagecolortransparent( $newim, $newtransparentcolor );
\r
217 $newim = imagerotate($im, $degree, 0);
\r
220 if($mime['mime'] == 'image/pjpeg' || $mime['mime'] == 'image/jpeg')
\r
221 imagejpeg ($newim,$targetimg,$tinybrowser['imagequality']);
\r
222 elseif($mime['mime'] == 'image/x-png' || $mime['mime'] == 'image/png')
\r
223 imagepng ($newim,$targetimg,substr($tinybrowser['imagequality'],0,1));
\r
224 elseif($mime['mime'] == 'image/gif')
\r
225 imagegif ($newim,$targetimg);
\r
226 imagedestroy($newim);
\r
229 // delete and recreate thumbnail image
\r
230 $targetthumb = $tinybrowser['docroot'].$editpath.'_thumbs/_'.$_POST['actionfile'][$rotatethis];
\r
231 if (file_exists($targetthumb)) unlink($targetthumb);
\r
232 $mime = getimagesize($targetimg);
\r
233 $im = convert_image($targetimg,$mime['mime']);
\r
234 resizeimage($im,$tinybrowser['thumbsize'],$tinybrowser['thumbsize'],$targetthumb,$tinybrowser['thumbquality'],$mime['mime']);
\r
242 // Read directory contents and populate $file array
\r
243 $dh = opendir($tinybrowser['docroot'].$editpath);
\r
245 while (($filename = readdir($dh)) !== false)
\r
247 // get file extension
\r
248 $nameparts = explode('.',$filename);
\r
249 $ext = end($nameparts);
\r
251 // filter directories and prohibited file types
\r
252 if($filename != '.' && $filename != '..' && !is_dir($tinybrowser['docroot'].$editpath.$filename) && !in_array($ext, $tinybrowser['prohibited']) && ($typenow == 'file' || strpos(strtolower($tinybrowser['filetype'][$typenow]),strtolower($ext))))
\r
254 // search file name if search term entered
\r
255 if($findnow) $exists = strpos(strtolower($filename),strtolower($findnow));
\r
257 // assign file details to array, for all files or those that match search
\r
258 if(!$findnow || ($findnow && $exists !== false))
\r
260 $file['name'][] = $filename;
\r
261 $file['sortname'][] = strtolower($filename);
\r
262 $file['modified'][] = filemtime($tinybrowser['docroot'].$editpath.$filename);
\r
263 $file['size'][] = filesize($tinybrowser['docroot'].$editpath.$filename);
\r
265 // image specific info or general
\r
266 if($typenow=='image' && $imginfo = getimagesize($tinybrowser['docroot'].$editpath.$filename))
\r
268 $file['width'][] = $imginfo[0];
\r
269 $file['height'][] = $imginfo[1];
\r
270 $file['dimensions'][] = $imginfo[0] + $imginfo[1];
\r
271 $file['type'][] = $imginfo['mime'];
\r
275 $file['width'][] = 'N/A';
\r
276 $file['height'][] = 'N/A';
\r
277 $file['dimensions'][] = 'N/A';
\r
278 $file['type'][] = returnMIMEType($filename);
\r
285 // Assign directory structure to array
\r
287 dirtree($editdirs,$tinybrowser['filetype'][$typenow],$tinybrowser['docroot'],$tinybrowser['path'][$typenow]);
\r
289 // generate alert if files deleted
\r
292 $notify['type'][]='success';
\r
293 $notify['message'][]=sprintf(TB_MSGDELETE, $deleteqty);
\r
295 // generate alert if files renamed
\r
296 elseif($renameqty>0)
\r
298 $notify['type'][]='success';
\r
299 $notify['message'][]=sprintf(TB_MSGRENAME, $renameqty);
\r
301 // generate alert if files renamed
\r
304 $notify['type'][]='success';
\r
305 $notify['message'][]=sprintf(TB_MSGMOVE, $moveqty);
\r
307 // generate alert if images resized
\r
308 elseif($resizeqty>0)
\r
310 $notify['type'][]='success';
\r
311 $notify['message'][]=sprintf(TB_MSGRESIZE, $resizeqty);
\r
313 // generate alert if images rotated
\r
314 elseif($rotateqty>0)
\r
316 $notify['type'][]='success';
\r
317 $notify['message'][]=sprintf(TB_MSGROTATE, $rotateqty);
\r
320 // generate alert if file errors encountered
\r
323 $notify['type'][]='failure';
\r
324 $notify['message'][]=sprintf(TB_MSGEDITERR, $errorqty);
\r
327 // determine sort order
\r
328 $sortorder = ($sorttypenow == 'asc' ? SORT_ASC : SORT_DESC);
\r
329 $num_of_files = (isset($file['name']) ? count($file['name']) : 0);
\r
331 if($num_of_files>0)
\r
333 // sort files by selected order
\r
334 sortfileorder($sortbynow,$sortorder,$file);
\r
337 // determine pagination
\r
338 if($tinybrowser['pagination']>0)
\r
340 $showpagestart = ($showpagenow ? ($_REQUEST['showpage']*$tinybrowser['pagination'])-$tinybrowser['pagination'] : 0);
\r
341 $showpageend = $showpagestart+$tinybrowser['pagination'];
\r
342 if($showpageend>$num_of_files) $showpageend = $num_of_files;
\r
346 $showpagestart = 0;
\r
347 $showpageend = $num_of_files;
\r
350 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
351 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
\r
353 <title>TinyBrowser :: <?php echo TB_EDIT; ?></title>
\r
354 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
355 <meta http-equiv="Pragma" content="no-cache" />
\r
357 if(empty($passfeid) && $tinybrowser['integration']=='tinymce')
\r
359 ?><link rel="stylesheet" type="text/css" media="all" href="<?php echo $tinybrowser['tinymcecss']; ?>" /><?php
\r
363 ?><link rel="stylesheet" type="text/css" media="all" href="css/stylefull_tinybrowser.css" /><?php
\r
366 <link rel="stylesheet" type="text/css" media="all" href="css/style_tinybrowser.css.php" />
\r
367 <script language="javascript" type="text/javascript" src="js/tinybrowser.js.php"></script>
\r
369 <body onload="rowHighlight();">
\r
371 if(count($notify['type'])>0) alert($notify);
\r
372 form_open('foldertab',false,'edit.php','?type='.$typenow.$passfeid);
\r
376 <li id="browse_tab"><span><a href="tinybrowser.php?type=<?php echo $typenow.$passfolder.$passfeid ; ?>"><?php echo TB_BROWSE; ?></a></span></li>
\r
378 if($tinybrowser['allowupload'])
\r
380 ?><li id="upload_tab"><span><a href="upload.php?type=<?php echo $typenow.$passfolder.$passfeid ; ?>"><?php echo TB_UPLOAD; ?></a></span></li>
\r
383 <li id="edit_tab" class="current"><span><a href="edit.php?type=<?php echo $typenow.$passfolder.$passfeid ; ?>"><?php echo TB_EDIT; ?></a></span></li>
\r
385 if($tinybrowser['allowfolders'])
\r
387 ?><li id="folders_tab"><span><a href="folders.php?type=<?php echo $typenow.$passfolder.$passfeid; ?>"><?php echo TB_FOLDERS; ?></a></span></li><?php
\r
389 // Display folder select, if multiple exist
\r
390 if(count($editdirs)>1)
\r
392 ?><li id="folder_tab" class="right"><span><?php
\r
393 form_select($editdirs,'folder',TB_FOLDERCURR,urlencode($foldernow),true);
\r
394 form_hidden_input('sortby',$sortbynow);
\r
395 form_hidden_input('sorttype',$sorttypenow);
\r
396 form_hidden_input('showpage',$showpagenow);
\r
397 form_hidden_input('action',$actionnow);
\r
398 ?></span></li><?php
\r
404 <div class="panel_wrapper">
\r
405 <div id="general_panel" class="panel currentmod">
\r
407 <legend><?php echo TB_EDITFILES; ?></legend>
\r
409 form_open('edit','custom','edit.php','?type='.$typenow.$passfolder.$passfeid);
\r
411 <div class="pushleft">
\r
414 // Assign edit actions based on file type and permissions
\r
416 if($tinybrowser['allowdelete']) $select[] = array('delete',TB_DELETE);
\r
417 if($tinybrowser['allowedit']) $select[] = array('rename',TB_RENAME);
\r
418 if($tinybrowser['allowfolders']) $select[] = array('move',TB_MOVE);
\r
419 if($typenow=='image' && $tinybrowser['allowedit'])
\r
421 $select[] = array('resize',TB_RESIZE);
\r
422 $select[] = array('rotate',TB_ROTATE);
\r
424 form_select($select,'action',TB_ACTION,$actionnow,true);
\r
426 // Show page select if pagination is set
\r
427 if($tinybrowser['pagination']>0)
\r
429 $pagelimit = ceil($num_of_files/$tinybrowser['pagination'])+1;
\r
431 for($i=1;$i<$pagelimit;$i++)
\r
433 $page[] = array($i,TB_PAGE.' '.$i);
\r
435 if($i>2) form_select($page,'showpage',SHOW,$showpagenow,true);
\r
437 ?></div><div class="pushright"><?php
\r
439 form_hidden_input('sortby',$sortbynow);
\r
440 form_hidden_input('sorttype',$sorttypenow);
\r
441 form_text_input('find',false,$findnow,25,50);
\r
442 form_submit_button('search',TB_SEARCH,'');
\r
445 form_open('actionform','custom','edit.php','?type='.$typenow.$passfolder.$passfeid);
\r
447 if($actionnow=='move')
\r
448 { ?><div class="pushleft"><?php
\r
449 form_select($editdirs,'destination',TB_FOLDERDEST,urlencode($destfoldernow),false);
\r
453 if($typenow=='image')
\r
455 $selectresize = array(
\r
456 array('width',TB_WIDTH),
\r
457 array('height',TB_HEIGHT)
\r
461 switch($actionnow)
\r
464 $actionhead = TB_DELETE;
\r
467 $actionhead = TB_RENAME;
\r
470 $actionhead = TB_RESIZE;
\r
473 $actionhead = TB_ROTATE;
\r
476 $actionhead = TB_MOVE;
\r
481 ?><div class="tabularwrapper"><table class="browse"><tr>
\r
482 <th><a href="?type=<?php echo $typenow.$passaction.$passfolder.$passfeid.$sortbyget['name']; ?>"<?php echo $thclass['name']; ?>><?php echo TB_FILENAME; ?></a></th>
\r
483 <th><a href="?type=<?php echo $typenow.$passaction.$passfolder.$passfeid.$sortbyget['size']; ?>"<?php echo $thclass['size']; ?>><?php echo TB_SIZE; ?></a></th>
\r
484 <th><a href="?type=<?php echo $typenow.$passaction.$passfolder.$passfeid.$sortbyget['type']; ?>"<?php echo $thclass['type']; ?>><?php echo TB_TYPE; ?></th>
\r
485 <th class="nohvr"><?php echo $actionhead; ?></th></tr>
\r
488 for($i=$showpagestart;$i<$showpageend;$i++)
\r
490 $alt = (IsOdd($i) ? 'r1' : 'r0');
\r
491 echo '<tr class="'.$alt.'">';
\r
492 if($typenow=='image') echo '<td><a class="imghover" href="#" onclick="return false;" title="'.$file['name'][$i].' '.TB_DIMENSIONS.': '.$file['width'][$i].' x '.$file['height'][$i].' '.TB_DATE.': '.date($tinybrowser['dateformat'],$file['modified'][$i]).'"><img src="'.$thumbpath.'_thumbs/_'.$file['name'][$i].$imagerefresh.'" alt="" />' .truncate_text($file['name'][$i],30).'</a></td>';
\r
493 else echo '<td title="'.$file['name'][$i].' '.TB_DATE.': '.date($tinybrowser['dateformat'],$file['modified'][$i]).'">'.truncate_text($file['name'][$i],30).'</td>';
\r
494 echo '<td>'.bytestostring($file['size'][$i],1).'</td><td>'.$file['type'][$i].'</td>'
\r
496 form_hidden_input('actionfile['.$i.']',$file['name'][$i]);
\r
497 switch($actionnow)
\r
500 echo '<input class="del" type="checkbox" name="deletefile['.$i.']" value="1" />';
\r
503 // get file extension
\r
504 $nameparts = explode('.',$file['name'][$i]);
\r
505 $ext = end($nameparts);
\r
506 form_hidden_input('renameext['.$i.']',$ext);
\r
507 form_text_input('renamefile['.$i.']',false,basename($file['name'][$i],$ext),30,120); echo $ext;
\r
510 form_text_input('resizefile['.$i.']',false,'',4,4); form_select($selectresize,'resizetype['.$i.']',false,'',false);
\r
513 echo '<img src="img/rotate_c.gif" alt="'.TB_ROTATECW.'" /><input class="rad" type="radio" name="rotatefile['.$i.']" value="clock"><img src="img/rotate_ac.gif" alt="'.TB_ROTATECCW.'" /><input class="rad" type="radio" name="rotatefile['.$i.']" value="anticlock">'.TB_NONE.'<input class="rad" type="radio" name="rotatefile['.$i.']" value="none" checked>';
\r
516 echo '<input class="del" type="checkbox" name="movefile['.$i.']" value="1" />';
\r
521 echo "</td></tr>\n";
\r
524 echo "</table></div>\n".'<div class="pushright">';
\r
525 if($tinybrowser['allowdelete'] || $tinybrowser['allowedit'])
\r
527 form_hidden_input('sortby',$sortbynow);
\r
528 form_hidden_input('sorttype',$sorttypenow);
\r
529 form_hidden_input('find',$findnow);
\r
530 form_hidden_input('showpage',$showpagenow);
\r
531 form_hidden_input('action',$actionnow);
\r
532 form_submit_button('commit',$actionhead.' '.TB_FILES,'edit');
\r
535 </div></fieldset></div></div>
\r