|
Le but serai de rajouté dans le properties.php3 lorsque l'on a les propriétés d'un fichier un bouton en-bas pour le télécharger
Voici le code du fichier
<html>
<head>
<title>Propriétés</title>
</head>
<body>
<?php
/************************************
Auteur : Hugo ETIEVANT
          2003-2004
http://cyberzoide.developpez.com/php4/file/
***********************************/
require_once("config.php3");
/* extraction taille totale d'un dossier,
  et calcul du nombre de fichiers et de
  dossiers contenus */
function getSize($base) {
  global $nfile, $ndir;
  $size = 0;
  /* ouverture */
  if($dir = opendir($base)) {
    /* listage */
    while($entry = readdir($dir)) {
       /* protection contre boucle infini */
       if(!in_array($entry, array(".",".."))) {
         /* cas dossier, récursion */
        if(is_dir($base."/".$entry)) {
           $size += getSize($base."/".$entry);
            $ndir++;
          /* cas fichier */
         } else {
           $size += filesize($base."/".$entry);
            $nfile++;
         }
       }
     }
     /* fermeture */
     closedir($dir);
  }
  return $size;
}
/* dossier */
function printDir() {
  global $entry, $nfile, $ndir;
 Â
  /* extraction infos */
  $nfile = 0;
  $ndir = 0;
  $entry = rawurldecode($entry);
  $n = explode("/", $entry);
  $name = $n[count($n)-1];
  $type = assocType(filetype($entry));
  $date = date("d/m/Y H:i:s", filemtime($entry));
  $size = formatSize(getSize($entry));
  $perms = mfunGetPerms(fileperms($entry));
 Â
  /* affichage */
  echo "<table width=\"100%\" height=\"100%\"
  border=\"1\" bordercolor=\"gray\"
  cellspacing=\"0\" cellpadding=\"5\">
  <tr><td align=\"center\" valign=\"middle\"><table>
  <tr><td><img src=\"ico-dossier.gif\" alt=\"Dossier\" /></td><td>$name</td></tr>
  <tr><td>Type : </td><td>$type</td></tr>
  <tr><td>Emplacement : </td><td>$entry</td></tr>
  <tr><td>Taille : </td><td>$size</td></tr>
  <tr><td>Contenu : </td><td>$nfile fichiers, $ndir dossiers</td></tr>
  <tr><td>Dernière modification : </td><td>$date</td></tr>
  <tr><td>Attributs : </td><td>$perms</td></tr>
  </table></td></tr>
  </table>";
}
/* fichier */
function printFile() {
  global $entry;
 Â
  /* extraction infos */
  $entry = rawurldecode($entry);
  $n = explode("/", $entry);
  $name = $n[count($n)-1];
  $type = assocType(filetype($entry));
  $date = date("d/m/Y H:i:s", filemtime($entry));
  $size = formatSize(filesize($entry));
  $perms = mfunGetPerms(fileperms($entry));
  $access = date("d/m/Y", fileatime($entry));
  $t = explode(".", $entry);
  $ext = assocExt($t[count($t)-1]);
 Â
  /* affichage */
  echo "<table width=\"100%\" height=\"100%\"
  border=\"1\" bordercolor=\"gray\"
  cellspacing=\"0\" cellpadding=\"5\">
  <tr><td align=\"center\" valign=\"middle\"><table>
  <tr><td><img src=\"ico-none.gif\" alt=\"Fichier\" /></td><td>$name</td></tr>
  <tr><td>Type : </td><td>$type</td></tr>
  <tr><td>Emplacement : </td><td>$entry</td></tr>
  <tr><td>Taille : </td><td>$size</td></tr>
  <tr><td>Extention : </td><td>$ext</td></tr>
  <tr><td>Dernière modification : </td><td>$date</td></tr>
  <tr><td>Dernier accès : </td><td>$access</td></tr>
  <tr><td>Attributs : </td><td>$perms</td></tr>
  <tr><td>Télécharger ce fichier : </td><td><a href="/veryrestrictedarea/$name">Cliquez-ici C'EST ICI LE PROBLEME</a></td></tr>
  </table></td></tr>
  </table>";
}
  </table></td></tr>
  </table>";
}
switch($type) {
  case 'dir' : printDir(); break;
  case 'file' : printFile(); break;
}
?>
</body>
</html>
|