source: alternc/branches/franck-desktop/bureau/admin/bro_main.php @ 1803

Revision 1803, 16.0 KB checked in by franck, 6 years ago (diff)

Le bureau ne dépend plus de register_globals (tester en register_globals off et error_reporting E_ALL)
Ajout de jQuery pour le menu et pour les futurs développements JS
Ajout d'une demande de suppression pour les listes mailmans
... je sais plus :)

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 TODO : Voir ??? + Déplacer / Copier
29 ----------------------------------------------------------------------
30*/
31require_once ("../class/config.php");
32include_once ("head.php");
33
34$fields = array (
35        "R"           => array ("request", "string", ""),
36        "formu"       => array ("request", "integer", 0),
37        "nomfich"     => array ("request", "string", ""),
38        "o"           => array ("request", "array", array()),
39        "d"           => array ("request", "array", array()),
40        "actmove"     => array ("request", "string", ""),
41        "actmoveto"   => array ("request", "string", ""),
42        "actrename"   => array ("request", "string", ""),
43        "actdel"      => array ("request", "string", ""),
44        "del_confirm" => array ("request", "string", ""),
45        "cancel"      => array ("request", "string", ""),
46);
47getFields($fields);
48
49$p = $bro->GetPrefs();
50if (!$R && $p["golastdir"])
51{
52        $R = $p["lastdir"];
53}
54
55$R = $bro->convertabsolute($R, 1);
56
57// on fait ?
58if ($formu)
59{
60        switch ($formu)
61        {
62                case 1:  // Créer le répertoire $R.$nomfich
63                        if (!$bro->CreateDir($R, $nomfich))
64                        {
65                                echo $err->errstr();
66                        }
67                        $p = $bro->GetPrefs();
68                break;
69
70                case 6: // Créer le fichier $R.$nomfich
71                        if (!$bro->CreateFile($R,$nomfich))
72                        {
73                                echo $err->errstr();
74                        }
75                        $p = $bro->GetPrefs();
76                        if ($p["createfile"] == 1)
77                        {
78                                $file = $nomfich;
79                                include ("bro_editor.php");
80                                exit();
81                        }
82                break;
83                case 2:  // act vaut Supprimer Copier ou Renommer.
84                        if ($actdel)
85                        {
86                                if ($del_confirm == _("Yes"))
87                                {
88                                        if (!$bro->DeleteFile($d, $R))
89                                        {
90                                                echo $err->errstr();
91                                        }
92                                }
93                                else if (!$cancel)
94                                {
95
96?>
97<h3><?php printf(_("Deleting files and/or directories")); ?></h3>
98<form action="bro_main.php" method="post">
99<input type="hidden" name="formu" value="2" />
100<input type="hidden" name="actdel" value="1" />
101<input type="hidden" name="R" value="<?php echo $R?>" />
102<p class="error"><?php __("WARNING : Confirm the deletion of this files"); ?></p>
103<?php foreach ($d as $file) { ?>
104<p><?php echo stripslashes($file); ?></p>
105<input type="hidden" name="d[]" value="<?php echo htmlentities(stripslashes($file)); ?>" />
106<?php } ?>
107<blockquote>
108        <input type="submit" class="inb" name="del_confirm" value="<?php __("Yes"); ?>" />&nbsp;&nbsp;
109        <input type="submit" class="inb" name="cancel" value="<?php __("No"); ?>" />
110</blockquote>
111</form>
112<?php
113                                        include_once("foot.php");
114                                        die();
115                                }
116                        }
117                        if ($actmove)
118                        {
119                                if (!$bro->MoveFile($d, $R, $actmoveto))
120                                {
121                                        echo $err->errstr();
122                                }
123                        }
124                break;
125                case 4:  // Renommage Effectif...
126                        if (!$bro->RenameFile($R, $o, $d)) // Rename $R (directory) $o (old) $d (new) names
127                        {
128                                echo $err->errstr();
129                        }
130                break;
131                case 3:  // Upload de fichier...
132                        if (!$bro->UploadFile($R))
133                        {
134                                echo $err->errstr();
135                        }
136                break;
137        }
138}
139
140/* Creation de la liste des fichiers courants */
141$c = $bro->filelist($R);
142if ($c === false)
143        $error = $err->errstr();
144
145?>
146<h3><?php __("File browser"); ?></h3>
147<table border="0" width="100%" cellspacing="0">
148<tr><td>
149
150<hr />
151<table width="100%"><tr><td valign="top">
152<a href="bro_main.php?R=/"><?php echo $mem->user["login"]; ?></a>&nbsp;/&nbsp;<?php echo $bro->PathList($R,"bro_main.php") ?><br />
153<?php if ($error) echo "<font color=\"red\">$error</font>"; ?>
154</td><td valign="top" align="right">
155
156<form action="bro_main.php" method="post" name="nn" id="nn">
157<input type="hidden" name="R" value="<?php echo $R; ?>" />
158<table><tr>
159<td><input type="text" class="int" name="nomfich" size="22" maxlength="255" /></td>
160<td><input type="submit" class="inb" value="<?php __("Create"); ?>" /></td>
161</tr><tr><td>
162<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>
163<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>
164</td><td></td></tr></table>
165</form>
166</td></tr>
167</table>
168
169</td></tr>
170<tr><td valign="top">
171
172<?php
173/* Renommer / Copier / Déplacer les fichiers : */
174if ($formu==2 && $actrename && count($d)) {
175  echo "<table cellpadding=\"6\">\n";
176  echo "<form action=\"bro_main.php\" method=\"post\">\n";
177  echo "<input type=\"hidden\" name=\"R\" value=\"$R\" />\n";
178  echo "<input type=\"hidden\" name=\"formu\" value=\"4\" />\n";
179  echo "<tr><th colspan=\"2\">"._("Rename")."</th></tr>";
180  for ($i=0;$i<count($d);$i++) {
181    $d[$i]=ssla($d[$i]);
182    echo "<tr><td><input type=\"hidden\" name=\"o[$i]\" value=\"".$d[$i]."\" />".$d[$i]."</td>";
183    echo "<td><input type=\"text\" class=\"int\" name=\"d[$i]\" value=\"".$d[$i]."\" /></td></tr>";
184  }
185  echo "<tr><td colspan=\"2\" align=\"center\"><input type=\"submit\" class=\"inb\" name=\"submit\" value=\""._("Rename")."\" /></td></tr>";
186  echo "</table></form>\n";
187  echo "<hr />\n";
188}
189
190/* We draw the file list and button bar only if there is files here ! */
191if (count($c)) {
192
193?>
194<form action="bro_main.php" method="post" name="main" id="main">
195<input type="hidden" name="R" value="<?php echo $R; ?>" />
196<input type="hidden" name="formu" value="2" />
197<hr />
198<script type="text/javascript">
199<!--
200document.write("<input type=\"button\" value=\"<?php __("all/none"); ?>\" class=\"inb\" onclick=\"CheckAll();\" />");
201//  -->
202</script>
203<input type="submit" class="inb" name="actdel" value="<?php __("Delete"); ?>" />
204
205<input type="submit" class="inb" name="actrename" value="<?php __("Rename"); ?>" />
206&nbsp;&nbsp;&nbsp;
207<input type="submit" class="inb" name="actmove" value="<?php __("Move"); ?>" />&nbsp;:&nbsp;<input type="text" class="int" name="actmoveto" value="" />
208<script type="text/javascript">
209<!--
210document.write("<input type=\"button\" name=\"bff\" onclick=\"browseforfolder('main.actmoveto');\" value=\" ... \" class=\"inb\" />");
211//  -->
212</script>
213     <hr />
214
215
216
217<?php
218     switch ($p["listmode"]) {
219case 0:
220/* AFFICHE 1 COLONNE DETAILLEE */
221reset($c);
222echo "<table width=\"100%\" style=\"border: 0px\" cellpadding=\"0\" cellspacing=\"0\">";
223$col=1;
224for($i=0;$i<count($c);$i++) {
225$col=3-$col;
226echo "<tr class=\"lst$col\">\n";
227if ($c[$i]["type"]) {
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/".$bro->icon($c[$i]["name"])."\" width=\"16\" height=\"16\" alt=\"\" /></td>";
231}
232echo "<td><a href=\"";
233echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
234echo "\">".htmlentities($c[$i]["name"])."</a></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>".$bro->mime($c[$i]["name"])."</td>";
239}
240$vu=$bro->viewurl($R,$c[$i]["name"]);
241if ($vu) {
242echo "<td><a href=\"$vu\">"._("View")."</a>";
243} else {
244echo "<td>&nbsp;";
245}
246echo "</td>\n";
247} else {           // DOSSIER :
248echo "  <td width=\"28\"><input type=\"checkbox\" class=\"inc\" name=\"d[]\" value=\"".htmlentities($c[$i]["name"])."\" /></td>";
249if ($p["showicons"]) {
250echo "<td width=\"28\"><img src=\"icon/folder.png\" width=\"16\" height=\"16\" alt=\"\" /></td>";
251}
252echo "<td><b><a href=\"";
253echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
254echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
255echo "  <td>".format_size($c[$i]["size"])."</td>";
256echo "<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>";
257if ($p["showtype"]) {
258echo "<td>Dossier</td>";
259}
260echo "<td>&nbsp;";
261echo "</td>\n";
262}
263
264echo "</tr>\n";
265}
266echo "</table>";
267break;
268case 1:
269/* AFFICHE 2 COLONNES COURTES */
270reset($c);
271echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
272echo "<tr><td valign=\"top\" width=\"50%\">";
273echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
274$col=1;
275for($i=0;$i<round(count($c)/2);$i++) {
276$col=3-$col;
277echo "<tr class=\"lst$col\">\n";
278if ($c[$i]["type"]) {
279echo "  <td width=\"28\"><input type=\"checkbox\" class=\"inc\" name=\"d[]\" value=\"".htmlentities($c[$i]["name"])."\" /></td><td><a href=\"";
280echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
281echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
282echo "  <td>".format_size($c[$i]["size"])."</td><td>";
283$vu=$bro->viewurl($R,$c[$i]["name"]);
284if ($vu) {
285echo "<td><a href=\"$vu\">"._("V")."</a>";
286} else {
287echo "<td>&nbsp;";
288}
289echo "</td>\n";
290} else {
291echo "  <td width=\"28\"><input type=\"checkbox\" class=\"inc\" name=\"d[]\" value=\"".htmlentities($c[$i]["name"])."\" /></td><td><b><a href=\"";
292echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
293echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
294echo "  <td>".format_size($c[$i]["size"])."</td><td>";
295echo "&nbsp;";
296echo "</td>\n";
297}
298
299echo "</tr>\n";
300}
301echo "</table>";
302echo "</td><td valign=\"top\" width=\"50%\">";
303echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
304$col=1;
305for($i=round(count($c)/2);$i<count($c);$i++) {
306$col=3-$col;
307echo "<tr class=\"lst$col\">\n";
308if ($c[$i]["type"]) {
309echo "  <td width=\"28\"><input type=\"checkbox\" class=\"inc\" name=\"d[]\" value=\"".htmlentities($c[$i]["name"])."\" /></td><td><a href=\"";
310echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
311echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
312echo "  <td>".format_size($c[$i]["size"])."</td><td>";
313$vu=$bro->viewurl($R,$c[$i]["name"]);
314if ($vu) {
315echo "<td><a href=\"$vu\">"._("V")."</a>";
316} else {
317echo "<td>&nbsp;";
318}
319echo "</td>\n";
320} else {
321echo "  <td width=\"28\"><input type=\"checkbox\" class=\"inc\" name=\"d[]\" value=\"".htmlentities($c[$i]["name"])."\" /></td><td><b><a href=\"";
322echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
323echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
324echo "  <td>".format_size($c[$i]["size"])."</td><td>";
325echo "&nbsp;";
326echo "</td>\n";
327}
328
329echo "</tr>\n";
330}
331echo "</table>";
332echo "</td></tr>";
333echo "</table>";
334break;
335case 2:
336/* AFFICHE 3 COLONNES COURTES */
337reset($c);
338echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
339echo "<tr><td valign=\"top\" width=\"33%\">";
340echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
341$col=1;
342for($i=0;$i<round(count($c)/3);$i++) {
343$col=3-$col;
344echo "<tr class=\"lst$col\">\n";
345if ($c[$i]["type"]) {
346echo "  <td width=\"28\"><input type=\"checkbox\" class=\"inc\" name=\"d[]\" value=\"".htmlentities($c[$i]["name"])."\" /></td><td><a href=\"";
347echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
348echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
349echo "  <td>".format_size($c[$i]["size"])."</td><td>";
350$vu=$bro->viewurl($R,$c[$i]["name"]);
351if ($vu) {
352echo "<td><a href=\"$vu\">"._("V")."</a>";
353} else {
354echo "<td>&nbsp;";
355}
356echo "</td>\n";
357} else {
358echo "  <td width=\"28\"><input type=\"checkbox\" class=\"inc\" name=\"d[]\" value=\"".htmlentities($c[$i]["name"])."\" /></td><td><b><a href=\"";
359echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
360echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
361echo "  <td>".format_size($c[$i]["size"])."</td><td>";
362echo "&nbsp;";
363echo "</td>\n";
364}
365
366echo "</tr>\n";
367}
368echo "</table>";
369echo "</td><td valign=\"top\" width=\"33%\">";
370echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
371$col=1;
372for($i=round(count($c)/3);$i<round(2*count($c)/3);$i++) {
373$col=3-$col;
374echo "<tr class=\"lst$col\">\n";
375if ($c[$i]["type"]) {
376echo "  <td width=\"28\"><input type=\"checkbox\" class=\"inc\" name=\"d[]\" value=\"".htmlentities($c[$i]["name"])."\" /></td><td><a href=\"";
377echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
378echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
379echo "  <td>".format_size($c[$i]["size"])."</td><td>";
380$vu=$bro->viewurl($R,$c[$i]["name"]);
381if ($vu) {
382echo "<td><a href=\"$vu\">"._("V")."</a>";
383} else {
384echo "<td>&nbsp;";
385}
386
387echo "</td>\n";
388} else {
389echo "  <td width=\"28\"><input type=\"checkbox\" class=\"inc\" name=\"d[]\" value=\"".htmlentities($c[$i]["name"])."\" /></td><td><b><a href=\"";
390echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
391echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
392echo "  <td>".format_size($c[$i]["size"])."</td><td>";
393echo "&nbsp;";
394echo "</td>\n";
395}
396
397echo "</tr>\n";
398}
399echo "</table>";
400echo "</td><td valign=\"top\" width=\"33%\">";
401echo "<table width=\"100%\" border=0 cellpadding=0 cellspacing=0>";
402$col=1;
403for($i=round(2*count($c)/3);$i<count($c);$i++) {
404$col=3-$col;
405echo "<tr class=\"lst$col\">\n";
406if ($c[$i]["type"]) {
407echo "  <td width=\"28\"><input TYPE=checkbox class=\"inc\" name=\"d[]\" value=\"".htmlentities($c[$i]["name"])."\" /></td><td><a href=\"";
408echo "bro_editor.php?file=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
409echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
410echo "  <td>".format_size($c[$i]["size"])."</td><td>";
411$vu=$bro->viewurl($R,$c[$i]["name"]);
412if ($vu) {
413echo "<td><a href=\"$vu\">"._("View")."</a>";
414} else {
415echo "<td>&nbsp;";
416}
417echo "</td>\n";
418} else {
419echo "  <td width=\"28\"><input TYPE=checkbox class=\"inc\"  name=\"d[]\" value=\"".htmlentities($c[$i]["name"])."\" /></td><td><b><a href=\"";
420echo "bro_main.php?R=".urlencode($R."/".$c[$i]["name"]);
421echo "\">".htmlentities($c[$i]["name"])."/</a></b></td>\n";
422echo "  <td>".format_size($c[$i]["size"])."</td><td>";
423echo "&nbsp;";
424echo "</td>\n";
425}
426
427echo "</tr>\n";
428}
429echo "</table>";
430echo "</td></tr>";
431echo "</table>";
432break;
433}
434?>
435     </form>
436<?php
437         } // is there any files here ?
438else {
439  echo "<p class=\"error\">"._("No files in this folder")."</p>";
440}
441?>
442
443     </td></tr>
444     <tr><td colspan="2">
445
446
447     <form action="bro_main.php" enctype="multipart/form-data" method="post">
448     <input type="hidden" name="R" value="<?php echo $R; ?>" />
449     <input type="hidden" name="formu" value="3" />
450     <hr />
451     <?php __("Import this file"); ?>&nbsp;&nbsp;<input class="int" name="userfile" type="file" />
452     <input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
453     <input type="submit" class="inb" value="<?php __("Send"); ?>" />
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?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<?php include_once("foot.php"); ?>
Note: See TracBrowser for help on using the repository browser.