Du befindest Dich im Archiv vom ABAKUS Online Marketing Forum. Hier kannst Du Dich für das Forum mit den aktuellen Beiträgen registrieren.

mail.php ohne Java Script?

Ajax, Hijax, Microformats, RDF, Markup, HTML, PHP, CSS, MySQL, htaccess, robots.txt, CGI, Java, Javascript usw.
Neues Thema Antworten
Ecki
PostRank 1
PostRank 1
Beiträge: 3
Registriert: 25.09.2007, 07:10

Beitrag von Ecki » 25.09.2007, 07:25

Hallo zusammen,
ich hab mich schon durch sämtliche Foren gewuselt, kann aber nix passendes finden. Ich muß dazu sagen, dass ich in Sachen php nicht gerade der fitteste bin.
Mein Problem:
Ich habe eine html-Seite (formular.php) mit einem Formular.
Über dieses Formular kommen ziemlich viele Spammails und nun möchte ich ein script verwenden, welches diese Spammails unterbinden soll.
Ich habe mir mittlerweile ein Script aus dem Netz besorgt, das funktioniert soweit auch alles.
Nur wenn ich Javascript deaktiviere, sendet die mail.php trotzdem eine leere email an mich.
Wie kann ich das Script erweitern, damit es auch ohne Javascript vernünftig läuft?
Ich hoffe, ihr habt nix dagegen, wenn ich die Datei mal hier poste:

Code: Alles auswählen

<?php
// L10Fm - v1.3 &#40;11/10/06&#41; &#40;patched for XSS&#41;
// requirements for session data -
//	1. LevelTen Hit Counter PHP v3.15 rel 3
//	2. L10HC_API.php v3.15 v1.0 rel 1
//

//////////////////////////////////////////////////////////////////////////////////////
//
// configuration variables
//
//////////////////////////////////////////////////////////////////////////////////////

// List all domains, including posible subdomains &#40;e.g. www.&#41; that are allowed to submit
// requests to this script and the domains of any posible recipient email address.

$validReferrers = array&#40;'sitedomain.com','www.sitedomain.com','emaildomain.com',''&#41;;

// Use the this array &#40;or create new arrays with a different association&#41; to replace
// setting fields in the form. Don't delete the 'default' array.

$formAction&#91;'default'&#93; = array&#40;
	'recipient' => 'emailalias@emaildomain.com',
	'recipient_cc' => '',
	'recipient_bcc' => '',
	'subject' => 'LevelTen Formmail Test',
	'redirect' => 'http&#58;//www.leveltendesign.com/L10Apps/Fm/success.php',
	'email' => '',
	'realname' => '',
	'required' => '',
	'format' => 'html',
	'sesrep_max_items' => '10',
&#41;;

// If set to 0, the form can set the email recipient. For security reasons you should
// always set this variable to 1.

define&#40;'DISABLE_FORM_RECIPIENTS', 1&#41;;

//////////////////////////////////////////////////////////////////////////////////////
//
// Start of code
// Don't edit below this line
//
//////////////////////////////////////////////////////////////////////////////////////

$pageHdr = "<html><head><style>td &#123;font&#58; x-small, verdana, arial, helvetica, sans-serif;&#125; h1 &#123;font-size&#58; medium;&#125; .err &#123;color&#58; #EE0000; font-weight&#58; bold;&#125;</style></head><body bgcolor=#FFFFFF><table width='500' align=center><tr><td>";
$pageFtr = "</td></tr>\n</body></html>";

$L10_LIBLoaded = 0;
if&#40;file_exists&#40;"L10_LIB.php"&#41;&#41; &#123;
	include_once&#40;"L10_LIB.php"&#41;;
	$L10_LIBLoaded = 1;
&#125;

$http_ref = $_SERVER&#91;'HTTP_REFERER'&#93;;
$array = parse_url&#40;$http_ref&#41;;
$a = $array&#91;'host'&#93;;

if&#40;!in_array&#40;$a,$validReferrers&#41;&#41; &#123;
	print "$pageHdr<p class=err>Invalid Referrer '$a'</p><p>Referrer does not have permission to access this LevelTen Formmail script.<p>For help on this issue, see <a href='http&#58;//www.leveltendesign.com/L10Apps/Fm/help_troubleshooting.php#invalidReferrer?hct=L10Fm-ErrMsg' target=_blank>LevelTen Formmail troubleshooting</a>$pageFtr";
	exit;
&#125;

if&#40;! $_POST&#91;'form_action'&#93; or ! $formAction&#91;$_POST&#91;'form_action'&#93;&#93;&#91;'recipient'&#93;&#41; &#123;
	$fAIndex = 'default';
&#125; else &#123;
	$fAIndex = $_POST&#91;'form_action'&#93;;
