door julien » 24 feb 2006 17:04
Natuurlijk!
Contact.shtml :
[code="html"]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>juliens cadsite - contact mogelijkheden</title>
<meta name="Title" content="juliens cadsite - contact mogelijkheden">
<meta name="Author" content="julien">
<meta name="Subject" content="autocad">
<meta name="Description" content="Hier vind je de contact mogelijkheden">
<meta name="Keywords" content="autocad, contact, chat, chatbox, adverteer, forum, Autocad, gratis, cursus, cad">
<meta name="Language" content="Nederlands">
<meta name="Revisit-After" content="30 Days">
<meta name="Robots" content="All">
<link rel="SHORTCUT ICON" href="http://www.cadsite.be/favicon.ico">
<link rel="stylesheet" type="text/css" href="http://www.cadsite.be/julien.css">
</head>
<body>
<div id="venster">
<script language="JavaScript" src="http://www.cadsite.be/cadmenu.js"></script>
<h1>Contact</h1>
<form action="mail.php" method="post">
<table>
<tr>
<td>Uw naam:</td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>Uw E-Mail adres:</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>Onderwerp</td>
<td><input type="text" name="subject"></td>
</tr>
<tr>
<td>Uw bericht:</td>
<td><textarea name="body" rows="10" cols="20"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="sent" value="Verstuur"></td>
</tr>
</table>
</form>
<br>
<!--#include virtual="/voet.html" -->
</div>
</body>
</html>[/code]
Mail.php:
[code="php"]<?php
/*
Simpel contact formulier script door Wido den Hollander <wido@pcextreme.nl>
*/
/* Instellingen */
// Naar welk e-mail adres moet de e-mail?
$rcptTo = "info@cadsite.be";
// Welke pagina moeten we tonen zodra de mail verstuurd is?
$thankYouPage = "http://www.cadsite.be/contact/bedankt.shtml";
// Welke pagina laten we zien als het versturen mislukt?
$errorPage = "http://www.cadsite.be/error/404.html";
// Welk onderwerp moet de e-mail krijgen? (Wordt genegeert als $_POST['subject']; is opgegeven)
$subject = "Contactformulier cadsite.be";
/* Einde instellingen! */
function isValidName($string){
return eregi("^[a-z0-9]*$",$string);
}
function isValidMailAddress($string){
return ereg("^[a-z0-9_\.-]+@[a-zA-Z0-9\.-]+\.[a-zA-Z]{2,4}$", $string);
}
if(!empty($_POST['subject']))
$subject = $_POST['subject'];
if(!isValidName($_POST['name']))
header("Location: ".$errorPage);
if(!isValidMailAddress($_POST['email']))
header("Location: ".$errorPage);
$headers = "From: ".$_POST['name']." <".$_POST['email'].">\r\n";
$headers .= "Return-Path: ".$_POST['email']."\r\n";
$headers .= "Reply-To: ".$_POST['email']."\r\n";
$headers .= "Content-Type: text/plain\r\n";
$headers .= "X-Mailer: PHP/".phpversion()."\r\n";
$headers .= "X-Abuse-Tracker: ".$_SERVER['REMOTE_ADDR']."\r\n";
if(!mail($rcptTo, $subject, $_POST['body'], $headers))
header("Location: ".$errorPage);
else
header("Location: ".$thankYouPage);
?>[/code]
En het scriptje dat je gepost hebt:
[code="php"]<?php
session_start ( );
srand ( microtime ( ) * 100000000 );
function gen_string ( $num_chars = 6 )
{
$chars = 'a b c d e f g h i j k l m n o p q r s t u v w x y z 1 2 3 4 5 6 7 8 9 0';
$chars = explode ( ' ', $chars );
for ( $i = 0; $i < $num_chars; $i++ )
{
if ( strlen ( $return ) < $num_chars )
{
$return .= $chars[rand ( 0, ( count ( $chars ) - 1 ) )];
}
}
return $return;
}
if ( $_POST )
{
if ( md5 ( base64_encode ( $_POST['code'] ) ) == $_POST['the_code'] )
{
die ( '<font color="#008000">Correcte Code!</font>' );
}
else
{
die ( '<font color="#800000">Foute Code!</font>' );
}
}
if ( isset ( $_GET['image'] ) )
{
// Alle instellingen:D
session_start ( );
$code = ( $_SESSION['string'] ) ? base64_decode ( $_SESSION['string'] ) : 'ReLoAd';
$lines = 25;
$dots = 100;
$width = strlen ( $code ) * 20;
$height = 30;
$im = imagecreate ( $width, $height );
// kleuren
$bg = imagecolorallocate ( $im, 0xff, 0xff, 0xff );
$text_color = imagecolorallocate ( $im, 0x00, 0x00, 0x00 );
$line_color = imagecolorallocate ( $im, 0x00, 0x80, 0x00 );
$dot_color = imagecolorallocate ( $im, 0x80, 0x00, 0x00 );
imagecolortransparent ( $im );
// lijnen
for ( $line = 0; $line < $lines; $line++ )
{
imageline ( $im, rand ( 0, $width ), rand ( 0, $height ), rand ( 0, $width ), rand ( 0, $height ), $line_color );
}
// stippen
for ( $dot = 0; $dot < $dots; $dot++ )
{
imagesetpixel ( $im, rand ( 0, $width ), rand ( 0, $height ), $dot_color );
}
// en nu het ECHTE werk:D
// de tekst
$chars = preg_split ( '//', $code );
$x = -12;
for ( $i = 0; $i < count ( $chars ); $i++ )
{
imagechar ( $im, rand ( 5, 5 ), $x, rand ( 0, $height - 15 ), $chars[$i], $text_color);
$x = $x + 20;
}
if ( function_exists ( 'imagegif' ) )
{
header ( 'Content-Type: image/gif' );
imagegif ( $im );
}
elseif ( function_exists ( 'imagejpeg' ) )
{
header ( 'Content-Type: image/jpeg' );
imagejpeg ( $im );
}
imagedestroy ( $im );
}
else
{
$characters = ( $_GET['chars'] ) ? $_GET['chars'] : 6;
$_SESSION['string'] = base64_encode ( gen_string ( $characters ) );
?>
<html dir="ltr">
<head>
<title>Verificatie Test</title>
</head>
<body bgcolor="grey">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="code" maxlength="6" size="6"> <img src="<?php echo $_SERVER['PHP_SELF']; ?>?image" height="30px" width="<?php echo ( 20 * $characters ); ?>px" alt="Code">
<br /><input type="hidden" name="the_code" value="<?php echo md5 ( $_SESSION['string'] ); ?>"><input type="submit">
</form>
</body>
</html>
<?php
}
?>[/code]