anti spam cookie mail form
ik zelf zie de fout niet, miss dat jullie em zien =P.
meldingen als, "dit is niet netjes" en "dit is zo netter" heb ik liever niet, als de fout maar gevonden word is het goed =P
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
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
<?php
session_start();
include_once ("config.php");
mysql_connect ($dbhost, $dbuser, $dbpasswd) or die ($lang["foutconnect"]);
mysql_select_db($dbname) or die ($lang["foutdatabase"]);
$sitenaam = "clown zijn site";
?>
<b>CONTACT</b><br />
<br />
<?php
ob_start();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$wm_email = "[email protected]";
$antispam = "5";
if(getenv($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = getenv($_SERVER['HTTP_X_FORWARDED_FOR']);
} elseif(getenv($_SERVER['HTTP_CLIENT_IP'])) {
$ip = getenv($_SERVER['HTTP_CLIENT_IP']);
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$host = gethostbyaddr($ip);
$headers = "From: \"" . $sitenaam . " Contactformulier\" <". $sitenaam .">\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1";
$message = "Naam: ". $_POST['naam'] ."\n";
$message .= "E-mail: ". $_POST['email'] ."\n";
$message .= "-------------------------------------------------------\n";
$message .= $_POST['bericht'] ."\n";
$message .= "-------------------------------------------------------\n";
$message .= "Datum: ".date("d-m-Y H:i:s")."\n";
$message .= "IP: ". $ip ."\n";
$message .= "Host: ". $host ."\n ";
if(!isset($_COOKIE[$sitenaam . 'mailformulier']))
{
if(isset($_POST['submit'])) {
if($_POST['naam'] == "") {
$error .= "naam vergeten<br />";
}
if($_POST['email'] == "") {
$error .= "email vergeten<br />";
}
if($_POST['onderwerp'] == "") {
$error .= "onderwerp vergeten<br />";
}
if($_POST['bericht'] == "") {
$error .= "bericht vergeten<br />";
}
if(strlen($error)==0) {
mail($wm_email,$_POST['onderwerp'],$message,$headers);
setcookie($sitenaam . "mailformulier",1,time()+($antispam*60));
}
if(strlen($error)==0) {
?>
je bericht is verzonden<br />
<br />
met vriendelijke groet<br />
<br />
<?php
echo $sitenaam;
} elseif(strlen($error)!=0) {
?>
je bent een veld vergeten<br />
<br />
<?=$error;?><br />
klik <a href="javascript:history.go(-1);">hier</a> om terug te gaan
<?php
}
} else {
?>
<form method="post" action="<? echo $PHP_SELF; ?>">
<b>naam*</b><br />
<input type="text" name="naam" size="25" maxlength="40"><br />
<b>email*</b><br />
<input type="text" name="email" size="25" maxlength="60"><br />
<b>onderwerp*</b><br />
<input type="text" name="onderwerp" size="25" maxlength="60"><br />
<b>bericht*</b><br />
<textarea name="bericht" rows="15" cols="45"></textarea><br />
<br />
<input type="submit" name="submit" value="OK">
</form>
<?
}
} else {
?>
je kunt maar eens in de <b><?php echo $antispam;?></b> minuten een mail sturen<br />
<br />
klik <a href="index.php">hier</a> om terug naar de index te gaan<br />
<?php
}
?>
session_start();
include_once ("config.php");
mysql_connect ($dbhost, $dbuser, $dbpasswd) or die ($lang["foutconnect"]);
mysql_select_db($dbname) or die ($lang["foutdatabase"]);
$sitenaam = "clown zijn site";
?>
<b>CONTACT</b><br />
<br />
<?php
ob_start();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
$wm_email = "[email protected]";
$antispam = "5";
if(getenv($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = getenv($_SERVER['HTTP_X_FORWARDED_FOR']);
} elseif(getenv($_SERVER['HTTP_CLIENT_IP'])) {
$ip = getenv($_SERVER['HTTP_CLIENT_IP']);
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
$host = gethostbyaddr($ip);
$headers = "From: \"" . $sitenaam . " Contactformulier\" <". $sitenaam .">\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1";
$message = "Naam: ". $_POST['naam'] ."\n";
$message .= "E-mail: ". $_POST['email'] ."\n";
$message .= "-------------------------------------------------------\n";
$message .= $_POST['bericht'] ."\n";
$message .= "-------------------------------------------------------\n";
$message .= "Datum: ".date("d-m-Y H:i:s")."\n";
$message .= "IP: ". $ip ."\n";
$message .= "Host: ". $host ."\n ";
if(!isset($_COOKIE[$sitenaam . 'mailformulier']))
{
if(isset($_POST['submit'])) {
if($_POST['naam'] == "") {
$error .= "naam vergeten<br />";
}
if($_POST['email'] == "") {
$error .= "email vergeten<br />";
}
if($_POST['onderwerp'] == "") {
$error .= "onderwerp vergeten<br />";
}
if($_POST['bericht'] == "") {
$error .= "bericht vergeten<br />";
}
if(strlen($error)==0) {
mail($wm_email,$_POST['onderwerp'],$message,$headers);
setcookie($sitenaam . "mailformulier",1,time()+($antispam*60));
}
if(strlen($error)==0) {
?>
je bericht is verzonden<br />
<br />
met vriendelijke groet<br />
<br />
<?php
echo $sitenaam;
} elseif(strlen($error)!=0) {
?>
je bent een veld vergeten<br />
<br />
<?=$error;?><br />
klik <a href="javascript:history.go(-1);">hier</a> om terug te gaan
<?php
}
} else {
?>
<form method="post" action="<? echo $PHP_SELF; ?>">
<b>naam*</b><br />
<input type="text" name="naam" size="25" maxlength="40"><br />
<b>email*</b><br />
<input type="text" name="email" size="25" maxlength="60"><br />
<b>onderwerp*</b><br />
<input type="text" name="onderwerp" size="25" maxlength="60"><br />
<b>bericht*</b><br />
<textarea name="bericht" rows="15" cols="45"></textarea><br />
<br />
<input type="submit" name="submit" value="OK">
</form>
<?
}
} else {
?>
je kunt maar eens in de <b><?php echo $antispam;?></b> minuten een mail sturen<br />
<br />
klik <a href="index.php">hier</a> om terug naar de index te gaan<br />
<?php
}
?>
Gewijzigd op 01/01/1970 01:00:00 door Clown
http://www.opteronics.com/opteron-cpu.htm
Bron: 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
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
<?php
// New / Returning visitor tracking cookie
// Calls an image with an additional uid relating to the visitors new or existing cookie value
// N Thompson - 06.10.2005
if (isset($_COOKIE['SDCvisitorRef'])) {
// returning visitor
$count = $_COOKIE['SDCvisitorRef'];
} else {
// new visitor
$file = "sdc/visitor-count.txt"; // file to work from
$handle = fopen ($file, 'r+'); // Let's open for read and write
$count = intval(fread ($handle, filesize ($file))); // We don't want to think it's a string and try appending
rewind ($handle); // Go back to the beginning
$count++; // Add one to counter
fwrite($handle, $count); // write new incriment to doc
fclose($handle); // close doc
$time = time();
$expire_ts = $time - date("Z", $time) + (date("I", $time)*60*60*24*30) + 43200;
$expire = date("D, j-M-Y H:i:s", $expire_ts) . " GMT";
setcookie ("SDCvisitorRef",$count, $expire); // set cookie called SDCvisitorRef, value of count, expire 30 days
}
echo '<img src="/images/global/visitor-tracker.gif?uid=' . $count . '" height="0" width="0" alt="" />';
?>
// New / Returning visitor tracking cookie
// Calls an image with an additional uid relating to the visitors new or existing cookie value
// N Thompson - 06.10.2005
if (isset($_COOKIE['SDCvisitorRef'])) {
// returning visitor
$count = $_COOKIE['SDCvisitorRef'];
} else {
// new visitor
$file = "sdc/visitor-count.txt"; // file to work from
$handle = fopen ($file, 'r+'); // Let's open for read and write
$count = intval(fread ($handle, filesize ($file))); // We don't want to think it's a string and try appending
rewind ($handle); // Go back to the beginning
$count++; // Add one to counter
fwrite($handle, $count); // write new incriment to doc
fclose($handle); // close doc
$time = time();
$expire_ts = $time - date("Z", $time) + (date("I", $time)*60*60*24*30) + 43200;
$expire = date("D, j-M-Y H:i:s", $expire_ts) . " GMT";
setcookie ("SDCvisitorRef",$count, $expire); // set cookie called SDCvisitorRef, value of count, expire 30 days
}
echo '<img src="/images/global/visitor-tracker.gif?uid=' . $count . '" height="0" width="0" alt="" />';
?>
maar ik heb liever dat de fout uit mijn eigen script word gefixt, want eerst werkte die wel naar behorten met die cookie ;)
iig wel hartelijk bedankt voor de reactie =)
naar mijn weten zijn dit soort principes niet geliefd hier op phphulp. Men wil je helpen bij problemen en je nieuwe dingen leren...niet iets fixen waarna je het zelf nogsteeds niet begrijpt ne je volgende week terug komt met de volgende vraag
Wat zie je dan?