1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
<?php
define("startpath",'C://');//le racine
if(isset($_GET['file']))
{
$file=htmlentities(file_get_contents(rawurldecode($_GET['file'])));
echo "<pre>".$file."</pre>";
}
else
{
if(isset($_GET['root'])&&$_GET['root']!='')
{
$str=$_GET['root'];
$cdir= getdirs($str);
echo '<a href=?root='.substr($str,0,-2).' >Previous...</a><br>';
}else
{
$cdir=startpath;
}
$directories = glob($cdir."*",GLOB_ONLYDIR);
foreach ($directories as $key => $dir)
{
if ($dir != 'objets' && $dir !='img')
echo sprintf("<a href=?root=%s%s>[%s]</a><br>",$str,dec_hex($key,2),basename($dir));
}
$directories = glob($cdir."*.*");
foreach ($directories as $dir)
{
if ($dir != 'liste_fichiers.php' && $dir !='img')
echo sprintf("<a href=?root=%s&file=%s>%s</a><br>",$str,rawurlencode($dir),basename($dir));
}
}
function getdirs($inp)
{
$filter=startpath;
for ($i=0;$i<strlen($inp);$i+=2)
{$rv=hexdec(substr($inp,$i,2));
$dir= glob($filter."*",GLOB_ONLYDIR);
$filter=$dir[$rv]."/";
}
return $filter;
}
function dec_hex($inps,$ln=0)
{
$str=str_repeat('x',$ln);
for($i=strlen($str); $i>0; $i--)
{
$str[$i-1]=dechex($inps & 15);
$inps>>=4;
}
return $str;
}
?> |
Partager