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

Revision 1741, 15.2 KB checked in by anarcat, 6 years ago (diff)

check for errors in file browser handlers, see #68

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