[b][u]index.php[/u][/b]


<?php 
error_reporting(E_ALL); 
set_time_limit(0); 
ob_implicit_flush(); 
/* 
    Config variabelen 
*/ 
$cfg['plugins']='plugins/'; //plugins directory 
$cfg['root']='/public_html'; // De begin directory 
$cfg['dir_t']=''; 
$cfg['dir']=$cfg['root']; 
$cfg['notshow']=array(); 
$cfg['length_file']=40; //De uitleg van een bestand word afgekapt achter 
/* 
    Plugins laden 
*/ 
$plugins=scandir($cfg['plugins']); 
$c_plugins=count($plugins); 
for($a=0;$a<$c_plugins;$a++){ 
    if($plugins[$a] != '.' && $plugins[$a] != '..' && is_file($cfg['plugins'].$plugins[$a])){ 
        include($cfg['plugins'].$plugins[$a]); 
    } 
} 
/* 
    ?dir behandelen 
*/ 
If(isset($_GET['dir'])){ 
    $parts=explode('.', $_GET['dir']); 
    $ext=strtolower($parts[count($parts)-1]); 
    if(is_dir($cfg['root'].'/'.$_GET['dir'])  && substr_count($_GET['dir'], '../') == 0 ){ 
        $cfg['dir']=$cfg['root'].'/'.$_GET['dir']; 
        $cfg['dir']=str_replace('//', '/', $cfg['dir']); 
        $cfg['dir_t']=$_GET['dir']; 
        $cfg['dir_t']=str_replace('//', '/', $cfg['dir_t']); 
    } 
    elseif(is_file($cfg['root'].'/'.$_GET['dir']) && substr_count($_GET['dir'], '../') == 0){ 
        header('Location: /'.$_GET['dir']); 
    } 
    else{ 
        $canthandle=$_GET['dir']; 
    } 
} 
/* 
    Directory ophalen 
*/ 
$files=scandir($cfg['dir']); 
$count=count($files); 
$b=0; 
if($count == 2){ 
    unset($files); 
    $files[]='..'; 
    $files[]=''; 
    $count = 2; 
} 
for($a=0;$a<$count;$a++){ 
    if($files[$a] == '..'){ 
        $higher_level=TRUE; 
    } 
    elseif($files[$a] != '.' && !in_array($cfg['dir'].'/'.$files[$a], $cfg['notshow'])){ 
        $files_g[]=$files[$a]; 
        $b++; 
    } 
} 
natcasesort($files_g); 
unset($files); 
foreach($files_g as $file){ 
    if($file != ''){ 
        if(is_dir($cfg['dir'].'/'.$file)){ 
            $dirs[]=array($file, handlesize($cfg['dir'].'/'.$file), 'Map', date('d/m/Y H:i', filemtime($cfg['dir'].'/'.$file))); 
        } 
        else{ 
            $files[]=array($file, handlesize($cfg['dir'].'/'.$file, 1), handlelength(handledescriptrion($file), $cfg['length_file']), date('d/m/Y H:i', filemtime($cfg['dir'].'/'.$file))); 
        } 
    } 
} 
/* 
    Html headers 
*/ 
?> 
<html> 
    <head> 
        <title><?=$cfg['dir_t'];?></title> 
        <style type="text/css"> 
        body{ 
            background: #F7F7F7; 
        } 
        body,td{ 
            color: #000000; 
            margin: 0px; 
            font-family: Tahoma; 
            font-size: 11px; 
        } 
        A:link  { 
            color : #000000; 
            text-decoration: none; 
        } 
        A:visited  { 
            color : #000000; 
            text-decoration: none; 
        } 
        A:hover  { 
            color : #000000; 
            text-decoration: none; 
        } 
        A:active  { 
            color : #000000; 
            text-decoration: none; 
        } 
        img{ 
            border: 0px;     
        } 
        td.title{ 
            border: 1px solid #F7F7F7; 
        } 
        </style> 
    </head> 
<body> 


 
<table width="100%" cellspacing="0" cellpadding="0"> 
<tr><td bgcolor="#F3F3F3" style="height: 40px;padding-left: 5px;" valign="middle"> 
<a href="javascript:history.back()" title="Vorige"><img src="img/vorige.png" alt="Vorige"></a>&nbsp;&nbsp;&nbsp;&nbsp 
<a href="javascript:history.next()" title="Volgende"><img src="img/volgende.png" alt="Volgende"></a>&nbsp;&nbsp;&nbsp;&nbsp 
<?php 
    if(isset($higher_level)){ 
        $parts=explode('/', $cfg['dir']); 
        $to=''; 
        for($a=0;$a<count($parts)-1;$a++){ 
            $to.='/'.$parts[$a]; 
        } 
        $to=str_replace('//', '/', $to); 
        $to=str_replace($cfg['root'].'/', '', $to); 
        if(empty($_GET['dir']))$_GET['dir']=''; 
        if($to != '/' && $_GET['dir'] != '' && $to != ''){ 
            if($to == $cfg['root']){ 
                $to=''; 
            } 
                echo '<a href="?dir='.$to.'" title="omhoog"><img src="img/omhoog.png" alt="omhoog"></a>'; 
        } 
        else{ 
            echo '<img src="img/omhoog_dark.png" alt="omhoog">'; 
        } 
    } 
    else{ 
        echo '<img src="img/omhoog_dark.png" alt="omhoog">'; 
    }     
    if(isset($canthandle)){ 
        echo '<br>Er is een fout opgetreden bij het openen van '.$canthandle; 
    }     
