Hallo PHP-Gemeinde,
seit Tagen durchforste ich das Internet nach Spamfiltern (captcha) für ein Gästebuch.
Bin natürlich bei mehreren Scripten fündig geworden.
Nun habe ich eines in mein Script eingebaut, jedoch wird beim Brücken des Submit-Button nur das Captcha überprüft und nicht der Beitrag in das Gästebuch gleichzeitig eingetragen.
Meine Frage also: Wie kann ich es realisieren, daß der eine Submit-Button sowohl das Captcha prüft, also auch den Beitrag ins Gästebuch einträgt.
Für Eure Hilfe im Voraus schon mal Dankeschön.
Gruß
Tom
PS: Suche hier im Forum hab ich schon verwendet, vielleicht die falschen Schlüsselwörter, zumindest hab ich nichts passendes gefunden.
Ankündigung
Einklappen
Keine Ankündigung bisher.
[Erledigt] Submit Button mit 2 Funktionen
Einklappen
Neue Werbung 2019
Einklappen
X
-
[Erledigt] Submit Button mit 2 Funktionen
Stichworte: -
-
Ok, Danke.
Die betreffenden Zeilen in der functions.php habe ich jetzt auskommentiert.
Läuft alles super!
Viellen Dank nochmal an alle!!!!!!!!!
Gruß
Tom
-
na freut mich doch zu hören, zu den 2 meldungen mal soviel, das sind keine errors sondern nur notice also hinweise deswegen funktioniert der code weiterhin
hier steht beschrieben was die fehlermeldung besagt
FAQ der Newsgroups de.comp.lang.php.* - 28.16.*Notice: Undefined variable ...
zu den captcha das is so ne sache, also wirklich sicher sind die nicht
es gibt spambots die erkennen halt dein bild bzw den text den die da eintippen müssen, etwas sicherer sind die neuen captcha wo man zahlen ausrechnen muss, naja das is dann nich 100% userfreundlich wer hat schon bock zu rechnen beim formular ausfüllen...also du musst selber für dich einen mittelweg finden was du haben möchtest und was nicht aber dazu gibts es auch schon einige beiträge in foren und bei google
Einen Kommentar schreiben:
-
Unglaublich aber wahr!!!!!!!!
Es hat geklappt.
Hab in die check.php folgendes eingefügt:
PHP-Code:include("functions/config.php");
include("functions/functions.php");
include("functions/visitor.php");
Da ich ja nun in die check.php am Anfang error_reporting(E_ALL); reingeschreiben habe (wie in der Netiquette geforder) bleiben noch 2 Meldungen übrig, die aber nicht zu sehen sind, wenn error_reporting(E_ALL); nicht mehr in die check.php integriert ist.
Notice: Undefined variable: ok in /srv/webs/web11/gb/functions/functions.php on line 67
Notice: Undefined variable: ok in /srv/webs/web11/gb/functions/functions.php on line 88
Was hat es denn damit auf sich?
Dann hätte ich noch eine allgemeine Frage:
Ist so ein Captcha wirklich wirksam gegen Spam? Oder gibt es eine effektivere Methode um Gästebuch Spam auszuschließen?
Aber erstmal ein DICKES DANKESCHÖN an Euch Helfer!!!!!! Da wäre ich in 10 Jahren noch dran gesessen.
Tom
Einen Kommentar schreiben:
-
du rufst nun die funktion loaddata(); die wieder im code nicht gefunden wird weil die warscheinlich wo anderst entstanden istsame problem als grad eben da ich aber nich weiß wo du sie stehen hast also die function loaddata kann ich dir da immo nich weiterhelfen
Einen Kommentar schreiben:
-
Ui, da ist ja ne Diskussion entstanden.
Also ich hab versuchtPHP-Code:require("functions/functions.php");
Weiter hab ich die check.php und captcha.php aus dem Verz. captcha in das "Root-Verzeichnis" kopiert, wo auch die sb.php liegt.
Dann kommt aber beim Absenden
Fatal error: Call to undefined function loaddata() in /srv/webs/web11/gb/functions/functions.php on line 73
Meine check.php sieht jetzt so aus:
PHP-Code:<?php
// Session starten
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<?php
// Captcha überprüfen
if ($_POST["captcha"] == $_SESSION['captcha_code']) {
echo "<a href='sb.php'></a>";
// Eintrag ins Gäsebuch
require("functions/functions.php");
$_REQUEST['name'] = strip_tags($_REQUEST['name']);
$_REQUEST['name'] = trim($_REQUEST['name']);
if(!$html) $_REQUEST['text'] = htmlspecialchars($_REQUEST['text']);
$_REQUEST['text'] = trim($_REQUEST['text']);
if(!empty($_REQUEST['name']) && !empty($_REQUEST['text']))
{
$out = "";
$_REQUEST['email'] = strip_tags(trim($_REQUEST['email']));
if(strlen($_REQUEST['text']) > $maxlength && $maxlength > 0) $out .= "<li>"._tolong."</li>";
if(empty($_REQUEST['email']) && $angemail) $out .= "<li>"._nomail."</li>";
if(!checkmail($_REQUEST['email']) && !empty($_REQUEST['email'])) $out .= "<li>"._wrongmail."</li>";
$_REQUEST['icq'] = strip_tags(trim($_REQUEST['icq']));
if(preg_match("/\D/", $_REQUEST['icq']) && !empty($_REQUEST['icq'])) $out .= "<li>"._wrongicq."</li>";
$_REQUEST['homepage'] = strip_tags(trim($_REQUEST['homepage']));
if(!checkhp($_REQUEST['homepage']) && !empty($_REQUEST['homepage'])) $out .= "<li>"._wronghp."</li>";
if(antispam($antispam)) $out = "<li>"._spam."</li>";
$_REQUEST['text'] = stripslashes($_REQUEST['text']);
if(empty($out))
{
if($enablemail) @mail($mail,"GB-Eintrag / GB-Entry",
"<html><body><b>".date("d.m.Y - H:i", time())."</b><br><br>
<b>Name: </b>".$_REQUEST['name']."<br>
<b>Email: </b>".$_REQUEST['email']."<br>
<b>ICQ: </b>".$_REQUEST['icq']."<br>
<b>Homepage: </b>".$_REQUEST['homepage']."<br>
<b>Text: </b>".$_REQUEST['text']."</body></html>",
"From: \"AN-Guestbook\" <$mail>\nX-Mailer: PHP/" . phpversion()."\nMime-Version: 1.0\nContent-Type: text/html; charset=\"ISO-8859-1\"");
if($bbcode) $_REQUEST['text'] = bbcode($_REQUEST['text']);
else $_REQUEST['text'] = nl2br($_REQUEST['text']);
if($enreplace) $_REQUEST['text'] = replacement($_REQUEST['text'], $badwords);
if($ensmilies) $_REQUEST['text'] = smilies($_REQUEST['text'], $smilies);
$_REQUEST['text'] = ($chars>0) ? split_text($_REQUEST['text'], $chars) : $_REQUEST['text'];
$show = ($admincheck) ? 0 : 1;
writedata($show, array(time(), $getip, stripslashes($_REQUEST['name']), $_REQUEST['email'], $_REQUEST['icq'], $_REQUEST['homepage'], $_REQUEST['text']));
if($thanks)
{
$out .= "<center>"._thankyou."</center><br>";
}
if($admincheck)
{
$out .= "<center>"._check."</center><br>";
}
if(!empty($out))
{
$out .= "<br><center><a href=\"sb.php\">"._back."</a></center>";
echo tplprint("tpl/saved.tpl", array("MESSAGE" => $out));
}
else
{
header("Location: sb.php");
exit;
}
}
else
{
$tout = "<b>"._wrong."</b><br>\n<ul>";
$tout .= $out;
$tout .= "</ul>";
$tout .= "<br><center><a href=\"javascript:history.back(1)\">"._back."</a></center>";
echo tplprint("tpl/saved.tpl", array("MESSAGE" => $tout));
}
}
else
{
$out = "<b>"._missing."</b><br>";
$out .= "<ul>\n";
if(empty($_REQUEST['name'])) $out .= "<li>"._mname."</li><br>";
if(empty($_REQUEST['text'])) $out .= "<li>"._mcontent."</li><br>";
$out .= "</ul>";
$out .= "<br><center><a href=\"javascript:history.back(1)\">"._back."</a></center>";
echo tplprint("tpl/saved.tpl", array("MESSAGE" => $out));
}
}
// Ende Eintrag Gästebuch
else {
echo "Falsch";
}
// Session löschen
unset($_SESSION['captcha_code']);
?>
- <a href="submit.html">zurück</a>
</body>
</html>
PHP-Code:function antispam($antispam)
{
global $getip;
$data = loaddata(); <---- Zeile 73
foreach($data as $erg)
{
$erg = explode("::", $erg);
$cerg = 0;
foreach($erg as $terg)
{
$tmperg[$cerg] = base64_decode($terg);
$cerg++;
}
$erg = $tmperg;
if($erg[0]+$antispam > time() && trim($erg[1]) == $getip) $ok = TRUE;
}
return $ok;
}
Trotzdem bitte helfen und Tips und Tricks einbringen, ich kann nur daraus lernen
Gruß
Tom
Edit: ich habe jetzt mal in die Check.php error_reporting(E_ALL); eingefügt und siehe da, jetzt kommen noch ganz andere Hinweise...
Notice: Undefined variable: html in /srv/webs/web11/gb/check.php on line 26
Notice: Undefined variable: maxlength in /srv/webs/web11/gb/check.php on line 32
Notice: Undefined variable: maxlength in /srv/webs/web11/gb/check.php on line 32
Notice: Undefined variable: ok in /srv/webs/web11/gb/functions/functions.php on line 67
Notice: Undefined variable: antispam in /srv/webs/web11/gb/check.php on line 39
Fatal error: Call to undefined function loaddata() in /srv/webs/web11/gb/functions/functions.php on line 73
Vielleicht für euch auch noch hilfreich...
Einen Kommentar schreiben:
-
Zitat von nikosch77-new Beitrag anzeigenStopp!
Hört auf mit diesen copy & paste Arien! Auch sb.php wäre besser an der relevanten Stelle per Include eingebunden worden. Und die functions.php sowieso.
ja ich weiß ist nich die schöne feine art deswegen auch
include hab ich aber oben geschriebenam liebsten wäre natürlich oop :P
Einen Kommentar schreiben:
-
Stopp!
Hört auf mit diesen copy & paste Arien! Auch sb.php wäre besser an der relevanten Stelle per Include eingebunden worden. Und die functions.php sowieso.
Einen Kommentar schreiben:
-
include doch mal oben die functions.php in deine check.php dann is die dort auch verfügbar oder mach copy und paste und füge die checkmail function bei dir in die check.php oben ein
Einen Kommentar schreiben:
-
Die steht in der functions/functions.php
PHP-Code:...
function checkmail($mail)
{
if(strstr($mail, "@"))
{
$mail = explode ("@", $mail);
if(strstr($mail[1], ".")) $ok = TRUE;
}
return $ok;
}
...
Einen Kommentar schreiben:
-
Ja ich meinte check.php. Da fehlt die checkmail()-Funktion. Keine Ahnung wo die bei dir steht.
Einen Kommentar schreiben:
-
Habe den Code jetzt in die check.php eingesetzt.
Dann kommt folgender Fehler:
Fatal error: Call to undefined function checkmail() in /srv/webs/web11/gb/captcha/check.php on line 30
DAs wäre dann if(!checkmail($_REQUEST['email']) && !empty($_REQUEST['email'])) $out .= "<li>"._wrongmail."</li>";
hm... wo liegt denn da mein Fehler?
Einen Kommentar schreiben:
-
PHP-Code:$_REQUEST['name'] = strip_tags($_REQUEST['name']);
$_REQUEST['name'] = trim($_REQUEST['name']);
if(!$html) $_REQUEST['text'] = htmlspecialchars($_REQUEST['text']);
$_REQUEST['text'] = trim($_REQUEST['text']);
if(!empty($_REQUEST['name']) && !empty($_REQUEST['text']))
{
$out = "";
$_REQUEST['email'] = strip_tags(trim($_REQUEST['email']));
if(strlen($_REQUEST['text']) > $maxlength && $maxlength > 0) $out .= "<li>"._tolong."</li>";
if(empty($_REQUEST['email']) && $angemail) $out .= "<li>"._nomail."</li>";
if(!checkmail($_REQUEST['email']) && !empty($_REQUEST['email'])) $out .= "<li>"._wrongmail."</li>";
$_REQUEST['icq'] = strip_tags(trim($_REQUEST['icq']));
if(preg_match("/\D/", $_REQUEST['icq']) && !empty($_REQUEST['icq'])) $out .= "<li>"._wrongicq."</li>";
$_REQUEST['homepage'] = strip_tags(trim($_REQUEST['homepage']));
if(!checkhp($_REQUEST['homepage']) && !empty($_REQUEST['homepage'])) $out .= "<li>"._wronghp."</li>";
if(antispam($antispam)) $out = "<li>"._spam."</li>";
$_REQUEST['text'] = stripslashes($_REQUEST['text']);
if(empty($out))
{
if($enablemail) @mail($mail,"GB-Eintrag / GB-Entry",
"<html><body><b>".date("d.m.Y - H:i", time())."</b><br><br>
<b>Name: </b>".$_REQUEST['name']."<br>
<b>Email: </b>".$_REQUEST['email']."<br>
<b>ICQ: </b>".$_REQUEST['icq']."<br>
<b>Homepage: </b>".$_REQUEST['homepage']."<br>
<b>Text: </b>".$_REQUEST['text']."</body></html>",
"From: \"AN-Guestbook\" <$mail>\nX-Mailer: PHP/" . phpversion()."\nMime-Version: 1.0\nContent-Type: text/html; charset=\"ISO-8859-1\"");
if($bbcode) $_REQUEST['text'] = bbcode($_REQUEST['text']);
else $_REQUEST['text'] = nl2br($_REQUEST['text']);
if($enreplace) $_REQUEST['text'] = replacement($_REQUEST['text'], $badwords);
if($ensmilies) $_REQUEST['text'] = smilies($_REQUEST['text'], $smilies);
$_REQUEST['text'] = ($chars>0) ? split_text($_REQUEST['text'], $chars) : $_REQUEST['text'];
$show = ($admincheck) ? 0 : 1;
writedata($show, array(time(), $getip, stripslashes($_REQUEST['name']), $_REQUEST['email'], $_REQUEST['icq'], $_REQUEST['homepage'], $_REQUEST['text']));
if($thanks)
{
$out .= "<center>"._thankyou."</center><br>";
}
if($admincheck)
{
$out .= "<center>"._check."</center><br>";
}
if(!empty($out))
{
$out .= "<br><center><a href=\"gb.php\">"._back."</a></center>";
echo tplprint("tpl/saved.tpl", array("MESSAGE" => $out));
}
else
{
header("Location: gb.php");
exit;
}
}
else
{
$tout = "<b>"._wrong."</b><br>\n<ul>";
$tout .= $out;
$tout .= "</ul>";
$tout .= "<br><center><a href=\"javascript:history.back(1)\">"._back."</a></center>";
echo tplprint("tpl/saved.tpl", array("MESSAGE" => $tout));
}
}
else
{
$out = "<b>"._missing."</b><br>";
$out .= "<ul>\n";
if(empty($_REQUEST['name'])) $out .= "<li>"._mname."</li><br>";
if(empty($_REQUEST['text'])) $out .= "<li>"._mcontent."</li><br>";
$out .= "</ul>";
$out .= "<br><center><a href=\"javascript:history.back(1)\">"._back."</a></center>";
echo tplprint("tpl/saved.tpl", array("MESSAGE" => $out));
}
Diese Zeilen musst in die captcha.php kopieren. Und zwar an die Stelle, an die ich das Kommentar gemacht habe.
Macht nix. Wir haben auch alle mal gelernt.
Einen Kommentar schreiben:
-
Seither lief das aber nicht über eine php-Datei, sondern war so implementiert
Code:... <form method="post" action="sb.php"> <input type=hidden name="service" value="entry"> ... <input name="entry" type="submit" value="Submit"> </form> ....
PHP-Code:?php
// A-N Guestbook
// All rights by Tocsulus & BAERnado (www.code-box.de)
// Dateien dürfen nur auf code-box.de zum Download angeboten werden.
require("functions/config.php");
require("functions/functions.php");
require("functions/visitor.php");
switch($_REQUEST['service'])
{
case "entry":
$_REQUEST['name'] = strip_tags($_REQUEST['name']);
$_REQUEST['name'] = trim($_REQUEST['name']);
if(!$html) $_REQUEST['text'] = htmlspecialchars($_REQUEST['text']);
$_REQUEST['text'] = trim($_REQUEST['text']);
if(!empty($_REQUEST['name']) && !empty($_REQUEST['text']))
{
$out = "";
$_REQUEST['email'] = strip_tags(trim($_REQUEST['email']));
if(strlen($_REQUEST['text']) > $maxlength && $maxlength > 0) $out .= "<li>"._tolong."</li>";
if(empty($_REQUEST['email']) && $angemail) $out .= "<li>"._nomail."</li>";
if(!checkmail($_REQUEST['email']) && !empty($_REQUEST['email'])) $out .= "<li>"._wrongmail."</li>";
$_REQUEST['icq'] = strip_tags(trim($_REQUEST['icq']));
if(preg_match("/\D/", $_REQUEST['icq']) && !empty($_REQUEST['icq'])) $out .= "<li>"._wrongicq."</li>";
$_REQUEST['homepage'] = strip_tags(trim($_REQUEST['homepage']));
if(!checkhp($_REQUEST['homepage']) && !empty($_REQUEST['homepage'])) $out .= "<li>"._wronghp."</li>";
if(antispam($antispam)) $out = "<li>"._spam."</li>";
$_REQUEST['text'] = stripslashes($_REQUEST['text']);
if(empty($out))
{
if($enablemail) @mail($mail,"GB-Eintrag / GB-Entry",
"<html><body><b>".date("d.m.Y - H:i", time())."</b><br><br>
<b>Name: </b>".$_REQUEST['name']."<br>
<b>Email: </b>".$_REQUEST['email']."<br>
<b>ICQ: </b>".$_REQUEST['icq']."<br>
<b>Homepage: </b>".$_REQUEST['homepage']."<br>
<b>Text: </b>".$_REQUEST['text']."</body></html>",
"From: \"AN-Guestbook\" <$mail>\nX-Mailer: PHP/" . phpversion()."\nMime-Version: 1.0\nContent-Type: text/html; charset=\"ISO-8859-1\"");
if($bbcode) $_REQUEST['text'] = bbcode($_REQUEST['text']);
else $_REQUEST['text'] = nl2br($_REQUEST['text']);
if($enreplace) $_REQUEST['text'] = replacement($_REQUEST['text'], $badwords);
if($ensmilies) $_REQUEST['text'] = smilies($_REQUEST['text'], $smilies);
$_REQUEST['text'] = ($chars>0) ? split_text($_REQUEST['text'], $chars) : $_REQUEST['text'];
$show = ($admincheck) ? 0 : 1;
writedata($show, array(time(), $getip, stripslashes($_REQUEST['name']), $_REQUEST['email'], $_REQUEST['icq'], $_REQUEST['homepage'], $_REQUEST['text']));
if($thanks)
{
$out .= "<center>"._thankyou."</center><br>";
}
if($admincheck)
{
$out .= "<center>"._check."</center><br>";
}
if(!empty($out))
{
$out .= "<br><center><a href=\"gb.php\">"._back."</a></center>";
echo tplprint("tpl/saved.tpl", array("MESSAGE" => $out));
}
else
{
header("Location: gb.php");
exit;
}
}
else
{
$tout = "<b>"._wrong."</b><br>\n<ul>";
$tout .= $out;
$tout .= "</ul>";
$tout .= "<br><center><a href=\"javascript:history.back(1)\">"._back."</a></center>";
echo tplprint("tpl/saved.tpl", array("MESSAGE" => $tout));
}
}
else
{
$out = "<b>"._missing."</b><br>";
$out .= "<ul>\n";
if(empty($_REQUEST['name'])) $out .= "<li>"._mname."</li><br>";
if(empty($_REQUEST['text'])) $out .= "<li>"._mcontent."</li><br>";
$out .= "</ul>";
$out .= "<br><center><a href=\"javascript:history.back(1)\">"._back."</a></center>";
echo tplprint("tpl/saved.tpl", array("MESSAGE" => $out));
}
break;
case "uin":
if($_REQUEST['uin'])
{
addicq($_REQUEST['uin']);
break; // Falls keine UIN übermittelt, normal GB laden
}
default:
$data = array_reverse(loaddata());
$table = "";
$i=0;
$entrynum = count($data);
foreach($data as $erg)
{
if($i >= $_REQUEST['cc'])
{
$erg = explode("::", $erg);
$tth = 0;
foreach($erg as $tempd)
{
$ergtemp[$tth] = (($tth == 4) && ($encodemails)) ? $tempd : base64_decode($tempd);
$tth++;
}
$erg = $ergtemp;
unset($ergtemp);
$erg[4] = trim($erg[4]);
if(!empty($erg[4]))
{
$erg[4] = ($encodemails) ? "<script language=\"JavaScript\">writemail(\"".$erg[4]."\")</script>" : "<a href=\"mailto:".$erg[4]."\"><img src=\"img/mail.gif\" alt=\"Email\" border=0></a>";
}
$erg[5] = trim($erg[5]);
if(!empty($erg[5])) $erg[5] = "<a href=\"gb.php?service=uin&uin=".$erg[5]."\"><img src=\"img/icq.gif\" alt=\"ICQ\" border=0></a>";
$erg[6] = trim($erg[6]);
if(!empty($erg[6])) $erg[6] = "<a href=\"".$erg[6]."\" target=\"_blank\"><img src=\"img/hp.gif\" alt=\"Homepage\" border=0></a>";
if(empty($erg[4]) && empty($erg[5]) && empty($erg[6])) $erg[5] = _nodata;
if(!empty($erg[8])) $erg[8] = _comment.$erg[8];
$table .= tplprint("tpl/table.tpl", array(
"NAME" => $erg[3],
"EMAIL" => $erg[4],
"ICQ" => $erg[5],
"HP" => $erg[6],
"CONTENT" => $erg[7],
"COMMENT" => $erg[8],
"DATE" => date("d.m.Y", $erg[1]),
"TIME" => date("H:i", $erg[1]),
"NUMBER" => ($entrynum-$i)));
if($i == $entries+$_REQUEST['cc']-1) break;
unset($erg);
}
$i++;
}
$mnum = $entrynum;
$sites = "";
$i=-$entries;
$ic = 1;
while($mnum>0)
{
$mnum = $mnum - $entries;
$i = $i + $entries;
if($_REQUEST['cc'] == $i) $sites .= "<b>$ic</b> ";
else $sites .= "<a href=\"gb.php?cc=$i\">$ic</a> ";
$ic++;
}
$menu = tplprint("tpl/menu.tpl", array(
"ENTRYNUM" => $entrynum,
"SITES" => $sites));
echo tplprint("tpl/index.tpl", array(
"ENTRIES" => $table,
"MENU" => $menu,
"SUBMIT" => tplprint("tpl/submit.tpl", array())));
}
?>
Gruß
Tom
Einen Kommentar schreiben:
Einen Kommentar schreiben: