directory-uitlezen

Gesponsorde koppelingen

PHP script bestanden

  1. directory-uitlezen

« Lees de omschrijving en reacties

/*-------------------------------------------------------------------------------------------
>>>>>>>>>>>>>index.php
-------------------------------------------------------------------------------------------*/

Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?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>


/*-------------------------------------------------------------------------------------------
>>>>>>>>>>>>>plugins/handlefile.php
-------------------------------------------------------------------------------------------*/
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?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;
}

?>

/*-------------------------------------------------------------------------------------------
>>>>>>>>>>>>>plugins/handleicon.php
-------------------------------------------------------------------------------------------*/
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?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';
    
    }
}

?>

/*-------------------------------------------------------------------------------------------
>>>>>>>>>>>>>plugins/handlelength.php
-------------------------------------------------------------------------------------------*/
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
<?php
function handlelength($string, $length){
    if(strlen($string) > $length-3){
        return substr($string, 0, $length-1).'...';
    }

    else{
        return $string;
    }
}

?>

/*-------------------------------------------------------------------------------------------
>>>>>>>>>>>>>plugins/handlesize.php
-------------------------------------------------------------------------------------------*/
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
<?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;
}

?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.