?> 
</td></tr> 
</table> 
<?php 
/* 
    Directory echoen 
*/ 
$files=array_merge((isset($dirs))?$dirs:array(), (isset($files))?$files:array()); 
$count=count($files); 
    for($a=0;$a<$count;$a++){ 
            echo handlefile($files[$a], $a, $count); 
    } 

/* 
    Einde van html 
*/     
?> 
</body> 
</html> 
 

[b][u]plugins/handlefile.php[/u][/b]

 
<?php 
function handlefile($file, $a, $count){ 
    global $cfg; 
    $return=''; 
    if($a == 0){ 
        $return.='<table cellspacing="0" cellpadding="0" align="left" width="100%">'."\n"; 
        $return.='<tr><td colspan="2" width="40%" bgcolor="#EBEADB" class="title">Naam</td><td bgcolor="#EBEADB" class="title" width="15%">Grootte</td><td bgcolor="#EBEADB" class="title" width="20%">Type</td><td bgcolor="#EBEADB" class="title" width="25%">Gewijzigd op</td></tr>'."\n"; 
    } 
    if($file == ''){ 
        echo ''; 
    } 
    else{ 
        $return.='<tr><td width="1%" bgcolor="#F7F7F7"><a href="?dir='.$cfg['dir_t'].'/'.$file[0].'"><img src="'.handleicon($cfg['dir'].'/'.$file[0]).'"></a></td><td bgcolor="#F7F7F7">&nbsp;<a href="?dir='.$cfg['dir_t'].'/'.$file[0].'">'.$file[0].'</a></td><td bgcolor="#FFFFFF">'.remake($file[1]).'</td><td bgcolor="#FFFFFF">'.$file[2].'</td><td bgcolor="#FFFFFF">'.$file[3].'</td></tr>'."\n"; 
    } 
    if($a == $count-1){ 
        $return.='</table>'."\n";     
    } 
    return $return; 
} 
?> 

[b]
[u]plugins/handleicon.php[/u][/b]

 
<?php 
$icons = array(); 
$icons['php'] = array('php',''); 
$icons['css'] = array('ini', 'Document met trapsgewijs opmaakmodel'); 
$icons['jpg'] = array('jpg', 'JPEG-afbeelding'); 
$icons['jpeg'] = array('jpg', 'JPEG-afbeelding'); 
$icons['db'] = array('db', ''); 
$icons['dll'] = array('db', ''); 
$icons['ttf'] = array('ttf', ''); 
$icons['txt'] = array('txt', 'Tekstdocument'); 
$icons['log'] = array('txt', 'Tekstdocument'); 
$icons['png'] = array('png', 'PNG-afbeelding'); 
$icons['gif'] = array('png', 'GIF-afbeelding'); 
$icons['zip'] = array('zip', 'WinZip-bestand'); 
$icons['wmv'] = array('mpg', 'Audio-/videobestand van Windows Media'); 
$icons['exe'] = array('exe', 'Toepassing'); 
$icons['js'] = array('js', 'JScript Script File'); 
$icons['htm'] = array('html', ''); 
$icons['html'] = array('html', ''); 
$icons['htaccess'] = array('ini', ''); 
$icons['ini'] = array('ini', 'Configuratie-instellingen'); 
$icons[''] = array('folder', ''); 
function handledescriptrion($file){ 
    global $icons; 
    $parts=explode('.', $file); 
    $ext=strtolower($parts[count($parts)-1]); 
    if(isset($icons[$ext]) && $icons[$ext][1] != ''){ 
        return $icons[$ext][1]; 
    } 
    else{ 
        return ucfirst($ext).'-bestand'; 
    } 
} 
function handleicon($file){ 
    global $icons; 
    $parts=explode('.', $file); 
    $ext=strtolower($parts[count($parts)-1]); 
    if(isset($icons[$ext]) && !is_dir($file)){ 
        return 'img/'.$icons[$ext][0].'.png'; 
    } 
    elseif(is_dir($file)){ 
        return 'img/folder.png'; 
    } 
    else{ 
        return 'img/unknow.png'; 
     
    } 
} 
?> 


[b][u]plugins/handlelength.php[/u][/b]


<?php 
function handlelength($string, $length){ 
    if(strlen($string) > $length-3){ 
        return substr($string, 0, $length-1).'...'; 
    } 
    else{ 
        return $string; 
    } 
} 
?> 


[b][u]plugins/handlesize.php[/u][/b]

  
<?php 
function remake($size){ 
    if(is_numeric($size)){ 
        if($size < 1024){ 
            $size=$size.' b'; 
        } 
        elseif($size < 1048576){ 
            $size=round($size/1024, 1).' Kb'; 
        } 
        elseif($size < 1073741824){ 
            $size=round($size/1048576, 2).' Mb'; 
        } 
        elseif($size < 1099511627776){ 
            $size=round($size/1073741824, 3).' Gb'; 
        } 
        $size=str_replace('.', ',', $size); 
    } 
    return $size; 
}     
function handlesize($file, $isint=0){ 
    if(is_file($file)){ 
        $size=(float) (filesize($file)); 
    } 
    elseif(is_dir($file)){ 
        $files=scandir($file); 
        $c_files=0; 
        $c_dirs=0; 
        for($a=0;$a<count($files);$a++){ 
            if($files[$a] != '.' && $files[$a] != '..'){ 
                if(is_file($file.'/'.$files[$a])){ 
                    $c_files++; 
                } 
                else{ 
                    $c_dirs++; 
                } 
            } 
        } 
        $size='('.$c_dirs.' mappen en '.$c_files.' bestanden)'; 
    } 
    if(is_numeric($size) && $isint==0){ 
        $size=remake($size); 
    } 
        return $size; 
} 
?> 
 