root/alternc/trunk/bureau/admin/bro_main.php

Revision 2416, 17.4 kB (checked in by anarcat, 3 months ago)

fix FTP edit link

Closes: #1162

Line 
1 <?php
2 /*
3  $Id: bro_main.php,v 1.11 2004/09/06 18:14:36 anonymous Exp $
4  ----------------------------------------------------------------------
5  AlternC - Web Hosting System
6  Copyright (C) 2002 by the AlternC Development Team.
7  http://alternc.org/
8  ----------------------------------------------------------------------
9  Based on:
10  Valentin Lacambre's web hosting softwares: http://altern.org/
11  ----------------------------------------------------------------------
12  LICENSE
13
14  This program is free software; you can redistribute it and/or
15  modify it under the terms of the GNU General Public License (GPL)
16  as published by the Free Software Foundation; either version 2
17  of the License, or (at your option) any later version.
18
19  This program is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  GNU General Public License for more details.
23
24  To read the license please visit http://www.gnu.org/copyleft/gpl.html
25  ----------------------------------------------------------------------
26  Original Author of file: Benjamin Sonntag, Remi
27  Purpose of file: Online file Browser of AlternC
28  ----------------------------------------------------------------------
29 */
30 require_once("../class/config.php");
31
32 $p=$bro->GetPrefs();
33 if (!$R && $p["golastdir"]) {
34   $R=$p["lastdir"];
35 }
36 $R=$bro->convertabsolute($R,1);
37 // on fait ?
38 if ($formu) {
39   switch ($formu) {
40   case 1// Créer le répertoire $R.$nomfich
41     if (!$bro->CreateDir($R,$nomfich)) {
42       print $err->errstr();
43     }
44     $p=$bro->GetPrefs();
45     break;
46   case 6: // Créer le fichier $R.$nomfich
47     if (!$bro->CreateFile($R,$nomfich)) {
48       print $err->errstr();
49     }
50     $p=$bro->GetPrefs();
51     if ($p["createfile"]==1) {
52       $file=$nomfich;
53       include("bro_editor.php");
54       exit();
55     }
56     break;
57   case 2// act vaut Supprimer Copier ou Renommer.
58     if ($actdel) {
59       if ($del_confirm != "") {
60         if (!$bro->DeleteFile($d,$R)) {
61           print $err->errstr();
62         }
63       } elseif (!$cancel && is_array($d)) {
64         include("head.php");
65 ?>
66 </head>
67 <body>
68   <h3><?php printf(_("Deleting files and/or directories")); ?> : </h3>
69   <form action="bro_main.php" method="post"> 
70     <input type="hidden" name="formu" value="2" />
71     <input type="hidden" name="actdel" value="1" />
72     <input type="hidden" name="R" value="<?php echo $R?>" />
73     <p class="error"><?php __("WARNING: Confirm the deletion of this files"); ?></p>
74 <?php foreach($d as $file){ ?>
75     <p><?php echo stripslashes($file); ?></p>
76         <input type="hidden" name="d[]" value="<?php echo htmlentities(stripslashes($file)); ?>" />
77 <?php } ?>
78     <blockquote>
79       <input type="submit" class="inb" name="del_confirm" value="<?php __("Yes"); ?>" />&nbsp;&nbsp;
80       <input type="submit" class="inb" name="cancel" value="<?php __("No"); ?>" />
81     </blockquote>
82   </form>
83 </body>
84 </html>
85 <?php
86         exit();
87       }
88     }
89     if ($actcopy) {
90       if (!$bro->CopyFile($d,$R,$actmoveto)) {
91         print $err->errstr();
92       }
93     }
94     if ($actmove) {
95       if (!$bro->MoveFile($d,$R,$actmoveto)) {
96         print $err->errstr();
97       }
98     }
99     break;
100   case 4// Renommage Effectif...
101     if (!$bro->RenameFile($R,$o,$d)) { // Rename $R (directory) $o (old) $d (new) names
102       print $err->errstr();
103     }
104     break;
105   case 3// Upload de fichier...
106     if (!$bro->UploadFile($R)) {
107       print $err->errstr();
108     }
109     break;
110   case 7// Changement de permissions [ML]
111     if (!$bro->ChangePermissions($R, $d, $perm)) {
112       print $err->errstr();
113     }
114     break;
115   }
116 }
117
118 if ($actextract) {
119   print _("extracting...");
120   if ($bro->ExtractFile($R. '/' . $file, $R)) {
121     print $err->errstr();
122     print _("failed");
123   } else {
124     print _("done");
125   }
126 }
127
128 /* Creation de la liste des fichiers courants */
129 $c=$bro->filelist($R);
130 if ($c===false) $error=$err->errstr();
131
132 include("head.php");
133 ?>
134 </head>
135 <body>
136
137 <div id="browser">
138 <h3><?php __("File browser"); ?></h3>
139 <hr />
140 <table width="100%"><tr><td valign="top">
141 <a href="bro_main.php?R=/"><?php echo $mem->user["login"]; ?></a>&nbsp;/&nbsp;<?php echo $bro->PathList($R,"bro_main.php") ?><br />
142 <small>
143 <?php if ($error) echo "<font color=\"red\">$error</font>"; ?>
144 </td><td valign="top" align="right">
145
146 <form action="bro_main.php" method="post" name="nn" id="nn">
147 <input type="hidden" name="R" value="<?php echo $R; ?>" />
148 <table id="add-file"><tr>
149 <td><input type="text" class="int" name="nomfich" size="22" maxlength="255" /></td>
150 <td><input type="submit" class="inb" value="<?php __("Create"); ?>" /></td>
151 </tr><tr><td>
152 <input type="radio" class="inc" id="nfile" onclick="document.nn.nomfich.focus();" name="formu" value="6" <?php if (!$p["crff"]) echo "checked=\"checked\""; ?> /><label for="nfile">&nbsp;<?php __("File"); ?></label>
153 <input type="radio" class="inc" id="nfold" onclick="document.nn.nomfich.focus();" name="formu" value="1" <?php if ($p["crff"]) echo "checked=\"checked\""; ?> /><label for="nfold">&nbsp;<?php __("Folder"); ?></label>
154 </td><td></td></tr></table>
155 </form>
156 </td></tr>
157 </table>
158
159 </td></tr>
160 <tr><td valign="top">
161
162 <?php
163 /* Renommer / Copier / Déplacer les fichiers : */
164 if ($formu==2 && $actrename && count($d)) {
165   echo "<form action=\"bro_main.php\" method=\"post\">\n";
166   echo "<input type=\"hidden\" name=\"R\" value=\"$R\" />\n";
167   echo "<input type=\"hidden\" name=\"formu\" value=\"4\" />\n";
168   echo "<p>"._("Rename")."</p>";
169   for ($i=0;$i<count($d);$i++) {
170     $d[$i]=ssla($d[$i]);
171     echo "<table>";
172     echo "<tr><td>"._("Old Name:")."</td><td><input type=\"hidden\" name=\"o[$i]\" value=\"".$d[$i]."\" />".$d[$i]."</td></tr>";
173     echo "<tr><td>"._("New Name:")."</td><td><input type=\"text\" class=\"int\" style=\"width: 350px\" name=\"d[$i]\" value=\"".$d[$i]."\" /></td></tr>";
174     echo "</table>";
175   }
176   echo "<p><input type=\"submit\" class=\"inb\" name=\"submit\" value=\""._("Rename")."\" /></p>";
177   echo "</form>\n";
178   echo "<hr />\n";
179 }
180
181 /* [ML] Changer les permissions : */
182 if ($formu==2 && $_REQUEST['actperms'] && count($d)) {
183   echo "<form action=\"bro_main.php\" method=\"post\">\n";
184   echo "<input type=\"hidden\" name=\"R\" value=\"$R\" />\n";
185   echo "<input type=\"hidden\" name=\"formu\" value=\"7\" />\n";
186   echo "<p>"._("Permissions")."</p>";
187
188   $tmp_absdir = $bro->convertabsolute($R,0);
189
190   echo "<table border=\"1\">"; // FIXME, marco, ajouter classe css?
191   echo "<tr>";
192   // echo "<th>" . 'File' . "</th><th>&nbsp;</th><th>Owner</th><th>Group</th><th>Other</th>"; // FIXME , i18n
193   echo "<th>" . 'File' . "</th><th>Permissions</th>"; // FIXME, i18n
194   echo "</tr>";
195
196   for ($i=0;$i<count($d);$i++) {
197     $d[$i]=ssla($d[$i]);
198     $stats = stat($tmp_absdir . '/' . $d[$i]);
199     $modes = $stats[2];
200
201     echo "<tr>";
202     echo "<td>".$d[$i]."</td>";
203
204     // Owner
205     echo "<td>";
206     echo "<input type=\"hidden\" name=\"d[$i]\" value=\"".$d[$i]."\" />";
207     // echo "<label>read <input type=\"checkbox\" name=\"perm[$i][r]\" value=\"1\" ". (($modes & 0000400) ? 'checked="checked"' : '') ." />";
208     echo "<label>write <input type=\"checkbox\" name=\"perm[$i][w]\" value=\"1\" ". (($modes & 0000200) ? 'checked="checked"' : '') ." />";
209     echo "</td>";
210
211     echo "</tr>";
212   }
213
214   echo "</table>";
215
216   echo "<p><input type=\"submit\" class=\"inb\" name=\"submit\" value=\""._("Change permissions")."\" /></p>";
217   echo "</form>\n";
218   echo "<hr />\n";
219 }
220
221 /* We draw the file list and button bar only if there is files here ! */
222 if (count($c)) {
223
224 ?>
225 <form action="bro_main.php" method="post" name="main" id="main">
226 <input type="hidden" name="R" value="<?php echo $R; ?>" />
227 <input type="hidden" name="formu" value="2" />
228 <hr />
229 <script type="text/javascript">
230 <!--
231 document.write("<input type=\"button\" value=\"<?php __("all/none"); ?>\" class=\"inb\" onclick=\"CheckAll();\" />");
232 //  -->
233 </script>
234 <input type="submit" class="inb" name="actdel" value="<?php __("Delete"); ?>" />
235
236 <input type="submit" class="inb" name="actrename" value="<?php __("Rename"); ?>" />
237 <input type="submit" class="inb" name="actperms" value="<?php __("Permissions"); ?>" /> <!-- [ML] -->
238 &nbsp;&nbsp;&nbsp;
239 <input type="submit" class="inb" name="actcopy" value="<?php __("Copy to"); ?>" />
240
241 <input type="submit" class="inb" name="actmove" value="<?php __("Move to"); ?>" />&nbsp;:&nbsp;<input type="text" class="int" name="actmoveto" value="" />
242 <script type="text/javascript">
243 <!--
244 document.write("<input type=\"button\" name=\"bff\" onclick=\"browseforfolder('main.actmoveto');\" value=\" ... \" class=\"inb\" />");
245 //  -->
246 </script>
247      <hr />
248
249
250
251 <?php
252      switch ($p["listmode"]) {
253 case 0:
254 /* AFFICHE 1 COLONNE DETAILLEE */
255 reset($c);
256 echo "<table width=\"100%\" style=\"border: 0px\" cellpadding=\"0\" cellspacing=\"0\">";
257 $col=1;
258 for($i=0;$i<count($c);$i++) {
259 $col=3-$col;
260 echo "<tr class=\"lst$col\">\n";
261 if ($c[$i]["type"]) {
262 echo "    <td width=\"28\"><input type=\"checkbox\" class=\"inc\" name=\"d[]\" value=\"".htmlentities($c[$i]["name"])."\" /></td>";
263 if ($p["showicons"]) {
264 echo "<td width=\"28\"><img src=\"icon/".$bro->icon($c[$i]["name"])."\" width=\"16\" height=\"16\" alt=\"\" /></td>";
265 }
266 echo "<td><a href=\"";
267 echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
268 echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
269 echo "    <td>".format_size($c[$i]["size"])."</td>";
270 echo "<td>".format_date('%3$d-%2$d-%1$d %4$d:%5$d',date("Y-m-d H:i:s",$c[$i]["date"]))."<br /></td>";
271 if ($p["showtype"]) {
272 echo "<td>"._($bro->mime($c[$i]["name"]))."</td>";
273 }
274 $vu=$bro->viewurl($R,$c[$i]["name"]);
275 if ($vu) {
276 echo "<td><a href=\"$vu\">"._("View")."</a>";
277 } else {
278 echo "<td>&nbsp;";
279 }
280 $e = $bro->is_extractable($R,$c[$i]["name"]);
281 if ($e) {
282 echo "<a href=\"bro_main.php?actextract=1&file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R)."\">";
283 echo _("Extract");
284 echo "</a>";
285 }
286
287 echo "</td>\n";
288 } else {           // DOSSIER :
289 echo "    <td width=\"28\"><input type=\"checkbox\" class=\"inc\" name=\"d[]\" value=\"".htmlentities($c[$i]["name"])."\" /></td>";
290 if ($p["showicons"]) {
291 echo "<td width=\"28\"><img src=\"icon/folder.png\" width=\"16\" height=\"16\" alt=\"\" /></td>";
292 }
293 echo "<td><b><a href=\"";
294 echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
295 echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
296 echo "    <td>".format_size($c[$i]["size"])."</td>";
297 echo "<td>".format_date('%3$d-%2$d-%1$d %4$d:%5$d',date("Y-m-d h:i:s",$c[$i]["date"]))."<br /></td>";
298 if ($p["showtype"]) {
299 echo "<td>Dossier</td>";
300 }
301 echo "<td>&nbsp;";
302 echo "</td>\n";
303 }
304
305 echo "</tr>\n";
306 }
307 echo "</table>";
308 break;
309 case 1:
310 /* AFFICHE 2 COLONNES COURTES */
311 reset($c);
312 echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
313 echo "<tr><td valign=\"top\" width=\"50%\">";
314 echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
315 $col=1;
316 for($i=0;$i<round(count($c)/2);$i++) {
317 $col=3-$col;
318 echo "<tr class=\"lst$col\">\n";
319 if ($c[$i]["type"]) {
320 echo "    <td width=\"28\"><input type=\"checkbox\" class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\" /></td><td><a href=\"";
321 echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
322 echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
323 echo "    <td>".format_size($c[$i]["size"])."</td><td>";
324 $vu=$bro->viewurl($R,$c[$i]["name"]);
325 if ($vu) {
326 echo "<td><a href=\"$vu\">"._("V")."</a>";
327 } else {
328 echo "<td>&nbsp;";
329 }
330 echo "</td>\n";
331 } else {
332 echo "    <td width=\"28\"><input TYPE=checkbox class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><b><a href=\"";
333 echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
334 echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
335 echo "    <td>".format_size($c[$i]["size"])."</td><td>";
336 echo "&nbsp;";
337 echo "</td>\n";
338 }
339
340 echo "</tr>\n";
341 }
342 echo "</table>";
343 echo "</td><td valign=\"top\" width=\"50%\">";
344 echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
345 $col=1;
346 for($i=round(count($c)/2);$i<count($c);$i++) {
347 $col=3-$col;
348 echo "<tr class=\"lst$col\">\n";
349 if ($c[$i]["type"]) {
350 echo "    <td width=\"28\"><input TYPE=checkbox class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><a href=\"";
351 echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
352 echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
353 echo "    <td>".format_size($c[$i]["size"])."</td><td>";
354 $vu=$bro->viewurl($R,$c[$i]["name"]);
355 if ($vu) {
356 echo "<td><a href=\"$vu\">"._("V")."</a>";
357 } else {
358 echo "<td>&nbsp;";
359 }
360 echo "</td>\n";
361 } else {
362 echo "    <td width=\"28\"><input TYPE=checkbox class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><b><a href=\"";
363 echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
364 echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
365 echo "    <td>".format_size($c[$i]["size"])."</td><td>";
366 echo "&nbsp;";
367 echo "</td>\n";
368 }
369
370 echo "</tr>\n";
371 }
372 echo "</table>";
373 echo "</td></tr>";
374 echo "</table>";
375 break;
376 case 2:
377 /* AFFICHE 3 COLONNES COURTES */
378 reset($c);
379 echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
380 echo "<tr><td valign=\"top\" width=\"33%\">";
381 echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
382 $col=1;
383 for($i=0;$i<round(count($c)/3);$i++) {
384 $col=3-$col;
385 echo "<tr class=\"lst$col\">\n";
386 if ($c[$i]["type"]) {
387 echo "    <td width=\"28\"><input TYPE=checkbox class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><a href=\"";
388 echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
389 echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
390 echo "    <td>".format_size($c[$i]["size"])."</td><td>";
391 $vu=$bro->viewurl($R,$c[$i]["name"]);
392 if ($vu) {
393 echo "<td><a href=\"$vu\">"._("V")."</a>";
394 } else {
395 echo "<td>&nbsp;";
396 }
397 echo "</td>\n";
398 } else {
399 echo "    <td width=\"28\"><input TYPE=checkbox class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><b><a href=\"";
400 echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
401 echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
402 echo "    <td>".format_size($c[$i]["size"])."</td><td>";
403 echo "&nbsp;";
404 echo "</td>\n";
405 }
406
407 echo "</tr>\n";
408 }
409 echo "</table>";
410 echo "</td><td valign=\"top\" width=\"33%\">";
411 echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
412 $col=1;
413 for($i=round(count($c)/3);$i<round(2*count($c)/3);$i++) {
414 $col=3-$col;
415 echo "<tr class=\"lst$col\">\n";
416 if ($c[$i]["type"]) {
417 echo "    <td width=\"28\"><input TYPE=checkbox class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><a href=\"";
418 echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
419 echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
420 echo "    <td>".format_size($c[$i]["size"])."</td><td>";
421 $vu=$bro->viewurl($R,$c[$i]["name"]);
422 if ($vu) {
423 echo "<td><a href=\"$vu\">"._("V")."</a>";
424 } else {
425 echo "<td>&nbsp;";
426 }
427
428 echo "</td>\n";
429 } else {
430 echo "    <td width=\"28\"><input TYPE=checkbox class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><b><a href=\"";
431 echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
432 echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
433 echo "    <td>".format_size($c[$i]["size"])."</td><td>";
434 echo "&nbsp;";
435 echo "</td>\n";
436 }
437
438 echo "</tr>\n";
439 }
440 echo "</table>";
441 echo "</td><td valign=\"top\" width=\"33%\">";
442 echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
443 $col=1;
444 for($i=round(2*count($c)/3);$i<count($c);$i++) {
445 $col=3-$col;
446 echo "<tr class=\"lst$col\">\n";
447 if ($c[$i]["type"]) {
448 echo "    <td width=\"28\"><input TYPE=checkbox class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><a href=\"";
449 echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
450 echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
451 echo "    <td>".format_size($c[$i]["size"])."</td><td>";
452 $vu=$bro->viewurl($R,$c[$i]["name"]);
453 if ($vu) {
454 echo "<td><a href=\"$vu\">"._("View")."</a>";
455 } else {
456 echo "<td>&nbsp;";
457 }
458 echo "</td>\n";
459 } else {
460 echo "    <td width=\"28\"><input TYPE=checkbox class=\"inc\"  name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><b><a href=\"";
461 echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
462 echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
463 echo "    <td>".format_size($c[$i]["size"])."</td><td>";
464 echo "&nbsp;";
465 echo "</td>\n";
466 }
467
468 echo "</tr>\n";
469 }
470 echo "</table>";
471 echo "</td></tr>";
472 echo "</table>";
473 break;
474 }
475 ?>
476      </form>
477 <?php
478      } // is there any files here ?
479 else {
480   echo "<p class=\"error\">"._("No files in this folder")."</p>";
481 }
482 ?>
483
484      </td></tr>
485      <tr><td colspan="2">
486
487
488      <form action="bro_main.php" enctype="multipart/form-data" method="post">
489      <input type="hidden" name="R" value="<?php echo $R; ?>" />
490      <input type="hidden" name="formu" value="3" />
491      <hr />
492      <?php __("Import this file"); ?>&nbsp;&nbsp;<input class="int" name="userfile" type="file" />
493      <input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
494      <input type="submit" class="inb" name="upload" value="<?php __("Send"); ?>" /