&#125;

$recipient  = &#40;! DISABLE_FORM_RECIPIENTS && &#40;$_POST&#91;'recipient'&#93; != ''&#41;&#41; ? $_POST&#91;'recipient'&#93; &#58; $formAction&#91;$fAIndex&#93;&#91;'recipient'&#93;;
$subject  = &#40;$_POST&#91;'subject'&#93; != ''&#41; ? $_POST&#91;'subject'&#93; &#58; $formAction&#91;$fAIndex&#93;&#91;'subject'&#93;;
$redirect = &#40;$_POST&#91;'redirect'&#93; != ''&#41; ? $_POST&#91;'redirect'&#93; &#58; $formAction&#91;$fAIndex&#93;&#91;'redirect'&#93;;
$email = &#40;$_POST&#91;'email'&#93; != ''&#41; ? $_POST&#91;'email'&#93; &#58; $formAction&#91;$fAIndex&#93;&#91;'email'&#93;;
$realname = &#40;$_POST&#91;'realname'&#93;&#41; ? $_POST&#91;'realname'&#93; &#58; $formAction&#91;$fAIndex&#93;&#91;'realname'&#93;;
$recipient_cc  = &#40;! DISABLE_FORM_RECIPIENTS && &#40;$_POST&#91;'recipient_cc'&#93; != ''&#41;&#41; ? $_POST&#91;'recipient_cc'&#93; &#58; $formAction&#91;$fAIndex&#93;&#91;'recipient_cc'&#93;;
$recipient_bcc  = &#40;! DISABLE_FORM_RECIPIENTS && &#40;$_POST&#91;'recipient_bcc'&#93; != ''&#41;&#41; ? $_POST&#91;'recipient_bcc'&#93; &#58; $formAction&#91;$fAIndex&#93;&#91;'recipient_bcc'&#93;;
$format = &#40;$_POST&#91;'format'&#93; != ''&#41; ? $_POST&#91;'format'&#93; &#58; $formAction&#91;$fAIndex&#93;&#91;'format'&#93;;
$required  = &#40;$_POST&#91;'required'&#93; != ''&#41; ? $_POST&#91;'required'&#93; &#58; $formAction&#91;$fAIndex&#93;&#91;'required'&#93;;
$sesrep_max_items  = &#40;$_POST&#91;'sesrep_max_items'&#93; != ''&#41; ? $_POST&#91;'sesrep_max_items'&#93; &#58; $formAction&#91;$fAIndex&#93;&#91;'sesrep_max_items'&#93;;
$recipient_secured  = &#40;$_POST&#91;'recipient_secured'&#93; != ''&#41; ? $_POST&#91;'recipient_secured'&#93; &#58; $formAction&#91;$fAIndex&#93;&#91;'recipient_secured'&#93;;

$a = explode&#40;"@",$recipient&#41;;
$a = array_pop&#40;$a&#41;;
if&#40;!in_array&#40;$a,$validReferrers&#41;&#41; &#123;
	print "$pageHdr<p class=err>Invalid Recipient '$recipient'</p><p> Email address does not have permission to relay through this LevelTen Formmail script.<p>For help on this issue, see <a href='http&#58;//www.leveltendesign.com/L10Apps/Fm/help_troubleshooting.php#invalidReferrer?hct=L10Fm-ErrMsg' target=_blank>LevelTen Formmail troubleshooting</a>$pageFtr";
	exit;
&#125;

$rccArray = explode&#40;",",$recipient_cc&#41;;
$recipient_cc = '';
if&#40;$rccArray&#91;0&#93; != ''&#41; &#123;
	foreach&#40;$rccArray as $rcc&#41; &#123;
		$a = explode&#40;"@",$rcc&#41;;
		$a = array_pop&#40;$a&#41;;
		if&#40;in_array&#40;$a,$validReferrers&#41;&#41; &#123;
			$recipient_cc .= "$rcc,";
		&#125;
	&#125;
&#125;
$recipient_cc = substr&#40;$recipient_cc,0,-1&#41;;

$rbccArray = explode&#40;",",$recipient_bcc&#41;;
$recipient_bcc = '';
if&#40;$rbccArray&#91;0&#93; != ''&#41; &#123;
	foreach&#40;$rbccArray as $rbcc&#41; &#123;
		$a = explode&#40;"@",$rbcc&#41;;
		$a = array_pop&#40;$a&#41;;
		if&#40;in_array&#40;$a,$validReferrers&#41;&#41; &#123;
			$recipient_bcc .= "$rbcc,";
		&#125;
	&#125;
&#125;
$recipient_bcc = substr&#40;$recipient_bcc,0,-1&#41;;

