source: alternc/trunk/bureau/admin/bro_main.php @ 2090

Revision 2090, 15.5 KB checked in by anarcat, 5 years ago (diff)

don't translate mimetypes in m_bro::mime(). revert hooking tarball extraction from the last commit

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*/
30require_once("../class/config.php");
31
32$p=$bro->GetPrefs();
33if (!$R && $p["golastdir"]) {
34  $R=$p["lastdir"];
35}
36$R=$bro->convertabsolute($R,1);
37// on fait ?
38if ($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  }
111}
112
113/* Creation de la liste des fichiers courants */
114$c=$bro->filelist($R);
115if ($c===false) $error=$err->errstr();
116
117include("head.php");
118?>
119</head>
120<body>
121
122<table border="0" width="100%" cellspacing="0">
123<tr><td>
124
125<hr />
126<table width="100%"><tr><td valign="top">
127<a href="bro_main.php?R=/"><?php echo $mem->user["login"]; ?></a>&nbsp;/&nbsp;<?php echo $bro->PathList($R,"bro_main.php") ?><br />
128<small>
129<?php if ($error) echo "<font color=\"red\">$error</font>"; ?>
130</td><td valign="top" align="right">
131<h3><?php __("File browser"); ?></h3>
132
133<form action="bro_main.php" method="post" name="nn" id="nn">
134<input type="hidden" name="R" value="<?php echo $R; ?>" />
135<table><tr>
136<td><input type="text" class="int" name="nomfich" size="22" maxlength="255" /></td>
137<td><input type="submit" class="inb" value="<?php __("Create"); ?>" /></td>
138</tr><tr><td>
139<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>
140<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>
141</td><td></td></tr></table>
142</form>
143</td></tr>
144</table>
145
146</td></tr>
147<tr><td valign="top">
148
149<?php
150/* Renommer / Copier / Déplacer les fichiers : */
151if ($formu==2 && $actrename && count($d)) {
152  echo "<form action=\"bro_main.php\" method=\"post\">\n";
153  echo "<input type=\"hidden\" name=\"R\" value=\"$R\" />\n";
154  echo "<input type=\"hidden\" name=\"formu\" value=\"4\" />\n";
155  echo "<p>"._("Rename")."</p>";
156  for ($i=0;$i<count($d);$i++) {
157    $d[$i]=ssla($d[$i]);
158    echo "<table>";
159    echo "<tr><td>"._("Old Name:")."</td><td><input type=\"hidden\" name=\"o[$i]\" value=\"".$d[$i]."\" />".$d[$i]."</td></tr>";
160    echo "<tr><td>"._("New Name:")."</td><td><input type=\"text\" class=\"int\" style=\"width: 350px\" name=\"d[$i]\" value=\"".$d[$i]."\" /></td></tr>";
161    echo "</table>";
162  }
163  echo "<p><input type=\"submit\" class=\"inb\" name=\"submit\" value=\""._("Rename")."\" /></p>";
164  echo "</form>\n";
165  echo "<hr />\n";
166}
167
168/* We draw the file list and button bar only if there is files here ! */
169if (count($c)) {
170
171?>
172<form action="bro_main.php" method="post" name="main" id="main">
173<input type="hidden" name="R" value="<?php echo $R; ?>" />
174<input type="hidden" name="formu" value="2" />
175<hr />
176<script type="text/javascript">
177<!--
178document.write("<input type=\"button\" value=\"<?php __("all/none"); ?>\" class=\"inb\" onclick=\"CheckAll();\" />");
179//  -->
180</script>
181<input type="submit" class="inb" name="actdel" value="<?php __("Delete"); ?>" />
182
183<input type="submit" class="inb" name="actrename" value="<?php __("Rename"); ?>" />
184&nbsp;&nbsp;&nbsp;
185<input type="submit" class="inb" name="actcopy" value="<?php __("Copy to"); ?>" />
186
187<input type="submit" class="inb" name="actmove" value="<?php __("Move to"); ?>" />&nbsp;:&nbsp;<input type="text" class="int" name="actmoveto" value="" />
188<script type="text/javascript">
189<!--
190document.write("<input type=\"button\" name=\"bff\" onclick=\"browseforfolder('main.actmoveto');\" value=\" ... \" class=\"inb\" />");
191//  -->
192</script>
193     <hr />
194
195
196
197<?php
198     switch ($p["listmode"]) {
199case 0:
200/* AFFICHE 1 COLONNE DETAILLEE */
201reset($c);
202echo "<table width=\"100%\" style=\"border: 0px\" cellpadding=\"0\" cellspacing=\"0\">";
203$col=1;
204for($i=0;$i<count($c);$i++) {
205$col=3-$col;
206echo "<tr class=\"lst$col\">\n";
207if ($c[$i]["type"]) {
208echo "  <td width=\"28\"><input type=\"checkbox\" class=\"inc\" name=\"d[]\" value=\"".htmlentities($c[$i]["name"])."\" /></td>";
209if ($p["showicons"]) {
210echo "<td width=\"28\"><img src=\"icon/".$bro->icon($c[$i]["name"])."\" width=\"16\" height=\"16\" alt=\"\" /></td>";
211}
212echo "<td><a href=\"";
213echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
214echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
215echo "  <td>".format_size($c[$i]["size"])."</td>";
216echo "<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>";
217if ($p["showtype"]) {
218echo "<td>"._($bro->mime($c[$i]["name"]))."</td>";
219}
220$vu=$bro->viewurl($R,$c[$i]["name"]);
221if ($vu) {
222echo "<td><a href=\"$vu\">"._("View")."</a>";
223} else {
224echo "<td>&nbsp;";
225}
226echo "</td>\n";
227} else {           // DOSSIER :
228echo "  <td width=\"28\"><input type=\"checkbox\" class=\"inc\" name=\"d[]\" value=\"".htmlentities($c[$i]["name"])."\" /></td>";
229if ($p["showicons"]) {
230echo "<td width=\"28\"><img src=\"icon/folder.png\" width=\"16\" height=\"16\" alt=\"\" /></td>";
231}
232echo "<td><b><a href=\"";
233echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
234echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
235echo "  <td>".format_size($c[$i]["size"])."</td>";
236echo "<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>";
237if ($p["showtype"]) {
238echo "<td>Dossier</td>";
239}
240echo "<td>&nbsp;";
241echo "</td>\n";
242}
243
244echo "</tr>\n";
245}
246echo "</table>";
247break;
248case 1:
249/* AFFICHE 2 COLONNES COURTES */
250reset($c);
251echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
252echo "<tr><td valign=\"top\" width=\"50%\">";
253echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
254$col=1;
255for($i=0;$i<round(count($c)/2);$i++) {
256$col=3-$col;
257echo "<tr class=\"lst$col\">\n";
258if ($c[$i]["type"]) {
259echo "  <td width=\"28\"><input type=\"checkbox\" class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\" /></td><td><a href=\"";
260echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
261echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
262echo "  <td>".format_size($c[$i]["size"])."</td><td>";
263$vu=$bro->viewurl($R,$c[$i]["name"]);
264if ($vu) {
265echo "<td><a href=\"$vu\">"._("V")."</a>";
266} else {
267echo "<td>&nbsp;";
268}
269echo "</td>\n";
270} else {
271echo "  <td width=\"28\"><input TYPE=checkbox class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><b><a href=\"";
272echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
273echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
274echo "  <td>".format_size($c[$i]["size"])."</td><td>";
275echo "&nbsp;";
276echo "</td>\n";
277}
278
279echo "</tr>\n";
280}
281echo "</table>";
282echo "</td><td valign=\"top\" width=\"50%\">";
283echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
284$col=1;
285for($i=round(count($c)/2);$i<count($c);$i++) {
286$col=3-$col;
287echo "<tr class=\"lst$col\">\n";
288if ($c[$i]["type"]) {
289echo "  <td width=\"28\"><input TYPE=checkbox class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><a href=\"";
290echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
291echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
292echo "  <td>".format_size($c[$i]["size"])."</td><td>";
293$vu=$bro->viewurl($R,$c[$i]["name"]);
294if ($vu) {
295echo "<td><a href=\"$vu\">"._("V")."</a>";
296} else {
297echo "<td>&nbsp;";
298}
299echo "</td>\n";
300} else {
301echo "  <td width=\"28\"><input TYPE=checkbox class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><b><a href=\"";
302echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
303echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
304echo "  <td>".format_size($c[$i]["size"])."</td><td>";
305echo "&nbsp;";
306echo "</td>\n";
307}
308
309echo "</tr>\n";
310}
311echo "</table>";
312echo "</td></tr>";
313echo "</table>";
314break;
315case 2:
316/* AFFICHE 3 COLONNES COURTES */
317reset($c);
318echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
319echo "<tr><td valign=\"top\" width=\"33%\">";
320echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
321$col=1;
322for($i=0;$i<round(count($c)/3);$i++) {
323$col=3-$col;
324echo "<tr class=\"lst$col\">\n";
325if ($c[$i]["type"]) {
326echo "  <td width=\"28\"><input TYPE=checkbox class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><a href=\"";
327echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
328echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
329echo "  <td>".format_size($c[$i]["size"])."</td><td>";
330$vu=$bro->viewurl($R,$c[$i]["name"]);
331if ($vu) {
332echo "<td><a href=\"$vu\">"._("V")."</a>";
333} else {
334echo "<td>&nbsp;";
335}
336echo "</td>\n";
337} else {
338echo "  <td width=\"28\"><input TYPE=checkbox class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><b><a href=\"";
339echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
340echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
341echo "  <td>".format_size($c[$i]["size"])."</td><td>";
342echo "&nbsp;";
343echo "</td>\n";
344}
345
346echo "</tr>\n";
347}
348echo "</table>";
349echo "</td><td valign=\"top\" width=\"33%\">";
350echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
351$col=1;
352for($i=round(count($c)/3);$i<round(2*count($c)/3);$i++) {
353$col=3-$col;
354echo "<tr class=\"lst$col\">\n";
355if ($c[$i]["type"]) {
356echo "  <td width=\"28\"><input TYPE=checkbox class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><a href=\"";
357echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
358echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
359echo "  <td>".format_size($c[$i]["size"])."</td><td>";
360$vu=$bro->viewurl($R,$c[$i]["name"]);
361if ($vu) {
362echo "<td><a href=\"$vu\">"._("V")."</a>";
363} else {
364echo "<td>&nbsp;";
365}
366
367echo "</td>\n";
368} else {
369echo "  <td width=\"28\"><input TYPE=checkbox class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><b><a href=\"";
370echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
371echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
372echo "  <td>".format_size($c[$i]["size"])."</td><td>";
373echo "&nbsp;";
374echo "</td>\n";
375}
376
377echo "</tr>\n";
378}
379echo "</table>";
380echo "</td><td valign=\"top\" width=\"33%\">";
381echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
382$col=1;
383for($i=round(2*count($c)/3);$i<count($c);$i++) {
384$col=3-$col;
385echo "<tr class=\"lst$col\">\n";
386if ($c[$i]["type"]) {
387echo "  <td width=\"28\"><input TYPE=checkbox class=\"inc\" name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><a href=\"";
388echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
389echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
390echo "  <td>".format_size($c[$i]["size"])."</td><td>";
391$vu=$bro->viewurl($R,$c[$i]["name"]);
392if ($vu) {
393echo "<td><a href=\"$vu\">"._("View")."</a>";
394} else {
395echo "<td>&nbsp;";
396}
397echo "</td>\n";
398} else {
399echo "  <td width=\"28\"><input TYPE=checkbox class=\"inc\"  name=\"d[]\" value=\"".$c[$i]["name"]."\"></td><td><b><a href=\"";
400echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
401echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
402echo "  <td>".format_size($c[$i]["size"])."</td><td>";
403echo "&nbsp;";
404echo "</td>\n";
405}
406
407echo "</tr>\n";
408}
409echo "</table>";
410echo "</td></tr>";
411echo "</table>";
412break;
413}
414?>
415     </form>
416<?php 
417         } // is there any files here ?
418else {
419  echo "<p class=\"error\">"._("No files in this folder")."</p>";
420}
421?>
422
423     </td></tr>
424     <tr><td colspan="2">
425
426
427     <form action="bro_main.php" enctype="multipart/form-data" method="post">
428     <input type="hidden" name="R" value="<?php echo $R; ?>" />
429     <input type="hidden" name="formu" value="3" />
430     <hr />
431     <?php __("Import this file"); ?>&nbsp;&nbsp;<input class="int" name="userfile" type="file" />
432     <input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
433     <input type="submit" class="inb" name="upload" value="<?php __("Send"); ?>" />
434     <input type="submit" class="inb" name="extract" value="<?php __("Send & Extract"); ?>" />
435     <hr />
436     </form>
437     <p>&nbsp;</p>
438
439     <?php
440
441
442     if ($id=$ftp->is_ftp($R)) {
443echo _("There is an ftp account in this folder")." <a href=\"ftp_edit?id=".urlencode($id)."\">"._("Click here to edit this ftp account.")."</a><br />";
444}
445else {
446echo "<a href=\"ftp_add.php?dir=".urlencode($R)."\">"._("Click here to create an ftp account in this folder.")."</a><br />";
447}
448
449if ($hta->is_protected($R)) {
450echo "<a href=\"hta_edit.php?dir=$R\">"._("This folder has restricted access")."</a><br />";
451}
452else {
453echo "<a href=\"hta_add.php?value=$R\">"._("Click here to protect this folder with login/password")."</a><br />";
454}
455?>
456<br />
457<a href="bro_tgzdown.php?dir=<?php echo $R; ?>"><?php __("Download"); ?></a> <?php __("this folder and its subfolders as a compressed file"); ?> (<?php echo $bro->l_tgz[$p["downfmt"]]; ?>)<br />
458<a href="bro_pref.php"><?php __("Configure the file browser"); ?></a><br />
459
460</td></tr></table>
461
462</body>
463</html>
Note: See TracBrowser for help on using the repository browser.