De laatste tijd word mijn forum dagelijks volgespamt met cheap viagra en dat soort troep. Ik wil dit graag stoppen maar zou niet weten hoe, weet iemand mischien een link naar een tutorial ofzo waarmee ik dit kan oplossen?
Is het elke keer hetzelfde IP adres?
Dan zo je in .htacces het IP kunnen blokkeren.
gewoon even kijken of er woorden in de post voorkomen als 'cheap' of 'viagra' of 'v1agra'.

Zo ja, dan kan er niet gepost worden, zo nee, dan kan er wel gepost worden.
njah hij checkt het ip-adres helaas (nog) niet dus dat ga ik eerst inbouwen, en verder een woordenfilter is idd ook goed idee

bedankt beide!
Mooi dit al opgelost
Wouter? Jou post voegt wat toe ofzo?

tom vd; krijg je spam met heel veel <A HREF="..">..</A> en [ignore]..[/ignore]?

Wat ik heb gedaan, in een website waar dit het geval was, was het volgende. Erg simpele oplossing, maar het werkt voor nu:

<?
$txt = "Input van je gastenboek o.i.d.";

$arr_links = explode("A HREF", $txt);
$arr_url = explode("[url", $txt);
if (count($arr_url) > 2 || count($arr_links) > 2)
echo "Spam..";
else
echo "Input in database";
?>

;)


Nog even een vraagje, je ziet ook wel eens dat je een code uit een plaatje moet overnemen. Weet iemand hoe ik dit er ook nog in kan bouwen?

Aangezien ip's meestal om de zoveel tijd worden veranderd en een filter voor woorden makkelijk kan worden doorbroken door gewoon een ander woord daar neer te zetten...
Zoek even in de scriptlib op captcha voor zo'n plaatje
Ik heb uiteindelijk iets gevonden. En dat heb ik geprobeerd in te bouwen, echter werkt het nu niet meer.

Het captcha script zelf:

<?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 = 10;
    $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="#333333">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="code" maxlength="6" size="6">&nbsp;&nbsp;&nbsp;<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
}
?> 


En het script waar ik het heb ingebouwd:

<?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 = 10;
    $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 ) );
?>
<?php
error_reporting(E_ALL);
ob_start(); ?>

<?php include("functies.php"); ?>
<?php include("style1.inc.php"); ?>
<?php include("config.php"); ?>
<body bgcolor="#333333">