$a = explode&#40;",",$required&#41;;
if&#40;$a&#91;0&#93; != ''&#41; &#123;
	foreach&#40;$a as $req&#41; &#123;
		if&#40;$_POST&#91;$req&#93; == ''&#41; &#123;
			print "$pageHdr<p class=err>Required Field '$req' is missing!</p><p> You must input a value for this field before submitting<p align=center><a href=\"".$HTTP_REFERER."\">back to form</a>$pageFtr";
			exit;
		&#125;
	&#125;
&#125;


$htmlFormat = &#40;strtolower&#40;substr&#40;$format,0,1&#41;&#41; == 'h'&#41;;

$msg = '';
if&#40;$htmlFormat&#41; &#123;
	$msg = "<html><head><style>td &#123;font&#58; x-small, verdana, arial, helvetica, sans-serif;&#125; .fldname &#123;font-weight&#58;bold;font-size&#58;x-small;&#125; .flddata &#123;font-size&#58;x-small;&#125; .tblhdr &#123; font-size&#58;x-small;font-weight&#58;bold;color&#58;#FFFFFF;background-color=#000088&#125;</style></head><body>\n";
	$msg .= "<table border=0 cellspacing=0 cellpadding=0 width=640>\n";
	$msg .= "<tr><td colspan=3 class='tblhdr'>Form Data</td></tr>\n";
&#125; else &#123;
	$msg = "Form data\n\n";
&#125;

$bl0 = '';
$bl1 = '';
$ld = ' ';
$el = "\n\n";

$creditStrAdd = '';

if&#40;$htmlFormat&#41; &#123;
	$bl0 = '<tr bgcolor=#E8E8FF><td class="fldname" valign=top>';
	$bl1 = '<tr bgcolor=#FFFFFF><td class="fldname" valign=top>';
	$ld = '</td><td> &nbsp; </td><td width=80% class="flddata">';
	$el = "</td></tr>\n";
&#125;
$i = 0;
foreach&#40;$_POST as $k => $v&#41; &#123;
	if&#40;$htmlFormat&#41; &#123;
		$v = str_replace&#40;"\n","<br>\n",$v&#41;;
	&#125;
	if&#40;$i&#41; &#123;
		$msg .= "$bl0$k&#58;$ld$v$el";
	&#125; else &#123;
		$msg .= "$bl1$k&#58;$ld$v$el";
	&#125;
	$i = !$i;
&#125;

if&#40;file_exists&#40;"L10HC_API.php"&#41;&#41; &#123;
	include&#40;"L10HC_API.php"&#41;;
	$vID = getVID&#40;&#41;;
	if&#40;$htmlFormat&#41; &#123;
		$msg .= "<tr><td colspan=3><br>&nbsp;<br></td></tr>\n<tr><td colspan=3 border=1>";
		$creditStrAdd = ' & LevelTen Hit Counter';
	&#125; else &#123;
		$msg .= "\n\n";
		$creditStrAdd = ' & LevelTen Hit Counter';
	&#125;
	$msg .= getSessions&#40;$vID,$max_sessions,$recipient_secured,$htmlFormat+1&#41;;
	if&#40;$htmlFormat&#41; &#123;
		$msg .= "</td></tr>\n";
	&#125; else &#123;

	&#125;
&#125;

if&#40;$htmlFormat&#41; &#123;
	$msg .= "<tr><td colspan=3>&nbsp;</td></tr><tr><td colspan=3 align=center>Generated by<br>LevelTen Formmail$creditStrAdd<td></tr></table></body></html>\n";
&#125; else &#123;
	$msg .= "\n\nGenerated by LevelTen Formmail$creditStrAdd\n";
&#125;



if &#40;! preg_match&#40;"/^&#91;^@\s&#93;+@&#40;&#91;-a-z0-9&#93;+\.&#41;+&#91;a-z&#93;&#123;2,&#125;$/i", $recipient, $result&#41;&#41; &#123;echo "Invalid recipient"; exit;&#125;
if &#40;strlen&#40;$recipient&#41; > 80 or strlen&#40;$recipient_cc&#41; > 200 or strlen&#40;$recipient_bcc&#41; > 200&#41; &#123;echo "Possible hack attempt"; exit;&#125;
if&#40;stristr&#40;$subject, "Bcc&#58;"&#41; or stristr&#40;$subject, "cc&#58;"&#41; or stristr&#40;$subject, "to&#58;"&#41;&#41; &#123;echo "Invalid content in subject"; exit;&#125;
if&#40;stristr&#40;$msg, "Bcc&#58;"&#41; or stristr&#40;$msg, "cc&#58;"&#41; or stristr&#40;$msg, "to&#58;"&#41;&#41; &#123;echo "Invalid content in message"; exit;&#125;
if&#40;stristr&#40;$realname, "Bcc&#58;"&#41; or stristr&#40;$realname, "cc&#58;"&#41; or stristr&#40;$realname, "to&#58;"&#41; or stristr&#40;$realname, "Content-type"&#41;&#41; &#123;echo "Invalid content"; exit;&#125;
if&#40;stristr&#40;$email, "Bcc&#58;"&#41; or stristr&#40;$email, "cc&#58;"&#41; or stristr&#40;$email, "to&#58;"&#41;&#41; &#123;echo "Invalid content"; exit;&#125;


