maj version dans config.xml
[mtweb] / mw / libs / tiny_mce / plugins / tinybrowser / folders.php
1 <?php\r
2 require_once('config_tinybrowser.php');\r
3 // Set language\r
4 if(isset($tinybrowser['language']) && file_exists('langs/'.$tinybrowser['language'].'.php'))\r
5         {\r
6         require_once('langs/'.$tinybrowser['language'].'.php'); \r
7         }\r
8 else\r
9         {\r
10         require_once('langs/en.php'); // Falls back to English\r
11         }\r
12 require_once('fns_tinybrowser.php');\r
13 \r
14 // Check session, if it exists\r
15 if(session_id() != '')\r
16         {\r
17         if(!isset($_SESSION[$tinybrowser['sessioncheck']]))\r
18                 {\r
19                 echo TB_DENIED;\r
20                 exit;\r
21                 }\r
22         }\r
23         \r
24 if(!$tinybrowser['allowfolders'])\r
25         {\r
26         echo TB_FODENIED;\r
27         exit;\r
28         }\r
29 \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
37 \r
38 \r
39 \r
40 // Assign browsing options\r
41 $actionnow = (isset($_POST['editaction']) ? $_POST['editaction'] : 'create' );\r
42 \r
43 // Initalise alert array\r
44 $notify = array(\r
45         'type' => array(),\r
46         'message' => array()\r
47 );\r
48 $createqty = 0;\r
49 $deleteqty = 0;\r
50 $renameqty = 0;\r
51 $errorqty = 0;\r
52         \r
53 // Create any child folders with entered name\r
54 if(isset($_POST['createfolder']))\r
55         {\r
56         foreach($_POST['createfolder'] as $parent => $newfolder)\r
57                 {\r
58                 if($newfolder != '')\r
59                         {\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
63                            {\r
64                                 createfolder($createthisfolder.'/_thumbs/',$tinybrowser['unixpermissions']);\r
65                            }\r
66                         }\r
67                 }\r
68         }\r
69         \r
70 // Delete any checked folders\r
71 if(isset($_POST['deletefolder']))\r
72         {\r
73         foreach($_POST['deletefolder'] as $delthis => $val)\r
74                 {\r
75                 if($typenow=='image')\r
76                         {\r
77                         $delthisthumbdir = $tinybrowser['docroot'].$dirpath.urldecode($_POST['actionfolder'][$delthis]).'_thumbs/';\r
78                         if (is_dir($delthisthumbdir)) rmdir($delthisthumbdir);\r
79                         }\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
83          {\r
84          $foldernow = '';\r
85          $passfolder = '';\r
86          }\r
87                 }\r
88 \r
89         }\r
90         \r
91 // Rename any folders with changed name\r
92 if(isset($_POST['renamefolder']))\r
93         {\r
94         foreach($_POST['renamefolder'] as $namethis => $newname)\r
95                 {\r
96       $urlparts = explode('/',rtrim(urldecode($_POST['actionfolder'][$namethis]),'/'));\r
97                 if(array_pop($urlparts) != $newname)\r
98                         {\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
104             {\r
105             $foldernow = ltrim($renameurl,'/');\r
106             $passfolder = '&folder='.urlencode(ltrim($renameurl,'/'));\r
107             }\r
108                         }\r
109                 }\r
110         }\r
111 \r
112 // Assign directory structure to array\r
113 $dirs=array();\r
114 dirtree($dirs,$tinybrowser['filetype'][$typenow],$tinybrowser['docroot'],$tinybrowser['path'][$typenow]);\r
115 \r
116 // generate alert if folders deleted\r
117 if($createqty>0)\r
118    {\r
119         $notify['type'][]='success';\r
120         $notify['message'][]=sprintf(TB_MSGCREATE, $createqty);\r
121         }\r
122 // generate alert if folders deleted\r
123 elseif($deleteqty>0)\r
124    {\r
125         $notify['type'][]='success';\r
126         $notify['message'][]=sprintf(TB_MSGDELETE, $deleteqty);\r
127         }\r
128 // generate alert if folders renamed\r
129 elseif($renameqty>0)\r
130    {\r
131         $notify['type'][]='success';\r
132         $notify['message'][]=sprintf(TB_MSGRENAME, $renameqty);\r
133         }\r
134         \r
135 // generate alert if file errors encountered\r
136 if($errorqty>0)\r
137    {\r
138         $notify['type'][]='failure';\r
139         $notify['message'][]=sprintf(TB_MSGEDITERR, $errorqty);\r
140         }\r
141         \r
142 // count folders\r
143 $num_of_folders = (isset($dirs) ? count($dirs) : 0);\r
144 \r
145 ?>\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
148 <head>\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
152 <?php\r
153 if($passfeid == '' && $tinybrowser['integration']=='tinymce')\r
154         {\r
155         ?><link rel="stylesheet" type="text/css" media="all" href="<?php echo $tinybrowser['tinymcecss']; ?>" /><?php \r
156         }\r
157 else\r
158         {\r
159         ?><link rel="stylesheet" type="text/css" media="all" href="css/stylefull_tinybrowser.css" /><?php \r
160         }\r
161 ?>\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
164 </head>\r
165 <body onload="rowHighlight();">\r
166 <?php\r
167 if(count($notify['type'])>0) alert($notify);\r
168 form_open('foldertab',false,'folders.php','?type='.$typenow.$passfeid);\r
169 ?>\r
170 <div class="tabs">\r
171 <ul>\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
173 <?php\r
174 if($tinybrowser['allowupload']) \r
175         {\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
177         <?php \r
178         }\r
179 if($tinybrowser['allowfolders'])\r
180         {\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
182    <?php\r
183    }\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
185 </ul>\r
186 </div>\r
187 </form>\r
188 <div class="panel_wrapper">\r
189 <div id="general_panel" class="panel currentmod">\r
190 <fieldset>\r
191 <legend><?php echo TB_FOLDERS; ?></legend>\r
192 <?php\r
193 form_open('edit','custom','folders.php','?type='.$typenow.$passfolder.$passfeid);\r
194 ?>\r
195 <div class="pushleft">\r
196 <?php\r
197 \r
198 // Assign edit actions based on file type and permissions\r
199 $select = array();\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
203 \r
204 form_select($select,'editaction',TB_ACTION,$actionnow,true);\r
205 ?></form></div><?php\r
206 \r
207 form_open('actionform','custom','folders.php','?type='.$typenow.$passfolder.$passfeid);\r
208 \r
209 if($actionnow=='move')\r
210    { ?><div class="pushleft"><?php\r
211    form_select($editdirs,'destination',TB_FOLDERDEST,urlencode($foldernow),false);\r
212    ?></div><?php\r
213    } \r
214 \r
215 switch($actionnow) \r
216         {\r
217         case 'delete':\r
218                 $actionhead = TB_DELETE;\r
219                 break;\r
220         case 'rename':\r
221                 $actionhead = TB_RENAME;\r
222                 break;\r
223         case 'create':\r
224                 $actionhead = TB_CREATE;\r
225                 break;\r
226         default:\r
227                 // do nothing\r
228         }\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
234 <?php\r
235 \r
236 for($i=0;$i<$num_of_folders;$i++)\r
237         {\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
243         .'<td>';\r
244         form_hidden_input('actionfolder['.$i.']',$dirs[$i][0]);\r
245         switch($actionnow) \r
246                 {\r
247                 case 'create':\r
248          echo '&rarr; ';\r
249                         form_text_input('createfolder['.$i.']',false,'',30,120);\r
250                         break;\r
251                 case 'delete':\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
254                         break;\r
255                 case 'rename':\r
256                         if(!$disable) form_text_input('renamefolder['.$i.']',false,$dirs[$i][3],30,120);\r
257                         break;\r
258                 default:\r
259                         // do nothing\r
260                 }\r
261         echo "</td></tr>\n";\r
262         }\r
263 \r
264 echo "</table></div>\n".'<div class="pushright">';\r
265 if($tinybrowser['allowdelete'] && $tinybrowser['allowedit'])\r
266         {\r
267         form_hidden_input('editaction',$actionnow);\r
268         form_submit_button('commit',$actionhead.' '.TB_FOLDERS,'edit');\r
269         }\r
270 ?>\r
271 </div></fieldset></div></div>\r
272 </body>\r
273 </html>\r