Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2011
    Messaggi
    60

    Nascondere un file in una directory

    Ciao a tutti,
    ho realizzato uno script che permette di visualizzare tutti i file in una cartella e altre funzioni.
    Vorrei però che non visualizzasse i file con estensione ".mz", purtroppo non ho idea di come fare.

    Qualcuno può darmi una mano?
    Questo è lo script:

    Codice PHP:
    $directory "../dir_priv" ;
    function 
    dir_list($directory FALSE) { 
      
    $dirs= array(); 
      
    $files = array(); 
      if (
    $handle opendir("./" $directory)) { 
        while (
    $file readdir($handle)) { 
          if (
    is_dir("./{$directory}/{$file}")) { 
            if (
    $file != "." $file != ".."$dirs[] = $file
          } else { 
            if (
    $file != "." $file != ".."$files[] = $file
         } 
      } 

    closedir($handle); 
    reset($dirs); 
    sort($dirs); 
    reset($dirs); 
    reset($files); 
    sort($files); 
    reset($files); 
    echo 
    "\n

    "

    while(list(
    $key$value) = each($files)) { 
    // qui puoi fare l'operazione su "$directory.$value", p.es.: 
       
     
    echo"
     <table border='0' cellpadding='5' id='tab_file'> 
      <tr>
      <td width='10%'>"

    $path_parts pathinfo($directory.$value);
    $ext $path_parts['extension'];
    echo 
    "
    [img]../../img/file_type/"
    .$ext.".png[/img]</td>
    <td width='20%'>[b]
    {$value}[/b]

    <p style='color:#666; padding:2px; margin:0;'>"
    filesize($directory.$value). " bytes</p>
    </td>"
    ;
    echo 
    "<td width='30%'>".
    $var=fopen("dir_priv/".$value.".mz","r");
    $leggi=fread($var,filesize("dir_priv/".$value.".mz"));
    $sss=nl2br($leggi);
    fclose($var);
    echo 
    $sss;
    "</td>";
      echo
      
    "<td width='25%'>";
    $path_parts pathinfo($directory.$value);
    $ext $path_parts['extension']; 

    $ext_insieme = array('com''htm''exe''html' 'shtml' 'php' 'asp' 'ade' 'adp' 'bas' 'bat' 'chm' 'cmd' 'com' 'cpl' 'crt' 'hlp' 'hta' 'inf' 'ins' 'isp' 'js' 'jse' 'lnk' 'mdb' 'mde' 'msc' 'msi' 'msp' 'mst' 'pcd' 'pif' 'reg' 'scr' 'sct' 'shb' 'shs' 'url' 'vb' 'vbe' 'vbs' 'wsc' 'wsf' 'wsh' '286' '386' 'vxd' 'dll' 'ocx' 'vbx' 'drv' 'ovl' 'scf' 'sys' 'qtx' 'fot' 'rom' 'class' 'job' 'htt' 'wll' 'dot' 'wiz' 'xla' 'xll' 'xlt' 'mdt' 'mdz' 'pot' 'ppa' 'wpt' 'wpm' 'mht'); 

    if (
    in_array($ext$ext_insieme)) { 
        echo 
    "<a href='#' class='button'><table border='0' cellpadding='0'>
      <tr>
        <td>[img]../../img/alert.png[/img]</td>
        <td>Il file non è sicuro</td>
      </tr>
    </table>
    </a>"


    else { 
        echo 
    "<a href='#' class='button'><table border='0' cellpadding='0'>
      <tr>
        <td>[img]../../img/check.png[/img]</td>
        <td>Il file è sicuro</td>
      </tr>
    </table>
    </a>"

    }  
    "</td>";



      
      echo 
    "<td width='5%'><a title='Download'  href='force-download.php?file={$directory}{$value}'>
      [img]../../img/download.png[/img]
    </a></td>
    <td width='5%'>
     <a title='Elimina' href='elimina.php?file=
    {$directory}{$value}'> 
    [img]../../img/delete.png[/img]
    </a> 
    </td>
      "
    ;

     echo

      </tr>
      </table>\n"
    ; } echo "</p>\n"; } dir_list("dir_priv/"); 

  2. #2
    Utente di HTML.it L'avatar di Virus_101
    Registrato dal
    Sep 2008
    Messaggi
    2,497
    Usa htaccess

  3. #3
    Utente di HTML.it
    Registrato dal
    Jan 2011
    Messaggi
    60
    Originariamente inviato da Virus_101
    Usa htaccess
    E cosa dovrei scrivere nel file htaccess?

  4. #4
    Utente di HTML.it L'avatar di Virus_101
    Registrato dal
    Sep 2008
    Messaggi
    2,497
    un esempio potrebbe essere questo.

    Order deny,allow

    <FilesMatch "\.mk$">
    Deny from all
    Allow from localhost
    </FilesMatch>

    Poi nel caso puoi fare degli htaccess che eseguano il redirect ad una pagina oscurando completamente il tutto

    ErrorDocument 403 http://www.yoursiteurl.com/subpath
    ErrorDocument 404 http://www.yoursiteurl.com/subpath

    order deny,allow

    <FilesMatch "\.mk$">
    Deny from all
    Allow from localhost
    </FilesMatch>

    Edit : questo vuol dire che nessuno al di fuori dei tuoi script puo accedere a tali files passando da apache. Mentre il tuo script puo' sempre accedevi e nel caso decidere se lasciar eil file per il download o quellochesia.

    Fatto questo lavori a lvl server sfruttando quanto apache ti mette a disposizione

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.