$extraHeaders = "";
if&#40;$email&#41; &#123; $extraHeaders .= "From&#58; \"". $realname ."\" <". trim&#40;$email&#41; .">\r\n"; &#125;
if&#40;$email&#41; &#123; $extraHeaders .= "Return-Path&#58; ". trim&#40;$email&#41; ."\r\n"; &#125;
if&#40;$email&#41; &#123; $extraHeaders .= "Reply-To&#58; ". trim&#40;$email&#41; ."\r\n"; &#125;
if&#40;$htmlFormat == 'h'&#41; &#123; $extraHeaders .= "Content-type&#58; text/html\r\n"; &#125;
if&#40;$recipient_cc != ''&#41; &#123; $extraHeaders .= "Cc&#58; ". trim&#40;$recipient_cc&#41; ."\r\n"; &#125;
if&#40;$recipient_bcc != ''&#41; &#123; $extraHeaders .= "Bcc&#58; ". trim&#40;$recipient_bcc&#41; ."\r\n"; &#125;

$success = 1;
$success = mail&#40;$recipient,$subject,$msg,$extraHeaders&#41;;

if&#40;!$success && $L10_LIBLoaded&#41; &#123;
	log_event&#40;"Unsuccesful Email Attempt&#58; $recipient"&#41;;
&#125;

//print "mail&#40;$recipient,$subject,$msg,$extraHeaders&#41;";
//print "$msg";

header&#40;"Location&#58; $redirect"&#41;;
?>
Würd mich freuen, wenn mir jemand helfen würde... :roll:

Anzeige von ABAKUS

von Anzeige von ABAKUS »

Content Erstellung von ABAKUS Internet Marketing
Ihre Vorteile:
  • einzigartige Texte
  • suchmaschinenoptimierte Inhalte
  • eine sinnvolle Content-Strategie
  • Beratung und Umsetzung
Jetzt anfragen: 0511 / 300325-0

wolli
PostRank 9
PostRank 9
Beiträge: 1395
Registriert: 01.01.2006, 18:48

Beitrag von wolli » 25.09.2007, 18:23

hi,

warum nimmt du nicht einfach die PHP mailfunktion
und überprüfst ob das Formular von deiner Webseite aufgerufen wurde

nette Grüße
wolli

Ecki
PostRank 1
PostRank 1
Beiträge: 3
Registriert: 25.09.2007, 07:10

Beitrag von Ecki » 26.09.2007, 06:44

Hallo Wolli,
genau das macht ja dieses Script, ich brauchte nichtmal irgendwelche Formulardaten anpassen.
Wie gesagt, es funktioniert, nur hab ich nicht den blassesten Schimmer, wo oder wie ich was verändern muß, damit das Script auch ohne Javascript richtig funktioniert.
Ich schätze mal, dass in der formular.php was geändert werden muß?

Anzeige von ABAKUS

von Anzeige von ABAKUS »

SEO Consulting bei ABAKUS Internet Marketing
Erfahrung seit 2002
  • persönliche Betreuung
  • individuelle Beratung
  • kompetente Umsetzung

Jetzt anfragen: 0511 / 300325-0.


Ecki
PostRank 1
PostRank 1
Beiträge: 3
Registriert: 25.09.2007, 07:10

Beitrag von Ecki » 27.09.2007, 06:57

Ich glaub ich habs gelöst.
Ich habe diesen code oben an das Script angehängt.

Nun habe ich noch ene andere Frage.
Wenn ich nun nach dem Versand zurück klicke, bekomme ich das Formular mit all den zuvor angegeben Daten wieder angezeigt.
Gibts da eine Lösung, dass die Daten aus dem Formular nach dem Versand gelöscht werden?

Gruß
Ecki

Code: Alles auswählen

<?php


$mail=$HTTP_POST_VARS&#91;'email'&#93;;

if&#40;!$_POST&#91;'email'&#93;&#41;
&#123;
echo "<html>
<head>
<title>Fehler</title>
</head>
<body>
<br />
<p align=\"center\">Fehler<br />Bitte gib Deine Email Adresse an.</p>
</body>
</html>";
&#125;
else
&#123;

Antworten
  • Vergleichbare Themen
    Antworten
    Zugriffe
    Letzter Beitrag