portfolio-met-watermerk
Gesponsorde koppelingen
PHP script bestanden
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
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
<HTML>
<HEAD>
<TITLE>GD-Test</TITLE>
<style type="text/css">
body,div,p,h1,h2,h3,h4,h5,h6,td {
SCROLLBAR-FACE-COLOR: #000000;
SCROLLBAR-HIGHLIGHT-COLOR: #000000;
SCROLLBAR-SHADOW-COLOR: #c0c0c0;
SCROLLBAR-3DLIGHT-COLOR: #c0c0c0;
SCROLLBAR-ARROW-COLOR: #C0C0C0;
SCROLLBAR-TRACK-COLOR: #000000;
SCROLLBAR-DARKSHADOW-COLOR: #000000;
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
FONT-SIZE: 10px;
color : 666666;
margin: 0px;
}
body {
overflow: auto;
background-color: black;
}
A {
text-decoration: underline;
color : 666666;
}
A:VISITED {
text-decoration: underline;
color : 666666;
}
A:hover {
text-decoration: underline;
color : #ffffff;
}
img {
border: 1px solid #666666;
}
div.top {
height: 25px; background-color: #333333;
padding: 5px 10px;
}
div.bottom {
clear: left;
height: 25px; background-color: #333333;
padding: 5px 10px;
}
div.thumbs {
float: left;
width: 430px; background-color: #000000;
padding: 20px 10px 20px 10px;
}
div.thumb {
float: left;
width: 120px; height: 120px;
padding: 0px; margin: 4px;
border: 1px solid #666666;
overflow: hidden;
}
div.images {
float: left;
width: 520px; height: 550px; background-color: #000000;
padding: 20px 10px 20px 10px;
}
div.image {
float: left;
padding: 0px; margin: 4px;
border: 1px solid #666666;
overflow: hidden;
}
LABEL,INPUT,TEXTAREA {
border:0px solid #C0C0C0; background-color: #606060;
color: #C0C0C0; font-family: arial; font-size: 10px;
margin: 2px;
}
LABEL,INPUT {
height: 12px;
}
</style>
</HEAD>
<BODY>
<DIV CLASS="TOP">
<P STYLE="float: left;">Wennekes Webdesign Digital Camera Portfolio</P>
<form class="navbar" action="<?php echo $_SERVER['REQUEST_URI'];?>" method="POST" STYLE="float: right; margin: 0px; padding: 0px;">
Inloggen
<input type="password" name="password" size="6">
<input type="submit" name="login" value="login">
<input type="submit" name="logout" value="logout">
</form>
</DIV>
<HEAD>
<TITLE>GD-Test</TITLE>
<style type="text/css">
body,div,p,h1,h2,h3,h4,h5,h6,td {
SCROLLBAR-FACE-COLOR: #000000;
SCROLLBAR-HIGHLIGHT-COLOR: #000000;
SCROLLBAR-SHADOW-COLOR: #c0c0c0;
SCROLLBAR-3DLIGHT-COLOR: #c0c0c0;
SCROLLBAR-ARROW-COLOR: #C0C0C0;
SCROLLBAR-TRACK-COLOR: #000000;
SCROLLBAR-DARKSHADOW-COLOR: #000000;
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
FONT-SIZE: 10px;
color : 666666;
margin: 0px;
}
body {
overflow: auto;
background-color: black;
}
A {
text-decoration: underline;
color : 666666;
}
A:VISITED {
text-decoration: underline;
color : 666666;
}
A:hover {
text-decoration: underline;
color : #ffffff;
}
img {
border: 1px solid #666666;
}
div.top {
height: 25px; background-color: #333333;
padding: 5px 10px;
}
div.bottom {
clear: left;
height: 25px; background-color: #333333;
padding: 5px 10px;
}
div.thumbs {
float: left;
width: 430px; background-color: #000000;
padding: 20px 10px 20px 10px;
}
div.thumb {
float: left;
width: 120px; height: 120px;
padding: 0px; margin: 4px;
border: 1px solid #666666;
overflow: hidden;
}
div.images {
float: left;
width: 520px; height: 550px; background-color: #000000;
padding: 20px 10px 20px 10px;
}
div.image {
float: left;
padding: 0px; margin: 4px;
border: 1px solid #666666;
overflow: hidden;
}
LABEL,INPUT,TEXTAREA {
border:0px solid #C0C0C0; background-color: #606060;
color: #C0C0C0; font-family: arial; font-size: 10px;
margin: 2px;
}
LABEL,INPUT {
height: 12px;
}
</style>
</HEAD>
<BODY>
<DIV CLASS="TOP">
<P STYLE="float: left;">Wennekes Webdesign Digital Camera Portfolio</P>
<form class="navbar" action="<?php echo $_SERVER['REQUEST_URI'];?>" method="POST" STYLE="float: right; margin: 0px; padding: 0px;">
Inloggen
<input type="password" name="password" size="6">
<input type="submit" name="login" value="login">
<input type="submit" name="logout" value="logout">
</form>
</DIV>
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
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
168
169
170
171
172
173
174
175
176
177
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
168
169
170
171
172
173
174
175
176
177
<?php
// 3-4-2008 GD-Watermerk test | Rene Wennekes
$map1 = "thumbs"; //Map waar de miniaturen geplaatst worden.
$map2 = "images"; //Map waar de normale afbeeldingen geplaatst worden voorzien van watermerk.
//----------------------------------------------------------------------------
// Simpel inlogsysteem
$login=$_POST["login"];
$logout=$_POST["logout"];
$password=$_POST["password"];
if (isset($login) and md5($password)=="e10adc3949ba59abbe56e057f20f883e") {
$userid="1";
$_SESSION["userid"]=$userid;
}
if (isset($logout)) {
$userid="";
$_SESSION["userid"]=$userid;
}
$mode=$_GET[mode];
$image=$_GET[image];
//----------------------------------------------------------------------------
// Verwijderen
print "<DIV STYLE='background-color: #402020;'>\n";
if ($mode == "delete" and $userid == "1" and file_exists("$map1/$image")) {
if (unlink("$map1/$image") == TRUE) {
print "Thumbnail van $image verwijderd<br>\n";
} else {
print "Thumbnail van $image niet verwijderd<br>\n";
}
}
if ($mode == "delete" and $userid == "1" and file_exists("$map2/$image")) {
if (unlink("$map2/$image") == TRUE) {
print "$image verwijderd<br>\n";
} else {
print "$image niet verwijderd<br>\n";
}
}
print "</DIV>\n";
//----------------------------------------------------------------------------
// Uploaden
if ($userid=="1") {
print "<DIV STYLE='background-color: #202040; clear: both;'>\n";
$uploadfile = $_FILES['upfile']['name'];
$submit=$_POST["submit"];
$filetype = $_FILES['upfile']['type'];
$filesize = $_FILES['upfile']['size'];
$error = $_FILES['upfile']['error'];
if ($submit != "") {
if ($filesize > 9999999) {$warnmessage = "Het bestand is groter dan 1.999 Mb.";}
if ($filetype != "image/jpeg") {$warnmessage = "Het bestand is geen jpg bestand.";}
}
// Upload bestand formulier
print "<form enctype='multipart/form-data' action={$_SERVER['REQUEST_URI']} method='post'>\n";
print "<input type='hidden' name='MAX_FILE_SIZE' value='9999999'>\n";
print "Bestand\n";
print "<input type='file' name='upfile'>\n";
print "<input type='submit' name='submit' value='Upload'>\n";
print "</form>\n";
print "<br>Het bestand moet van het jpg formaat zijn en niet groter dan 1.999 mb.<br>\n";
print "<br>\n";
print "<b>$warnmessage</b><br>\n";
print "<br>\n";
if ($submit != "" and $warnmessage == "") {
$tempimage=$_FILES['upfile']['tmp_name'];
//---------------------------------------------------------------
// Resizen naar 500x375, watermerk toevoegen en schrijven in $map1
// Resizen naar 160x120 en schrijven in $map2
$src=$uploadfile;
$size=getimagesize($tempimage);
$width=$size[0];
$height=$size[1];
//Create Thumbnail
if ($width >= $height) {$thumbwidth=160; $thumbheight=120;} else {$thumbwidth=120; $thumbheight=160;}
$thumb = imagecreatetruecolor($thumbwidth, $thumbheight);
$source1 = imagecreatefromjpeg($tempimage);
imagecopyresampled($thumb, $source1, 0, 0, 0, 0, $thumbwidth, $thumbheight, $width, $height);
//Create Normal Size Image
if ($width >= $height) {$newwidth=500; $newheight=375;} else {$newwidth=375; $newheight=500;}
$medium = imagecreatetruecolor($newwidth, $newheight);
$source2 = imagecreatefromjpeg($tempimage);
imagecopyresampled($medium, $source2, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// Add Watermark
// The text to draw
$text = 'Copyright (C) 2008 Wennekes Webdesign';
// Replace path by your own font path
$font = 'square.ttf';
#$frontcolor = imagecolorallocate($image, 240, 240, 240);
$frontcolor = imagecolorexactalpha($medium, 240, 240, 240, 64); // r:240 g:240 b:240 alpha: 50%
imagettftext($medium, 10, 30, 50, $newheight-50, $frontcolor, $font, $text); // 30 graden x=50 y=50 van onder
imagettftext($medium, 10, 30, 50, $newheight/2, $frontcolor, $font, $text); // 30 graden x=50 y=hoogte/2
//Write Image
imagejpeg($medium, $map2.'/'.$uploadfile, 90);
imagejpeg($thumb, $map1.'/'.$uploadfile, 90);
#print "<center><IMG SRC='$map1/$uploadfile'><br>\n";
#print $map1.'/'.$uploadfile."</center><br>\n<br>\n";
#print "<center><IMG SRC='$map2/$uploadfile'><br>\n";
#print $map2.'/'.$uploadfile."</center><br>\n<br>\n";
print "<IMG SRC='$map1/$uploadfile' style='float: right'>\n";
print "Het bestand $uploadfile is succesvol geupload.<br>\n";
print "Het type is van het bestand is $filetype.<br>\n";
print "De grootte van het bestand is $filesize bytes<br>\n";
#print "<br>\n";
#print "<A HREF={$_SERVER['REQUEST_URI']}>Upload</A>";
//---------------------------------------------------------------
}
print "</DIV>\n";
}
//----------------------------------------------------------------------------
// Afdrukken miniaturen uit $map1
print "<DIV CLASS='THUMBS'>\n";
// Openen
$dir = new DirectoryIterator($map1);
// Doorlopen
foreach ($dir as $file) {
$src=$map1.'/'.$file;
if ($file != "." and $file != ".." and $file != "Thumbs.db") {
print "<DIV CLASS='THUMB'>\n";
if ($userid == "1") {print "<A HREF='{$_SERVER['PHP_SELF']}?image=$file&mode=delete'>Delete</A>\n";}
print "<A HREF='{$_SERVER['PHP_SELF']}?image=$file'><IMG SRC='$src'></A>\n";
print "</DIV>\n";
if ($file != "") {$lastslide=$file;}
}
}
print "</DIV>";
// Afdrukken image uit $map2 (bij delete 1e image uit de map)
print "<DIV CLASS='IMAGES'>\n";
if ($image == "" or $mode == "delete") {
$dir = new DirectoryIterator($map2);
foreach ($dir as $file) {
if ($file != "." and $file != ".." and $file != "Thumbs.db") {
$image=$file; break;
}
}
}
print "<DIV CLASS='IMAGE'>\n";
if (file_exists($map2.'/'.$image)) {print "<IMG SRC='$map2/$image'>\n";} else {print "Het bestand is verwijderd.";}
print "</DIV>\n";
print "</DIV>\n";
?>
// 3-4-2008 GD-Watermerk test | Rene Wennekes
$map1 = "thumbs"; //Map waar de miniaturen geplaatst worden.
$map2 = "images"; //Map waar de normale afbeeldingen geplaatst worden voorzien van watermerk.
//----------------------------------------------------------------------------
// Simpel inlogsysteem
$login=$_POST["login"];
$logout=$_POST["logout"];
$password=$_POST["password"];
if (isset($login) and md5($password)=="e10adc3949ba59abbe56e057f20f883e") {
$userid="1";
$_SESSION["userid"]=$userid;
}
if (isset($logout)) {
$userid="";
$_SESSION["userid"]=$userid;
}
$mode=$_GET[mode];
$image=$_GET[image];
//----------------------------------------------------------------------------
// Verwijderen
print "<DIV STYLE='background-color: #402020;'>\n";
if ($mode == "delete" and $userid == "1" and file_exists("$map1/$image")) {
if (unlink("$map1/$image") == TRUE) {
print "Thumbnail van $image verwijderd<br>\n";
} else {
print "Thumbnail van $image niet verwijderd<br>\n";
}
}
if ($mode == "delete" and $userid == "1" and file_exists("$map2/$image")) {
if (unlink("$map2/$image") == TRUE) {
print "$image verwijderd<br>\n";
} else {
print "$image niet verwijderd<br>\n";
}
}
print "</DIV>\n";
//----------------------------------------------------------------------------
// Uploaden
if ($userid=="1") {
print "<DIV STYLE='background-color: #202040; clear: both;'>\n";
$uploadfile = $_FILES['upfile']['name'];
$submit=$_POST["submit"];
$filetype = $_FILES['upfile']['type'];
$filesize = $_FILES['upfile']['size'];
$error = $_FILES['upfile']['error'];
if ($submit != "") {
if ($filesize > 9999999) {$warnmessage = "Het bestand is groter dan 1.999 Mb.";}
if ($filetype != "image/jpeg") {$warnmessage = "Het bestand is geen jpg bestand.";}
}
// Upload bestand formulier
print "<form enctype='multipart/form-data' action={$_SERVER['REQUEST_URI']} method='post'>\n";
print "<input type='hidden' name='MAX_FILE_SIZE' value='9999999'>\n";
print "Bestand\n";
print "<input type='file' name='upfile'>\n";
print "<input type='submit' name='submit' value='Upload'>\n";
print "</form>\n";
print "<br>Het bestand moet van het jpg formaat zijn en niet groter dan 1.999 mb.<br>\n";
print "<br>\n";
print "<b>$warnmessage</b><br>\n";
print "<br>\n";
if ($submit != "" and $warnmessage == "") {
$tempimage=$_FILES['upfile']['tmp_name'];
//---------------------------------------------------------------
// Resizen naar 500x375, watermerk toevoegen en schrijven in $map1
// Resizen naar 160x120 en schrijven in $map2
$src=$uploadfile;
$size=getimagesize($tempimage);
$width=$size[0];
$height=$size[1];
//Create Thumbnail
if ($width >= $height) {$thumbwidth=160; $thumbheight=120;} else {$thumbwidth=120; $thumbheight=160;}
$thumb = imagecreatetruecolor($thumbwidth, $thumbheight);
$source1 = imagecreatefromjpeg($tempimage);
imagecopyresampled($thumb, $source1, 0, 0, 0, 0, $thumbwidth, $thumbheight, $width, $height);
//Create Normal Size Image
if ($width >= $height) {$newwidth=500; $newheight=375;} else {$newwidth=375; $newheight=500;}
$medium = imagecreatetruecolor($newwidth, $newheight);
$source2 = imagecreatefromjpeg($tempimage);
imagecopyresampled($medium, $source2, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// Add Watermark
// The text to draw
$text = 'Copyright (C) 2008 Wennekes Webdesign';
// Replace path by your own font path
$font = 'square.ttf';
#$frontcolor = imagecolorallocate($image, 240, 240, 240);
$frontcolor = imagecolorexactalpha($medium, 240, 240, 240, 64); // r:240 g:240 b:240 alpha: 50%
imagettftext($medium, 10, 30, 50, $newheight-50, $frontcolor, $font, $text); // 30 graden x=50 y=50 van onder
imagettftext($medium, 10, 30, 50, $newheight/2, $frontcolor, $font, $text); // 30 graden x=50 y=hoogte/2
//Write Image
imagejpeg($medium, $map2.'/'.$uploadfile, 90);
imagejpeg($thumb, $map1.'/'.$uploadfile, 90);
#print "<center><IMG SRC='$map1/$uploadfile'><br>\n";
#print $map1.'/'.$uploadfile."</center><br>\n<br>\n";
#print "<center><IMG SRC='$map2/$uploadfile'><br>\n";
#print $map2.'/'.$uploadfile."</center><br>\n<br>\n";
print "<IMG SRC='$map1/$uploadfile' style='float: right'>\n";
print "Het bestand $uploadfile is succesvol geupload.<br>\n";
print "Het type is van het bestand is $filetype.<br>\n";
print "De grootte van het bestand is $filesize bytes<br>\n";
#print "<br>\n";
#print "<A HREF={$_SERVER['REQUEST_URI']}>Upload</A>";
//---------------------------------------------------------------
}
print "</DIV>\n";
}
//----------------------------------------------------------------------------
// Afdrukken miniaturen uit $map1
print "<DIV CLASS='THUMBS'>\n";
// Openen
$dir = new DirectoryIterator($map1);
// Doorlopen
foreach ($dir as $file) {
$src=$map1.'/'.$file;
if ($file != "." and $file != ".." and $file != "Thumbs.db") {
print "<DIV CLASS='THUMB'>\n";
if ($userid == "1") {print "<A HREF='{$_SERVER['PHP_SELF']}?image=$file&mode=delete'>Delete</A>\n";}
print "<A HREF='{$_SERVER['PHP_SELF']}?image=$file'><IMG SRC='$src'></A>\n";
print "</DIV>\n";
if ($file != "") {$lastslide=$file;}
}
}
print "</DIV>";
// Afdrukken image uit $map2 (bij delete 1e image uit de map)
print "<DIV CLASS='IMAGES'>\n";
if ($image == "" or $mode == "delete") {
$dir = new DirectoryIterator($map2);
foreach ($dir as $file) {
if ($file != "." and $file != ".." and $file != "Thumbs.db") {
$image=$file; break;
}
}
}
print "<DIV CLASS='IMAGE'>\n";
if (file_exists($map2.'/'.$image)) {print "<IMG SRC='$map2/$image'>\n";} else {print "Het bestand is verwijderd.";}
print "</DIV>\n";
print "</DIV>\n";
?>