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

Revision 2093, 15.9 KB checked in by anarcat, 5 years ago (diff)

hook in the extract action.
Closes: #1043

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