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['allowfolders'])
\r
30 // Assign request / get / post 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 $dirpath = $tinybrowser['path'][$typenow];
\r
35 $passfolder = '&folder='.urlencode($foldernow);
\r
36 $passfeid = (isset($_GET['feid']) && $_GET['feid']!='' ? '&feid='.$_GET['feid'] : '');
\r
40 // Assign browsing options
\r
41 $actionnow = (isset($_POST['editaction']) ? $_POST['editaction'] : 'create' );
\r
43 // Initalise alert array
\r
46 'message' => array()
\r
53 // Create any child folders with entered name
\r
54 if(isset($_POST['createfolder']))
\r
56 foreach($_POST['createfolder'] as $parent => $newfolder)
\r
58 if($newfolder != '')
\r
60 $createthisfolder = $tinybrowser['docroot'].$dirpath.urldecode($_POST['actionfolder'][$parent]).clean_filename($newfolder);
\r
61 if (!file_exists($createthisfolder) && createfolder($createthisfolder,$tinybrowser['unixpermissions'])) $createqty++; else $errorqty++;
\r
62 if($typenow=='image')
\r
64 createfolder($createthisfolder.'/_thumbs/',$tinybrowser['unixpermissions']);
\r
70 // Delete any checked folders
\r
71 if(isset($_POST['deletefolder']))
\r
73 foreach($_POST['deletefolder'] as $delthis => $val)
\r
75 if($typenow=='image')
\r
77 $delthisthumbdir = $tinybrowser['docroot'].$dirpath.urldecode($_POST['actionfolder'][$delthis]).'_thumbs/';
\r
78 if (is_dir($delthisthumbdir)) rmdir($delthisthumbdir);
\r
80 $delthisdir = $tinybrowser['docroot'].$dirpath.urldecode($_POST['actionfolder'][$delthis]);
\r
81 if (is_dir($delthisdir) && rmdir($delthisdir)) $deleteqty++; else $errorqty++;
\r
82 if($foldernow==urldecode($_POST['actionfolder'][$delthis]))
\r
91 // Rename any folders with changed name
\r
92 if(isset($_POST['renamefolder']))
\r
94 foreach($_POST['renamefolder'] as $namethis => $newname)
\r
96 $urlparts = explode('/',rtrim(urldecode($_POST['actionfolder'][$namethis]),'/'));
\r
97 if(array_pop($urlparts) != $newname)
\r
99 $namethisfolderfrom = $tinybrowser['docroot'].$dirpath.urldecode($_POST['actionfolder'][$namethis]);
\r
100 $renameurl = implode('/',$urlparts).'/'.clean_filename($newname).'/';
\r
101 $namethisfolderto = $tinybrowser['docroot'].$dirpath.$renameurl;
\r
102 if (is_dir($namethisfolderfrom) && rename($namethisfolderfrom,$namethisfolderto)) $renameqty++; else $errorqty++;
\r
103 if($foldernow==urldecode($_POST['actionfolder'][$namethis]))
\r
105 $foldernow = ltrim($renameurl,'/');
\r
106 $passfolder = '&folder='.urlencode(ltrim($renameurl,'/'));
\r
112 // Assign directory structure to array
\r
114 dirtree($dirs,$tinybrowser['filetype'][$typenow],$tinybrowser['docroot'],$tinybrowser['path'][$typenow]);
\r
116 // generate alert if folders deleted
\r
119 $notify['type'][]='success';
\r
120 $notify['message'][]=sprintf(TB_MSGCREATE, $createqty);
\r
122 // generate alert if folders deleted
\r
123 elseif($deleteqty>0)
\r
125 $notify['type'][]='success';
\r
126 $notify['message'][]=sprintf(TB_MSGDELETE, $deleteqty);
\r
128 // generate alert if folders renamed
\r
129 elseif($renameqty>0)
\r
131 $notify['type'][]='success';
\r
132 $notify['message'][]=sprintf(TB_MSGRENAME, $renameqty);
\r
135 // generate alert if file errors encountered
\r
138 $notify['type'][]='failure';
\r
139 $notify['message'][]=sprintf(TB_MSGEDITERR, $errorqty);
\r
143 $num_of_folders = (isset($dirs) ? count($dirs) : 0);
\r
146 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
\r
147 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
\r
149 <title>TinyBrowser :: <?php echo TB_FOLDERS; ?></title>
\r
150 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
\r
151 <meta http-equiv="Pragma" content="no-cache" />
\r
153 if($passfeid == '' && $tinybrowser['integration']=='tinymce')
\r
155 ?><link rel="stylesheet" type="text/css" media="all" href="<?php echo $tinybrowser['tinymcecss']; ?>" /><?php
\r
159 ?><link rel="stylesheet" type="text/css" media="all" href="css/stylefull_tinybrowser.css" /><?php
\r
162 <link rel="stylesheet" type="text/css" media="all" href="css/style_tinybrowser.css.php" />
\r
163 <script language="javascript" type="text/javascript" src="js/tinybrowser.js.php"></script>
\r
165 <body onload="rowHighlight();">
\r
167 if(count($notify['type'])>0) alert($notify);
\r
168 form_open('foldertab',false,'folders.php','?type='.$typenow.$passfeid);
\r
172 <li id="browse_tab"><span><a href="tinybrowser.php?type=<?php echo $typenow.$passfolder.$passfeid ; ?>"><?php echo TB_BROWSE; ?></a></span></li>
\r
174 if($tinybrowser['allowupload'])
\r
176 ?><li id="upload_tab"><span><a href="upload.php?type=<?php echo $typenow.$passfolder.$passfeid ; ?>"><?php echo TB_UPLOAD; ?></a></span></li>
\r
179 if($tinybrowser['allowfolders'])
\r
181 ?><li id="edit_tab"><span><a href="edit.php?type=<?php echo $typenow.$passfolder.$passfeid ; ?>"><?php echo TB_EDIT; ?></a></span></li>
\r
184 ?><li id="folders_tab" class="current"><span><a href="folders.php?type=<?php echo $typenow.$passfolder.$passfeid; ?>"><?php echo TB_FOLDERS; ?></a></span></li>
\r
188 <div class="panel_wrapper">
\r
189 <div id="general_panel" class="panel currentmod">
\r
191 <legend><?php echo TB_FOLDERS; ?></legend>
\r
193 form_open('edit','custom','folders.php','?type='.$typenow.$passfolder.$passfeid);
\r
195 <div class="pushleft">
\r
198 // Assign edit actions based on file type and permissions
\r
200 if($tinybrowser['allowfolders']) $select[] = array('create',TB_CREATE);
\r
201 if($tinybrowser['allowdelete']) $select[] = array('delete',TB_DELETE);
\r
202 if($tinybrowser['allowedit']) $select[] = array('rename',TB_RENAME);
\r
204 form_select($select,'editaction',TB_ACTION,$actionnow,true);
\r
205 ?></form></div><?php
\r
207 form_open('actionform','custom','folders.php','?type='.$typenow.$passfolder.$passfeid);
\r
209 if($actionnow=='move')
\r
210 { ?><div class="pushleft"><?php
\r
211 form_select($editdirs,'destination',TB_FOLDERDEST,urlencode($foldernow),false);
\r
215 switch($actionnow)
\r
218 $actionhead = TB_DELETE;
\r
221 $actionhead = TB_RENAME;
\r
224 $actionhead = TB_CREATE;
\r
229 ?><div class="tabularwrapper"><table class="browse"><tr>
\r
230 <th class="nohvr"><?php echo TB_FOLDERNAME; ?></th>
\r
231 <th class="nohvr"><?php echo TB_FILES; ?></th>
\r
232 <th class="nohvr"><?php echo TB_DATE; ?></th>
\r
233 <th class="nohvr"><?php echo $actionhead; ?></th></tr>
\r
236 for($i=0;$i<$num_of_folders;$i++)
\r
238 $disable = ($i == 0 ? true : false);
\r
239 $alt = (IsOdd($i) ? 'r1' : 'r0');
\r
240 echo '<tr class="'.$alt.'">';
\r
241 echo '<td>'.$dirs[$i][2].'</td>';
\r
242 echo '<td>'.$dirs[$i][4].'</td><td>'.date($tinybrowser['dateformat'],$dirs[$i][5]).'</td>'
\r
244 form_hidden_input('actionfolder['.$i.']',$dirs[$i][0]);
\r
245 switch($actionnow)
\r
249 form_text_input('createfolder['.$i.']',false,'',30,120);
\r
252 $disabledel = ($dirs[$i][4] > 0 ? ' DISABLED' : '');
\r
253 if(!$disable) echo '<input class="del" type="checkbox" name="deletefolder['.$i.']" value="1"'.$disabledel.' />';
\r
256 if(!$disable) form_text_input('renamefolder['.$i.']',false,$dirs[$i][3],30,120);
\r
261 echo "</td></tr>\n";
\r
264 echo "</table></div>\n".'<div class="pushright">';
\r
265 if($tinybrowser['allowdelete'] && $tinybrowser['allowedit'])
\r
267 form_hidden_input('editaction',$actionnow);
\r
268 form_submit_button('commit',$actionhead.' '.TB_FOLDERS,'edit');
\r
271 </div></fieldset></div></div>
\r