<?
//Explorer PHP By Scorpion
function present($chaine,$mot,$sep)
{
    
$tab=split($sep,$chaine);
    
$rep=FALSE;
    for (
$j=0;$j<count($tab);$j++)
    {
        if (
$tab[$j]==$mot) {$rep=TRUE;break;}
    }
    return
$rep;
}
function
affperm($fichier)
{
    
$perm=fileperms($fichier);
    
$nbr1=substr($perm,-1,1);
    return(
true);
}
function
affperm2($fichier)
{
    
$perm=fileperms($fichier);
    
$nbr1=substr($perm,-1,1);
    
$r="-";$w="-";$x="-";
    if (
$nbr1>=6 and $nbr1<=9)
        
$r="r";
    if (
$nbr1==4 or $nbr1==5 or $nbr1==8 or $nbr1==9)
        
$w="w";
    if (
$nbr1==3 or $nbr1==5 or $nbr1==7 or $nbr1==9)
        
$x="x";
    return
$r." ".$w." ".$x;
}
function
affdate($fichier)
{
    
$datef=filemtime("$fichier");
    if (
date("d/m/Y",$datef)==date("d/m/Y",time()))
    {
        
$datef="Aujourd'hui à".date(" H:i:s",$datef);
    }
    else
    {
        
$datef=date("d/m/Y à H:i:s",$datef);
    }
    return
$datef;
}
function
afftaille($t)
{
    if (
$t>=10000 and $t<1000000)
    {
        
$t=(int)($t/1000);
        
$tlib="$t Ko";
    }
    else if (
$t>1000000 and $t<1000000000)
    {
        
$t=(int)($t/10000);
        
$t=$t/100;
        
$tlib="$t Mo";
    }
    else if (
$t>1000000000)
    {
        
$t=(int)($t/10000000);
        
$t=$t/100;
        
$tlib="$t Go";
    }
    else
    {
        
$tlib="$t Bytes";
    }
    return
$tlib;
}
function
autoinstall($rep)
{
    @
copy("index.php",$rep."/index.php");
}
$tab_ext=array(
        array(
"PHP","#006699","Fichier PHP"),
        array(
"PHPS","red","Code source"),
        array(
"HTM,HTML","#00219A","Fichier HTML"),
        array(
"TXT","#000000","Fichier Texte"),
        array(
"DOC","#0066FF","Fichier Word"),
        array(
"EXE","#6600EE","Fichier exécutable"),
        array(
"ZIP,RAR,TAR,GZ,TGZ","#FF6600","Fichier compressé"),
        array(
"JPG,JPEG,GIF,BMP","#00BBFF","Image"),
        array(
"MPG,MPEG,AVI","#008000","Vidéo"));
if (
$action=="install" and !empty($rep))
{
    if (!@
copy("index.php",$rep."/index.php"))
    {
        echo
"<FONT size=1 face=verdana color=red><B>ATTENTION</B> : ERREUR DANS L'INSTALLATION DU SCRIPT !! VERIFIEZ VOS DROITS SUR LES FICHIERS...</FONT><BR><BR>";
    }
}
echo
"<HTML><HEAD><STYLE>A {TEXT-DECORATION: none}A:visited {TEXT-DECORATION: none}A:hover {TEXT-DECORATION: underline}TD{FONT-FAMILY:verdana;FONT-SIZE:10}BODY{FONT-FAMILY:verdana;FONT-SIZE:10}</STYLE><TITLE>Explorer PHP</TITLE></HEAD><BODY>";
$mydir=dir("."); // récupère le répertoire du script
$mydir->read();
$rep=""; //variable contenant les répertoires
$fic=""; //variable contenant les fichiers
$rep=$rep."<TR height=20><TD><FONT FACE=wingdings size=4>1</FONT></TD><TD><A HREF=\"..\"><FONT color=green>..</FONT></A></TD><TD>&nbsp;</TD></TR>\n";
while(
$entry=$mydir->read()) // on lit chaque fichier ou répertoire jusqu'à ce qu'il n'y en ai plus
{
    
    if ((
$entry!="index.php" and substr($entry,0,1)!="."))
    {
        if (
filetype($entry)=="dir") // on teste si le nom de fichier est un répertoire ou non
        
{
            
$perm=fileperms("$entry");
            
$nbr1=substr($perm,-1,1);
            
$perm=fileperms("$entry/index.php");
            
$nbr2=substr($perm,-1,1);
            if (
filesize("index.php")!=filesize("$entry/index.php") && affperm("$entry"))
            {
                
$link="<A HREF=\"index.php?action=install&rep=$entry\"><FONT color=#0B163D face=wingdings size=4>:</FONT></A>";
            }
            else
            {
                
$link="<FONT FACE=wingdings size=4 color=red>ý</FONT>";
            }
            if (
filesize("index.php")==filesize("$entry/index.php"))
                
$link="";
            
$perm=affperm2($entry);
            
$rep=$rep."<TR height=20><TD><FONT FACE=wingdings size=4>0</FONT></TD><TD><A HREF=\"$entry/\"><FONT color=green>$entry</FONT></A></TD><TD>$link</TD><TD align=center>N.A</TD><TD>&nbsp;</TD><TD>Répertoire</TD><TD>&nbsp;</TD><TD align=center>$perm</TD><TD>&nbsp;</TD><TD>".affdate($entry)."</TD></TR>\n";
        }
        else
        {
            
$tlib=afftaille(filesize($entry)); // convertion de la taille du fichier
            
$extention2=substr($entry,-1,1); // prends le dernier caractère (pour voir si fichier est un backup)
            
$extention=strtoupper(str_replace(".","",strrchr($entry,".")));
            
$couleur="#545A72";
            
$description="Fichier $extention";
            for (
$i=0;$i<count($tab_ext);$i++)
            {
                if (
present($tab_ext[$i][0],$extention,","))
                {
                    
$couleur=$tab_ext[$i][1];
                    
$description=$tab_ext[$i][2];
                    break;
                }
            }
            if (
$extention2=="~")
            {
                
$couleur="#545A72";
                
$description="Fichier Backup";
            }
            
$perm="<FONT FACE=wingdings size=4 color=red>ý</FONT>";
            if (
is_writable("$entry"))
            {
                
$perm="<FONT FACE=wingdings size=4 color=green>þ</FONT>";
            }
            
$perm=affperm2($entry);
            
$fic=$fic."<TR height=20><TD align=center><FONT FACE=wingdings size=4 COLOR=$couleur>2</FONT></TD><TD><A HREF=\"$entry\"><FONT COLOR=$couleur>$entry</FONT></A></TD><TD width=20>&nbsp;</TD><TD><FONT COLOR=$couleur> $tlib</FONT></TD><TD width=20>&nbsp;</TD><TD><FONT COLOR=$couleur>$description</FONT></TD><TD width=20>&nbsp;</TD><TD align=center>$perm</TD><TD width=20>&nbsp;</TD><TD><FONT COLOR=$couleur>".affdate($entry)."</FONT></TD></TR>\n";
        }
    }
}
$mydir->close();
echo
"<TABLE>";
echo
"<TR><TD colspan=3>&nbsp;</TD><TD align=center>Taille</TD><TD>&nbsp;</TD><TD align=center>Description</TD><TD>&nbsp;</TD><TD align=center>Permissions</TD><TD>&nbsp;</TD><TD align=center>Dernier accès</TD></TR>";
echo
"$rep$fic</TABLE></BODY></HTML>"; // on affiche les répertoires, puis les fichiers.
$t=afftaille(diskfreespace("/"));
echo
"<BR><BR><P align=center>.: Explorer PHP | Espace disque libre : $t :.";
?>