bestands-systeem
----------- opendir.php ----------------
Code (php)
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
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
<html><head><link rel="stylesheet" type="text/css" href="vdveen.css"></head><body>
<script>
var limit="0:15"
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
function beginrefresh(){
if (!document.images)
return
if (parselimit==1)
window.location.reload()
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
else
setTimeout("beginrefresh()",1000)
}
}
window.onload=beginrefresh
//-->
</script>
<?php
// vars
$dir = "upload/";
chmod($dir, 0777);
$extentie = substr($file, -4, -3);
$extentie2 = substr($file, -3);
$ext = strtolower($extentie2);
$size = round(filesize($array['$file'])/1024,1).' K';
// script
echo "<table width=\"740\"><tr class=\"sub\"><td align=\"center\">Menu</td></tr></table><table width=\"740\"><tr class=\"ond\"><td><a href=\"#\" onclick=\"javascript:window.open('bewerk.php?x=new',null,'height=110,width=320,status=yes,toolbar=no,menubar=no,location=no');\">Nieuw leeg tekstbestand toevoegen</a></td>
<td><a href=\"#\" onclick=\"javascript:window.open('upload.php',null,'height=200,width=620,status=yes,toolbar=no,menubar=no,location=no');\">Upload een bestand</a></td></tr></table>";
echo "<table>";
echo "<tr><td></td><td><font size=\"5\">Bestanden in de map: <b>$dir</b></font></td></tr></table>";
echo "<table><tr class=\"sub\"><td></td><td></td><td width=\"150\">Naam/openen</td><td width=\"50\">Type:</td><td width=\"100\">Size:</td><td width=\"150\">Laatst geweizigt:</td><td align=\"center\">verwijder:</td><td align=\"center\">Verander naam:</td><td align=\"center\">Bewerk:</td></tr>";
$a=0;
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ($file != "." && $file != "..") {
// --------------
$array['$file'] = $file;
$filesize = $filesize+filesize($dir . $file);
$a++;
// ------------------- ifs
if(strtolower(substr($file, -3)) == "jpg" || strtolower(substr($file, -3)) == "gif" || strtolower(substr($file, -3)) == "pdf" || strtolower(substr($file, -3)) == "doc" || strtolower(substr($file, -3)) == "xls" || strtolower(substr($file, -3)) == "mdb" || strtolower(substr($file, -3)) == "txt") {
echo "<tr class=\"main\"><td>$a</td><td><img src=\"img/". strtolower(substr($file, -3)) . ".gif\" width=\"20\" height=\"22\" alt=\"". substr($file, -3) ."\"></td>";
} else {
echo "<tr><td>$a</td><td><img src=\"img/unknown.gif\" width=\"20\" height=\"22\" alt=\"onbekent\"></td>";
}
// ------------- normal
echo "<td><a href=\"" . $dir . "$file\" target=\"_blank\">$file</a></td>
<td>" . substr($file, -3) . "</td><td>" . round(filesize($dir . $file)/1024,1) . " K</td>
<td>". date ("d\-M\-Y H\:i", filemtime($dir . $file)) . "</td>
<td align=\"center\"> <a href=\"#\" onclick=\"javascript:window.open('bewerk.php?x=delform&file=$file',null,'height=100,width=400,status=yes,toolbar=no,menubar=no,location=no');\">delete</a></td>
<td align=\"center\"> <a href=\"#\" onclick=\"javascript:window.open('bewerk.php?x=rename&file=$file',null,'height=100,width=450,status=yes,toolbar=no,menubar=no,location=no');\">rename</a></td>";
// ------------------ if
if(strtolower(substr($file, -3)) == "txt") {
echo "<td align=\"center\"><a href=\"#\" onclick=\"javascript:window.open('bewerk.php?x=form&file=$file',null,'height=300,width=400,status=yes,toolbar=no,menubar=no,location=no');
\">bewerk</a></td></tr> ";
} else {
echo "<td></td></tr>";
}
}
}
closedir($dh);
}
}
// regel onder in
echo "<tr class=\"ond\"><td></td><td></td><td>totaal files $a</td><td></td><td>totaal " . round($filesize/1024,1) . " K</td><td></td><td></td><td></td><td></td></tr></table>";
?>
</body></html>
<script>
var limit="0:15"
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}
function beginrefresh(){
if (!document.images)
return
if (parselimit==1)
window.location.reload()
else{
parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
else
setTimeout("beginrefresh()",1000)
}
}
window.onload=beginrefresh
//-->
</script>
<?php
// vars
$dir = "upload/";
chmod($dir, 0777);
$extentie = substr($file, -4, -3);
$extentie2 = substr($file, -3);
$ext = strtolower($extentie2);
$size = round(filesize($array['$file'])/1024,1).' K';
// script
echo "<table width=\"740\"><tr class=\"sub\"><td align=\"center\">Menu</td></tr></table><table width=\"740\"><tr class=\"ond\"><td><a href=\"#\" onclick=\"javascript:window.open('bewerk.php?x=new',null,'height=110,width=320,status=yes,toolbar=no,menubar=no,location=no');\">Nieuw leeg tekstbestand toevoegen</a></td>
<td><a href=\"#\" onclick=\"javascript:window.open('upload.php',null,'height=200,width=620,status=yes,toolbar=no,menubar=no,location=no');\">Upload een bestand</a></td></tr></table>";
echo "<table>";
echo "<tr><td></td><td><font size=\"5\">Bestanden in de map: <b>$dir</b></font></td></tr></table>";
echo "<table><tr class=\"sub\"><td></td><td></td><td width=\"150\">Naam/openen</td><td width=\"50\">Type:</td><td width=\"100\">Size:</td><td width=\"150\">Laatst geweizigt:</td><td align=\"center\">verwijder:</td><td align=\"center\">Verander naam:</td><td align=\"center\">Bewerk:</td></tr>";
$a=0;
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ($file != "." && $file != "..") {
// --------------
$array['$file'] = $file;
$filesize = $filesize+filesize($dir . $file);
$a++;
// ------------------- ifs
if(strtolower(substr($file, -3)) == "jpg" || strtolower(substr($file, -3)) == "gif" || strtolower(substr($file, -3)) == "pdf" || strtolower(substr($file, -3)) == "doc" || strtolower(substr($file, -3)) == "xls" || strtolower(substr($file, -3)) == "mdb" || strtolower(substr($file, -3)) == "txt") {
echo "<tr class=\"main\"><td>$a</td><td><img src=\"img/". strtolower(substr($file, -3)) . ".gif\" width=\"20\" height=\"22\" alt=\"". substr($file, -3) ."\"></td>";
} else {
echo "<tr><td>$a</td><td><img src=\"img/unknown.gif\" width=\"20\" height=\"22\" alt=\"onbekent\"></td>";
}
// ------------- normal
echo "<td><a href=\"" . $dir . "$file\" target=\"_blank\">$file</a></td>
<td>" . substr($file, -3) . "</td><td>" . round(filesize($dir . $file)/1024,1) . " K</td>
<td>". date ("d\-M\-Y H\:i", filemtime($dir . $file)) . "</td>
<td align=\"center\"> <a href=\"#\" onclick=\"javascript:window.open('bewerk.php?x=delform&file=$file',null,'height=100,width=400,status=yes,toolbar=no,menubar=no,location=no');\">delete</a></td>
<td align=\"center\"> <a href=\"#\" onclick=\"javascript:window.open('bewerk.php?x=rename&file=$file',null,'height=100,width=450,status=yes,toolbar=no,menubar=no,location=no');\">rename</a></td>";
// ------------------ if
if(strtolower(substr($file, -3)) == "txt") {
echo "<td align=\"center\"><a href=\"#\" onclick=\"javascript:window.open('bewerk.php?x=form&file=$file',null,'height=300,width=400,status=yes,toolbar=no,menubar=no,location=no');
\">bewerk</a></td></tr> ";
} else {
echo "<td></td></tr>";
}
}
}
closedir($dh);
}
}
// regel onder in
echo "<tr class=\"ond\"><td></td><td></td><td>totaal files $a</td><td></td><td>totaal " . round($filesize/1024,1) . " K</td><td></td><td></td><td></td><td></td></tr></table>";
?>
</body></html>
----------------- bewerk.php ------------------
Code (php)
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
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
<html><head><link rel="stylesheet" type="text/css" href="vdveen.css"></head><body bgcolor="#67AEE5">
<?php
// -------- del
$_GET['file'] = str_replace('/','geen',$_GET['file']);
$del_file = "upload/" . $_GET['file'];
if($_GET['x'] == "del") {
if(isset($_POST['ja'])) {
if(file_exists($del_file)) {
unlink($del_file);
echo "<table width=\"300\"><tr class=\"sub\"><td>Verwijderen</td></tr></table><table width=\"300\"><tr class=\"main\"><td>$del_file verwijdert <script language=\"javascript\">setTimeout('window.close()',500)</script></td></tr></table>";
} else {
echo "<table width=\"300\"><tr class=\"sub\"><td>Verwijderen</td></tr></table><table width=\"300\"><tr class=\"main\"><td>dat bestand bestaat niet</td></tr></table>";
}
}
}
if($_GET['x'] == "delform") {
$_GET['file'] = str_replace('/','geen',$_GET['file']);
echo "<table width=\"300\"><tr class=\"sub\"><td>Verwijderen</td></tr></table><table width=\"300\"><tr class=\"main\"><td>weet je het zeker dat je " . $_GET['file'] . " wilt verwijderen?</td></tr>";
echo "<tr class=\"main\"><td><form method=\"post\" action=\"bewerk.php?x=del&file=" . $_GET['file'] . "\"> <input type=\"submit\" name=\"ja\" value=\" ja \"> <input type=\"button\" name=\"nee\" value=\" nee \" onclick=\"javascript:window.close()\"></td></tr></table></form>";
}
//---------------- schrijf
$_GET['bestand'] = str_replace('/','geen',$_GET['bestand']);
if($_GET['x'] == "schrijf") {
$get = "upload/" . $_GET['bestand'];
if(file_exists($get)) {
if($_POST['bericht'] != "") {
// --------------- vars
$post = preg_replace('/\</','',$_POST['bericht']);
$file1 = "upload/" . $_GET['bestand'];
chmod("$file1" , 0777);
// ----------
$fp=fopen("$file1","w");
fwrite($fp,$post);
fclose($fp);
echo "<table width=\"500\"><tr class=\"sub\"><td>Bewerkform:</td></tr></table>
<table width=\"500\"><tr class=\"main\"><td>bestand bijgewerkt <script language=\"javascript\">setTimeout('window.close()',500)</script></td></tr></table>";
}
}
}
// ----------------
// ----------- rename
if($_GET['x'] == "rename") {
$_GET['file'] = str_replace('/','geen',$_GET['file']);
$file = "upload/" . $_GET['file'];
$ext = substr($_GET['file'], -3);
$rename = "upload/" . $_POST['rename'] . "." . $ext;
$extentie = substr($_GET['file'], -4);
//------------
if(file_exists($file)) {
if(isset($_POST['submit']) && $_POST['rename'] != "") {
// -------------
$_POST['rename'] = preg_replace('/\</','',$_POST['rename']);
// ----------
chmod("$file", 0777);
copy($file, $rename);
unlink($file);
echo "<table width=\"330\"><tr class=\"main\"><td>het bestand heet nu $rename <script language=\"javascript\">setTimeout('window.close()',500)</script></td></tr></table>";
}
echo "<table width=\"330\"><tr class=\"sub\" ><td>naam veranderen</td></tr></table>";
echo "<table width=\"330\"><tr class=\"main\"><td>oude naam:</td><td> " . $_GET['file'] . "</td></tr><form method=\"post\" action=\"bewerk.php?x=rename&file=" . $_GET['file'] . "\"><tr class=\"main\"><td>
Nieuwe naam: </td><td><input type=\"text\" name=\"rename\" maxlength=\"15\" value=\"" . $getfile . "\">" . $extentie . "<input type=\"submit\" name=\"submit\" value=\"verander\"></td></tr></table>";
} else
echo "<table><tr class=\"main\"><td>dat bestand bestaat niet</td></tr></table>";
}
// ------------------
// -------------------------
if($_GET['x'] == "form") {
$_GET['file'] = str_replace('/','geen',$_GET['file']);
$file = "upload/" . $_GET['file'];
$handle = fopen ("$file", "r");
echo "<table width=\"500\"><tr class=\"sub\"><td>Bewerkform:</td></tr></table>";
echo "<table width=\"450\"><tr class=\"main\"><td><form method=\"post\" action=\"bewerk.php?x=schrijf&bestand=" . $_GET['file'] . "\" name=\"form\"><textarea name='bericht' cols='40' rows='10'>";
while (!feof ($handle)) {
$bestand = fgets($handle, 4096);
echo "$bestand";
}
echo "</textarea></td></tr><tr class=\"main\"><td><input type=\"submit\" value=\"bewerk!\" name=\"bewerk\"><input type=\"button\" onclick=\"javascript:document.form.bericht.value='';\" name=\"B2\" value=\"leeg\"></form></td></tr></table>";
fclose ($handle);
}
//-------------------
if($_GET['x'] == "new") {
$post = "upload/" . $_POST['name'];
$_POST['name'] = preg_replace('/\</','',$_POST['name']);
if(isset($_POST['submit']) && $_POST['name'] != "") {
$file = 'new.txt';
$newfile = "upload/" . $_POST['name'] . ".txt";
copy($file, $newfile);
echo "<table width=\"300\"><tr class=\"main\"><td>" . $_POST['name'] . ".txt is aangemaakt <script language=\"javascript\">setTimeout('window.close()',500)</script></td></tr></table>";
}
// form
echo "<table width=\"300\"><tr class=\"sub\"><td>nieuw bestand</td></tr></table>";
echo "<table width=\"300\"><tr class=\"main\"><form method=\"post\" action=\"bewerk.php?x=new\"><td>
Naam bestand</td><td><input type=\"text\" name=\"name\" maxlength=\"15\" value=\"nieuwtekstbestand\"></td><td><input type=\"submit\" name=\"submit\" value=\"maak aan\"></td></tr></table>";
}
?>
</body>
</html>
<?php
// -------- del
$_GET['file'] = str_replace('/','geen',$_GET['file']);
$del_file = "upload/" . $_GET['file'];
if($_GET['x'] == "del") {
if(isset($_POST['ja'])) {
if(file_exists($del_file)) {
unlink($del_file);
echo "<table width=\"300\"><tr class=\"sub\"><td>Verwijderen</td></tr></table><table width=\"300\"><tr class=\"main\"><td>$del_file verwijdert <script language=\"javascript\">setTimeout('window.close()',500)</script></td></tr></table>";
} else {
echo "<table width=\"300\"><tr class=\"sub\"><td>Verwijderen</td></tr></table><table width=\"300\"><tr class=\"main\"><td>dat bestand bestaat niet</td></tr></table>";
}
}
}
if($_GET['x'] == "delform") {
$_GET['file'] = str_replace('/','geen',$_GET['file']);
echo "<table width=\"300\"><tr class=\"sub\"><td>Verwijderen</td></tr></table><table width=\"300\"><tr class=\"main\"><td>weet je het zeker dat je " . $_GET['file'] . " wilt verwijderen?</td></tr>";
echo "<tr class=\"main\"><td><form method=\"post\" action=\"bewerk.php?x=del&file=" . $_GET['file'] . "\"> <input type=\"submit\" name=\"ja\" value=\" ja \"> <input type=\"button\" name=\"nee\" value=\" nee \" onclick=\"javascript:window.close()\"></td></tr></table></form>";
}
//---------------- schrijf
$_GET['bestand'] = str_replace('/','geen',$_GET['bestand']);
if($_GET['x'] == "schrijf") {
$get = "upload/" . $_GET['bestand'];
if(file_exists($get)) {
if($_POST['bericht'] != "") {
// --------------- vars
$post = preg_replace('/\</','',$_POST['bericht']);
$file1 = "upload/" . $_GET['bestand'];
chmod("$file1" , 0777);
// ----------
$fp=fopen("$file1","w");
fwrite($fp,$post);
fclose($fp);
echo "<table width=\"500\"><tr class=\"sub\"><td>Bewerkform:</td></tr></table>
<table width=\"500\"><tr class=\"main\"><td>bestand bijgewerkt <script language=\"javascript\">setTimeout('window.close()',500)</script></td></tr></table>";
}
}
}
// ----------------
// ----------- rename
if($_GET['x'] == "rename") {
$_GET['file'] = str_replace('/','geen',$_GET['file']);
$file = "upload/" . $_GET['file'];
$ext = substr($_GET['file'], -3);
$rename = "upload/" . $_POST['rename'] . "." . $ext;
$extentie = substr($_GET['file'], -4);
//------------
if(file_exists($file)) {
if(isset($_POST['submit']) && $_POST['rename'] != "") {
// -------------
$_POST['rename'] = preg_replace('/\</','',$_POST['rename']);
// ----------
chmod("$file", 0777);
copy($file, $rename);
unlink($file);
echo "<table width=\"330\"><tr class=\"main\"><td>het bestand heet nu $rename <script language=\"javascript\">setTimeout('window.close()',500)</script></td></tr></table>";
}
echo "<table width=\"330\"><tr class=\"sub\" ><td>naam veranderen</td></tr></table>";
echo "<table width=\"330\"><tr class=\"main\"><td>oude naam:</td><td> " . $_GET['file'] . "</td></tr><form method=\"post\" action=\"bewerk.php?x=rename&file=" . $_GET['file'] . "\"><tr class=\"main\"><td>
Nieuwe naam: </td><td><input type=\"text\" name=\"rename\" maxlength=\"15\" value=\"" . $getfile . "\">" . $extentie . "<input type=\"submit\" name=\"submit\" value=\"verander\"></td></tr></table>";
} else
echo "<table><tr class=\"main\"><td>dat bestand bestaat niet</td></tr></table>";
}
// ------------------
// -------------------------
if($_GET['x'] == "form") {
$_GET['file'] = str_replace('/','geen',$_GET['file']);
$file = "upload/" . $_GET['file'];
$handle = fopen ("$file", "r");
echo "<table width=\"500\"><tr class=\"sub\"><td>Bewerkform:</td></tr></table>";
echo "<table width=\"450\"><tr class=\"main\"><td><form method=\"post\" action=\"bewerk.php?x=schrijf&bestand=" . $_GET['file'] . "\" name=\"form\"><textarea name='bericht' cols='40' rows='10'>";
while (!feof ($handle)) {
$bestand = fgets($handle, 4096);
echo "$bestand";
}
echo "</textarea></td></tr><tr class=\"main\"><td><input type=\"submit\" value=\"bewerk!\" name=\"bewerk\"><input type=\"button\" onclick=\"javascript:document.form.bericht.value='';\" name=\"B2\" value=\"leeg\"></form></td></tr></table>";
fclose ($handle);
}
//-------------------
if($_GET['x'] == "new") {
$post = "upload/" . $_POST['name'];
$_POST['name'] = preg_replace('/\</','',$_POST['name']);
if(isset($_POST['submit']) && $_POST['name'] != "") {
$file = 'new.txt';
$newfile = "upload/" . $_POST['name'] . ".txt";
copy($file, $newfile);
echo "<table width=\"300\"><tr class=\"main\"><td>" . $_POST['name'] . ".txt is aangemaakt <script language=\"javascript\">setTimeout('window.close()',500)</script></td></tr></table>";
}
// form
echo "<table width=\"300\"><tr class=\"sub\"><td>nieuw bestand</td></tr></table>";
echo "<table width=\"300\"><tr class=\"main\"><form method=\"post\" action=\"bewerk.php?x=new\"><td>
Naam bestand</td><td><input type=\"text\" name=\"name\" maxlength=\"15\" value=\"nieuwtekstbestand\"></td><td><input type=\"submit\" name=\"submit\" value=\"maak aan\"></td></tr></table>";
}
?>
</body>
</html>
--------------- upload.php -----------------
Code (php)
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
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
<html><head><link rel="stylesheet" type="text/css" href="vdveen.css"></head><body>
<?PHP
global $_FILES;
$filename = $_FILES['userfile']['name'];
// extensies
$allow[0] = "jpg";
$allow[1] = "pdf";
$allow[2] = "gif";
$allow[3] = "mdb";
$allow[4] = "doc";
$allow[5] = "xls";
$allow[6] = "txt";
$allow[7] = "JPG";
$allow[8] = "PDF";
$allow[9] = "GIF";
$allow[10] = "MDB";
$allow[11] = "DOC";
$allow[12] = "XLS";
$allow[13] = "TXT";
$allow[14] = "zip";
$allow[15] = "ZIP";
$allow[14] = "rar";
$allow[15] = "RAR";
$allow[16] = "dwg";
$allow[15] = "DWG";
// vars
$max = '1048576';
$kb = $max/1024;
$name = $_FILES['userfile']['name'];
$size = $_FILES['userfile']['size'];
// script
if(isset($_POST['submit'])) {
// newname
if ($_POST["newname"]) {
$ext = substr($_FILES['userfile']['name'], -3);
$uploadname = $_POST['newname'] . "." . $ext;
} else {
$uploadname = $_FILES['userfile']['name'];
}
// exensie check
$extentie = substr($uploadname, -3);
for ($i = 0; $i < count($allow); $i++) {
if ($extentie == $allow[$i]) {
$extentie_check = "ok";
$i = count($allow) + 5; // om loop te beindigen
}
}
// upload en extensie check
if ($extentie_check == "ok") {
if ($size <= $max) { // size
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { // upload
move_uploaded_file($_FILES['userfile']['tmp_name'], "upload/" . $uploadname);
echo "<table width=\"600\"><tr class=\"main\"><td>Het bestand is geupload onder de naam: $uploadname</td></tr></table>";
} // einde upload'
} else { // size
echo "<table width=\"600\"><tr class=\"main\"><td>het bestand $name mag niet groter zijn als $kb kb</td></tr></table>";
}
} else {
echo "<table width=\"600\"><tr class=\"main\"><td>Die extensie mag niet</td></tr></table>";
}
}
// form
echo "
<table width=\"600\"><tr class=\"sub\"><td>Upload formulier</td></tr></table>
<table width=\"600\"><tr class=\"main\"><td>
<form enctype=\"multipart/form-data\" method=\"post\">
Selecteer een bestand:</td><td><input name=\"userfile\" type=\"file\"></td></tr>
<tr class=\"main\"><td>Nieuwe naam:</td><td><input name=\"newname\" type=\"text\">(Optioneel)</td></tr>
<tr class=\"main\"><td><input type=\"submit\" name=\"submit\" value=\"upload bestand\"></td><td></td></tr></table>
</form> ";
?>
</body>
</html>
<?PHP
global $_FILES;
$filename = $_FILES['userfile']['name'];
// extensies
$allow[0] = "jpg";
$allow[1] = "pdf";
$allow[2] = "gif";
$allow[3] = "mdb";
$allow[4] = "doc";
$allow[5] = "xls";
$allow[6] = "txt";
$allow[7] = "JPG";
$allow[8] = "PDF";
$allow[9] = "GIF";
$allow[10] = "MDB";
$allow[11] = "DOC";
$allow[12] = "XLS";
$allow[13] = "TXT";
$allow[14] = "zip";
$allow[15] = "ZIP";
$allow[14] = "rar";
$allow[15] = "RAR";
$allow[16] = "dwg";
$allow[15] = "DWG";
// vars
$max = '1048576';
$kb = $max/1024;
$name = $_FILES['userfile']['name'];
$size = $_FILES['userfile']['size'];
// script
if(isset($_POST['submit'])) {
// newname
if ($_POST["newname"]) {
$ext = substr($_FILES['userfile']['name'], -3);
$uploadname = $_POST['newname'] . "." . $ext;
} else {
$uploadname = $_FILES['userfile']['name'];
}
// exensie check
$extentie = substr($uploadname, -3);
for ($i = 0; $i < count($allow); $i++) {
if ($extentie == $allow[$i]) {
$extentie_check = "ok";
$i = count($allow) + 5; // om loop te beindigen
}
}
// upload en extensie check
if ($extentie_check == "ok") {
if ($size <= $max) { // size
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) { // upload
move_uploaded_file($_FILES['userfile']['tmp_name'], "upload/" . $uploadname);
echo "<table width=\"600\"><tr class=\"main\"><td>Het bestand is geupload onder de naam: $uploadname</td></tr></table>";
} // einde upload'
} else { // size
echo "<table width=\"600\"><tr class=\"main\"><td>het bestand $name mag niet groter zijn als $kb kb</td></tr></table>";
}
} else {
echo "<table width=\"600\"><tr class=\"main\"><td>Die extensie mag niet</td></tr></table>";
}
}
// form
echo "
<table width=\"600\"><tr class=\"sub\"><td>Upload formulier</td></tr></table>
<table width=\"600\"><tr class=\"main\"><td>
<form enctype=\"multipart/form-data\" method=\"post\">
Selecteer een bestand:</td><td><input name=\"userfile\" type=\"file\"></td></tr>
<tr class=\"main\"><td>Nieuwe naam:</td><td><input name=\"newname\" type=\"text\">(Optioneel)</td></tr>
<tr class=\"main\"><td><input type=\"submit\" name=\"submit\" value=\"upload bestand\"></td><td></td></tr></table>
</form> ";
?>
</body>
</html>
----------- index.php ---------------
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?PHP
echo "<script language=\"javascript\">window.self.location=('opendir.php');</script>";
?>
</body>
</html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?PHP
echo "<script language=\"javascript\">window.self.location=('opendir.php');</script>";
?>
</body>
</html>
--------------- vdveen.css ----------------
Code (php)
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
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
body { background: #67AEE5; color: #F2FF21; font-family: "verdana"; font-size: 8pt; cursor: default; }
p { color: #000000; font-family: "verdana"; font-size: 10pt; cursor: default; }
a:link { color: #0800AE; font-family: "verdana"; font-size: 10pt; text-decoration: none; }
a:visited { color: #0800AE; font-family: "verdana"; font-size: 10pt; text-decoration: none; }
a:active { color: #0800AE; font-family: "verdana"; font-size: 10pt; text-decoration: none; }
a:hover { color: #FF7301; font-family: "verdana"; font-size: 10pt; text-decoration: none; }
textarea { border: 1px solid #000000; color: #0800AE; background: #F7F79C; font-size: 8pt; }
text { border: 1px solid #000000; background: #F7F79C; font-size: 8pt; }
input { border: 1px solid #000000; background: #F7F79C; font-size: 8pt; }
select { border: 1px solid #000000; background: #F7F79C; font-size: 8pt; }
table { color: #F2FF21; font-family: "verdana"; font-size: 8pt; }
table.main { background: #000000; color:#F7F79C; font-family: "verdana"; font-size: 10pt; }
tr.sub { border: 0px solid #000F5C; background: #0800AE; color: #FF7301; font-family: "verdana"; font-size: 8pt; letter-spacing: 1px; }
tr.main { border: 0px solid #001478; background: #91CFFF; color: #FF0909; font-family: "verdana"; font-size: 10pt; padding-left: 5px;}
tr.ond { border: 0px solid #001478; background: #65BCFF; color: #FF7301; font-family: "verdana"; font-size: 10pt; padding-left: 5px;}
body {
scrollbar-face-color: #eb7722;
scrollbar-shadow-color: #000000;
scrollbar-highlight-color: #388ccc;
scrollbar-3dlight-color: #99BEEE;
scrollbar-darkshadow-color: black;
scrollbar-track-color: #99BEEE;
scrollbar-arrow-color: #388ccc;
cursor: default; }
p { color: #000000; font-family: "verdana"; font-size: 10pt; cursor: default; }
a:link { color: #0800AE; font-family: "verdana"; font-size: 10pt; text-decoration: none; }
a:visited { color: #0800AE; font-family: "verdana"; font-size: 10pt; text-decoration: none; }
a:active { color: #0800AE; font-family: "verdana"; font-size: 10pt; text-decoration: none; }
a:hover { color: #FF7301; font-family: "verdana"; font-size: 10pt; text-decoration: none; }
textarea { border: 1px solid #000000; color: #0800AE; background: #F7F79C; font-size: 8pt; }
text { border: 1px solid #000000; background: #F7F79C; font-size: 8pt; }
input { border: 1px solid #000000; background: #F7F79C; font-size: 8pt; }
select { border: 1px solid #000000; background: #F7F79C; font-size: 8pt; }
table { color: #F2FF21; font-family: "verdana"; font-size: 8pt; }
table.main { background: #000000; color:#F7F79C; font-family: "verdana"; font-size: 10pt; }
tr.sub { border: 0px solid #000F5C; background: #0800AE; color: #FF7301; font-family: "verdana"; font-size: 8pt; letter-spacing: 1px; }
tr.main { border: 0px solid #001478; background: #91CFFF; color: #FF0909; font-family: "verdana"; font-size: 10pt; padding-left: 5px;}
tr.ond { border: 0px solid #001478; background: #65BCFF; color: #FF7301; font-family: "verdana"; font-size: 10pt; padding-left: 5px;}
body {
scrollbar-face-color: #eb7722;
scrollbar-shadow-color: #000000;
scrollbar-highlight-color: #388ccc;
scrollbar-3dlight-color: #99BEEE;
scrollbar-darkshadow-color: black;
scrollbar-track-color: #99BEEE;
scrollbar-arrow-color: #388ccc;
cursor: default; }
------------------------------------------------------