On peux a nouveau télécharger un fichier depuis le browser

This commit is contained in:
Alan Garcia 2012-08-26 17:55:41 +00:00
parent b8a4b87061
commit 7399963cfd
5 changed files with 35 additions and 14 deletions

View File

@ -1,15 +1,9 @@
<?php <?php
/* /*
$Id: adm_doadd.php,v 1.8 2006/01/24 05:03:30 joe Exp $
---------------------------------------------------------------------- ----------------------------------------------------------------------
AlternC - Web Hosting System AlternC - Web Hosting System
Copyright (C) 2006 Le réseau Koumbit Inc. Copyright (C) 2000-2012 by the AlternC Development Team.
http://koumbit.org/ https://alternc.org/
Copyright (C) 2002 by the AlternC Development Team.
http://alternc.org/
----------------------------------------------------------------------
Based on:
Valentin Lacambre's web hosting softwares: http://altern.org/
---------------------------------------------------------------------- ----------------------------------------------------------------------
LICENSE LICENSE
@ -25,9 +19,6 @@
To read the license please visit http://www.gnu.org/copyleft/gpl.html To read the license please visit http://www.gnu.org/copyleft/gpl.html
---------------------------------------------------------------------- ----------------------------------------------------------------------
Original Author of file: Benjamin Sonntag
Purpose of file: Create a new member
----------------------------------------------------------------------
*/ */
require_once("../class/config.php"); require_once("../class/config.php");

View File

@ -330,7 +330,12 @@ if ($p["showicons"]) {
echo "<td width=\"28\"><img src=\"icon/".$bro->icon($c[$i]["name"])."\" width=\"16\" height=\"16\" alt=\"\" /></td>"; echo "<td width=\"28\"><img src=\"icon/".$bro->icon($c[$i]["name"])."\" width=\"16\" height=\"16\" alt=\"\" /></td>";
} }
echo "<td><a href=\""; echo "<td><a href=\"";
echo "bro_editor.php?editfile=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R); $canedit = $bro->can_edit($R,$c[$i]["name"]);
if ($canedit) {
echo "bro_editor.php?editfile=".urlencode($c[$i]["name"])."&amp;R=".urlencode($R);
} else {
echo "bro_downloadfile.php?dir=".urlencode($R)."&amp;file=".urlencode($c[$i]["name"]);
}
echo "\">".htmlentities($c[$i]["name"])."</a></td>\n"; echo "\">".htmlentities($c[$i]["name"])."</a></td>\n";
echo " <td>".format_size($c[$i]["size"])."</td>"; echo " <td>".format_size($c[$i]["size"])."</td>";
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>"; 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>";

View File

@ -4,7 +4,7 @@
</table> </table>
</div> <!-- div global --> </div> <!-- div global -->
<?php <?php
if ( $debug_alternc->status ) { if ( isset($debug_alternc) && $debug_alternc->status ) {
$debug_alternc->dump(); $debug_alternc->dump();
} }
?> ?>

View File

@ -741,6 +741,22 @@ class m_bro {
} }
} }
function can_edit($dir,$name) {
global $mem,$err;
$absolute="$dir/$name";
$absolute=$this->convertabsolute($absolute,0);
if (!$absolute) {
$err->raise('bro',_("File not in authorized directory"));
include('foot.php');
exit;
}
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo,$absolute);
if ( substr($mime,0,5)=="text/" || $mime == "application/x-empty") {
return true;
}
return false;
}
/** /**
* Return a HTML snippet representing an extraction function only if the mimetype of $name is supported * Return a HTML snippet representing an extraction function only if the mimetype of $name is supported
@ -769,6 +785,15 @@ class m_bro {
return false; return false;
} }
function download_link($dir,$file){
global $err;
$err->log("bro","download_link");
header("Content-Disposition: attachment; filename=$file");
header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary");
$this->content_send($dir,$file);
}
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/** Echoes the content of the file $file located in directory $R /** Echoes the content of the file $file located in directory $R

View File

@ -80,7 +80,7 @@ class m_log {
function download_link($file){ function download_link($file){
global $err,$mem; global $err,$mem;
$err->log("log","download_link"); $err->log("log","download_link");
header("Content-Disposition: attachment; filename=".$mem->user["login"].".zip"); header("Content-Disposition: attachment; filename=".$mem->user["login"].".zip"); // FIXME: keep the original name file
header("Content-Type: application/force-download"); header("Content-Type: application/force-download");
header("Content-Transfer-Encoding: binary"); header("Content-Transfer-Encoding: binary");
$f=$this->get_logs_directory(); $f=$this->get_logs_directory();