hallo,
Ik ben bezig met een directory lister, om zo een autoindex te creeren, maar ik krijg nog steeds 1 foutmelding waar ik niet uitkom. er wordt een Unfefinded variable aangegeven, maar ik begrijp niet wat er mis is.
dit is mijn code.
kunnen jullie zien wat er mis is??
ik heb aangegeven op welke regel de fout wordt gegeven in het script.
achter de regel staat '// op deze regel wordt een foutmelding gegeven'
Notice: Undefined variable: result in ********\index.php on line 73
Ik ben bezig met een directory lister, om zo een autoindex te creeren, maar ik krijg nog steeds 1 foutmelding waar ik niet uitkom. er wordt een Unfefinded variable aangegeven, maar ik begrijp niet wat er mis is.
dit is mijn code.
code:
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
| <?
function getIcon($ext) {
switch ($ext) {
case "css":
$icon = "stylesheet.png";
break;
case "ttf":
case "fon":
$icon = "font.png";
break;
case "txt":
case "rtf":
$icon = "text.png";
break;
case "tar":
case "zip":
$icon = "archive.png";
break;
case "png":
case "gif":
case "jpg":
$icon = "picture.png";
break;
// scripts
case "js":
case "tpl":
case "inc":
case "jsp":
case "asp":
case "php":
case "php3":
$icon = "script.png";
break;
// office type documents
case "doc":
$icon = "word.png";
break;
case "xls":
$icon = "excel.png";
break;
case "ppt":
$icon = "powerpoint.png";
break;
case "mdb":
case "db":
$icon = "database.png";
break;
case "pdf":
$icon = "acrobat.png";
break;
case "":
$icon = "system.png";
break;
default:
$icon = "01.png";
break;
}
return $icon;
}
// GetDir helper function
function GetDir($path) {
$handle = opendir($path);
while ($file = readdir($handle)) {
if ($file != "." && $file != "..") {
$ft = filemtime("$path/$file");
$result[count($result)] = "$ft|$file"; // op deze regel wordt een foutmelding gegeven
}
}
closedir($handle);
// reverse sort and then strip filetime
if (count($result)>0) rsort($result);
for ($i = 0; $i < count($result); $i++) {
$date_file = explode("|", $result[$i]);
$result[$i] = $date_file[1];
}
return $result;
}
$PHP_SELF = $_SERVER['PHP_SELF'];
$tree = "// directory tree generated on " . strftime("%c") . "\r\n\r\n";
$script_path = substr($PHP_SELF, 0, strrpos($PHP_SELF, "/"));
$script_dir = substr($script_path, strrpos($script_path, "/")+1);
function processDir($path) {
global $tree;
$nesting = count(explode("/", $path));
// list folders
$arr = GetDir($path);
if (count($arr)==0) return;
while (list(, $file) = each($arr)) {
if (is_dir("$path/$file")) {
global $script_dir;
if ($script_dir != $file) {
$tree .= "f$nesting=f".($nesting-1).".af(\"$file\");\r\n";
processDir("$path/$file");
}
}
}
// list files
reset($arr);
while (list(, $file) = each($arr)) {
if (is_file("$path/$file")) {
$folder = "f" . ($nesting - 1);
$ext = strtolower(substr(strrchr($file, "."), 1));
$icon = getIcon($ext);
$tree .= "$folder.al(\"$file\", \"$path/$file\", \"$icon\");\r\n";
}
}
}
// our most humble template mechanism...
$filename = "index.tpl";
if (file_exists($filename)) {
$handle = fopen($filename, "r");
if ($handle) {
$html = fread($handle, filesize($filename));
fclose($handle);
}
}
processDir(".."); // the magic function!
// show parent dir path (relative to script path)
$dir = substr($script_path, 0, strrpos($script_path, "/"));
$html = str_replace("\$title", "$dir/", $html);
echo str_replace("\$tree", $tree, $html);
?> |
kunnen jullie zien wat er mis is??
ik heb aangegeven op welke regel de fout wordt gegeven in het script.
achter de regel staat '// op deze regel wordt een foutmelding gegeven'
Notice: Undefined variable: result in ********\index.php on line 73
[ Voor 43% gewijzigd door peter007 op 08-06-2005 00:21 ]