<style> BODY{scrollbar-3dlight-color:#333333;scrollbar-highlight-color:;scrollbar-face-color:#545454;scrollbar-shadow-color:;scrollbar-track-color:#333333;scrollbar-arrow-color:#333333;scrollbar-darkshadow-color:#FFFFFF;} </style>

<html>
  <head>

    <title>Schrijf een bericht in het gastenboek</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript">
    //Deze functie hebben we later nodig voor de UBB code
    function Invoegen(Smiley) {
      var edit;
      var HuidigeTekst = document.gastenboek.bericht.value;
      edit = HuidigeTekst+Smiley+" ";
      document.gastenboek.bericht.value=edit;
      document.gastenboek.bericht.focus();
      return;
    }   
    
    function smiley() {
      return;      
    }
    </script>
  </head>
  <body>

<?php
  if (isset($_POST['Submit'])) {

    if (!trim($_POST['naam'])) {
        $error="Je moet je naam invullen";
    }
    elseif(!check_email($_POST['emailadres'])) {
        $error="Je moet een geldig e-mailadres invullen";
    }
    elseif (!trim($_POST['bericht'])) {
      $error="Je moet een bericht invullen";
    }
    elseif ($_COOKIE['Gastenboek'] == "1") {
      $error="Je kan geen bericht posten omdat je er al één hebt gepost";
    }
    
    //Als er een veld niet is ingevuld of wanneer het e-mailadres niet bestaat komt er een error

    if ($error != "") {            
?>
  <center>
    <table class="gastenboek" width="100%" border="1" cellspacing="0" cellpadding="2">
      <tr>
        <td>
          <center>
                <b><?=$error?></b><br>
          <form method="post" action="javascript:history.go(-1)">
            <input type="submit" name="Terug" value="Terug" />
          </form>
          </center>
        </td>
      </tr>
    </table>
  </center>
<?php
    } else {
      //Als alles correct is ingevuld gaan we over naar het posten van de gegevens naar de database
      mysql_query ("INSERT INTO gastenboek (naam, emailadres, bericht, datum) VALUES ('".$_POST['naam']."', '".$_POST['emailadres']."', '".$_POST['bericht']."', NOW())") or die (mysql_error());

      //Om SPAM te vermijden maken we een COOKIE (zie config)
      setcookie (Gastenboek, 1, $tijd_cookie);

      //Na het verzenden sturen we de gebruiker terug naar het gastenboek
      header ("location: ".$pagina_lezen);
    }
    
  } else {
  ?>
  <center>
    <form name="gastenboek" action="" method="post">
        <table class="gastenboek" width="100%" border="1" cellspacing="0" cellpadding="2">
            <tr>
              <td height="20" colspan="2"><strong>Bericht posten in het gastenboek:</strong></td>
            </tr>
            <tr>
              <td width="44%">Naam:</td>
          <td width="56%">
                  <input name="naam" type="text" id="naam"  size="30" maxlength="50" />
              </td>
            </tr>
            <tr>
              <td>E-mail adres:</td>
              <td>
                  <input name="emailadres" type="text" id="emailadres"  size="30" maxlength="50" />            
              </td>
            </tr>
<tr>
<td>Verificatie:</td>
<td>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="text" name="code" maxlength="6" size="6">&nbsp;&nbsp;&nbsp;<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'] ); ?>">
</form>
<?php
}
?> 
</td>
</tr>
            <tr>
              <td align="center" colspan="2">Bericht:</td>
            </tr>
            <tr>
              <td align="center" colspan="2">
            <table width="27%" border="0" cellspacing="0" cellpadding="0">          
                    <tr>         
                        <td align="center" height="21" colspan="4">
                  <small><i><b>Ubb-code:</b></i></small>
                </td>
              </tr>       
                    <tr>     
                        <td align="center" height="27" colspan="4">               
                          <input type="button" name="b" value="B" style="font-weight: bold; width: 30px;" onClick="javascript:Invoegen('[B]...[/B]');" />
                          <input type="button" name="u" value="U" style="text-decoration: underline; width: 30px;" onClick="javascript:Invoegen('[U]...[/U]');" />
                          <input type="button" name="i" value="I" style="font-style: italic; width: 30px;" onClick="javascript:Invoegen('[I]...[/I]');" />
                          <input type="button" name="s" value="S" style="text-decoration: line-through; width: 30px;" onClick="javascript:Invoegen('[S]...[/S]');" />       
                          <input type="button" name="url" value="http://" onClick="javascript:Invoegen('[URL=http://...]...[/URL]');" />
                        </td>
                    </tr>
                     <tr>
                        <td align="center" height="21" colspan="4">   
                          <input type="button" name="align" value="Align" onClick="javascript:Invoegen('[ALIGN=...]...[/ALIGN]');" />
                          <input type="button" name="color" value="Kleur" onClick="javascript:Invoegen('[COLOR=...]...[/COLOR]');" />   
                          <input type="button" name="size" value="Grootte" onClick="javascript:Invoegen('[SIZE=...]...[/SIZE]');" />       
                          <input type="button" name="e-mail" value="E-mail" onClick="javascript:Invoegen('[EMAIL=...]...[/EMAIL]');" />
                        </td>
                    </tr>
                    <tr>           
                       <td align="center" height="21" colspan="4"><small><i><b>Smileys:</b></i></small></td>
                     </tr>
                    <tr>
                <td height="41" width="24%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(':)');"><img src="smileys/blij.gif" width="20" border="0" /></a></td>
                <td height="41" width="24%" align="center" valign="middle"><a href="javascript:smiley();" onClick="javascript:Invoegen(':D');"><img src="smileys/tanden.gif" width="20" height="20" border="0" /></a></td>
                <td height="41" width="23%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(':P');"><img src="smileys/tong.gif" width="20" height="20" border="0" /></a></td>
                <td height="41" width="29%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(';)');"><img src="smileys/knipoog.gif" width="20" height="20" border="0" /></a></td>
                </tr>     
                     <tr>   
                <td height="36" width="24%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(':cool:');"><img src="smileys/cool.gif" width="20" height="20" border="0" /></a></td>
                <td height="36" width="24%" align="center" valign="middle"><a href="javascript:smiley();" onClick="javascript:Invoegen(':s');"><img src="smileys/verward.gif" width="20" height="20" border="0" /></a></td>
                <td height="36" width="23%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(':omg:');"><img src="smileys/omg.gif" width="20" height="20" border="0" /></a></td>
                 <td height="36" width="29%" valign="middle" align="center"><a href="javascript:smiley();" onClick="javascript:Invoegen(':(');"><img src="smileys/droevig.gif" width="20" height="20" border="0" /></a></td>
                     </tr>
            </table>


            <br>
                  <textarea name="bericht" cols="50" rows="10" id="bericht"></textarea><br />
              </td>
            </tr>
              <tr>
              <td height="25" colspan="2" align="center">
                 <input type="submit" name="Submit" value="Verzenden" />&nbsp;             
                  <input name="Reset" type="submit" id="Reset" value="Opnieuw" />
              </td>
              </tr>
      </table>
    </form>
  </center>
  <?php
  }
  ?>

  </body>
</html>


Op lijn 187 t/m 193 vind je het 'form' terug, en helemaal bovenaan staat de rest...

Reageren