"emailadres", Dit wordt gebruikt om ieder onderwerp naar een eigen emailadres te sturen en niet altijd aan dezelfde. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ $onderwerpadres = array( "I want to send you my compliments for this nice form" => "hgb@users.sourceforge.net", "You removed the compliment text? Type here a different one ..." => "you@your_provider.com", "... and many more if you like ..." => "email@example.net", "This last line may not end with a komma ','" => "email@example.org" ); // Veranderingen vanaf hier zijn niet op mijn lasten :) // Changes below this line are not my fault :) $copyright="\n\nSendEmail.php 1.0 (C) 2010 Hans-Georg Bork (hgb@users.sourceforge.net)\n\nDownload this from http://hgbhome.net/software/sendemail.tar.gz"; /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is a fix if register_globals is turned off ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ if(!$PHP_SELF){ if($_POST) {extract($_POST, EXTR_PREFIX_SAME, "post_");} if($_GET) {extract($_GET, EXTR_PREFIX_SAME, "get_");} if($_COOKIE) {extract($_COOKIE, EXTR_PREFIX_SAME, "cookie_");} if($_ENV) {extract($_ENV, EXTR_PREFIX_SAME, "env_");} } if($PHP_SELF == ""){ $PHP_SELF = $_SERVER['PHP_SELF']; } $ip = getenv("REMOTE_ADDR"); $httpagent = getenv("HTTP_USER_AGENT"); $httpref = getenv("HTTP_REFERER"); // check fields function field_errors( $naam, $adres, $bericht) { $naamfout = false; $adresfout = false; $berichtfout = false; $fieldfout = false; if( strlen($naam) <= 3 ) { $naamfout = true; } if( strlen($adres) <= 6 || !strstr($adres,"@") || !strstr($adres,".")) { $adresfout = true; } if( strlen($bericht) <= 3 ) { $berichtfout = true; } foreach( $_REQUEST as $fields => $value ) { if( eregi("TO:", $value) || eregi("CC:", $value) || eregi("CCO:", $value) || eregi("BCC:", $value) || eregi("Content-Type", $value) ) { $fieldfout = true; } // if( eregi ... } // foreach if( $naamfout || $adresfout || $berichtfout || $fieldfout ) { print "

Er is een fout opgetreden

"; if( $naamfout ) print "

Your name is too short.

"; if( $adresfout ) print "

Your emailadress is wrong.

"; if( $berichtfout ) print "

Your message is too short.

"; if( $fieldfout ) print "

ERROR: Code injection attempt denied!
Don't try to use 'TO:', 'CC:', 'CCO:', 'BCC:' of 'Content-Type' in this form.

"; print "
"; print "

"; print "


"; return true; } // if( $naamfout || ... return false; } // field_errors() // avoid wrong calls $defaultaction = FALSE; if( !isset( $action ) || ($action != "view" && $action != "send" )) { $defaultaction = TRUE; } if( $defaultaction ) { unset( $action ); // to be able to use it in form $onderwerpoptions = ""; foreach( $onderwerpadres as $onderwerp => $emailadres ) { $onderwerpoptions .= "\n"; } print <<Mailform

Name:
Emailadress:
Subject:
Message:
Want a copy of this?   No   Yes



$copyright

HTML; } // if( $defaultaction ) if( $action == "view" && !field_errors( $naam, $adres, $bericht ) ) { $txtccopy = (($ccopy == "ccja") ? "" : "don't"); print <<Preview of your email

Name:
Emailadress:
Subject:
Message:
You $txtccopy want a copy of this mail.



$copyright

HTML; } // if( $action == "view" ) if( $action == "send" ) { $emailheader = "From: mailform@hgbhome.net\r\n"; $emailheader = $emailheader . "Reply-To: " . $adres . "\r\n"; $emailto = $onderwerpadres[$onderwerp]; $emailsubject = $onderwerp; $emailmessage = "Mailform on $httpref\n\n"; $emailmessage .= "Name : " . $naam . "\nEmailadress : " . $adres . "\nSubject : " . $onderwerp . "\n"; $emailmessage .= "Message :\n" . $bericht . "\n"; $emailsuccessadres = TRUE; if( $ccopy == "ccja" ) { $emailsuccessadres = mail( $adres, $emailsubject, $emailmessage . $copyright, $emailheader ); } $emailmessage .= "\nFurther information:\nIP-adres: " . $ip . "\nBrowser: " . $httpagent . "\n"; $emailsuccessto = mail( $emailto, $emailsubject, $emailmessage . $copyright, $emailheader ); if( $emailsuccessto && $emailsuccessadres ) { print "

Your email is submitted

"; print "

"; } else { print "

An error occured.
Your email is not submitted.

"; print "

"; } // if( mail( ... print "


$copyright

"; } // if( $action == "send" ) ?>