Christian Bliß: CAPTCHA so in Ordnung?

Beitrag lesen

Hallo,

Keine Ahnung. Aber sei mal sogut und zeige nicht nur das IMG sondern den zughörigen HTML-Code mit dem eingebundenen Captcha.

Ich hau den gerade mal hier rein:

#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser);
use GD;
use CGI;

print new CGI->header(-type=>"image/gif");

$img = GD::Image->new(300, 100);

%zeichen = ( "1" => "a",
             "2" => "b",
             "3" => "c",
             "4" => "d",
             "5" => "e",
             "6" => "f",
             "7" => "g",
             "8" => "h",
             "9" => "i",
             "10" => "j",
             "11" => "k",
             "12" => "l",
             "13" => "m",
             "14" => "n",
             "15" => "o",
             "16" => "p",
             "17" => "q",
             "18" => "r",
             "19" => "s",
             "20" => "t",
             "21" => "u",
             "22" => "v",
             "23" => "w",
             "24" => "x",
             "25" => "y",
             "26" => "z",
             "27" => "1",
             "28" => "2",
             "29" => "3",
             "30" => "4",
             "31" => "5",
             "32" => "6",
             "33" => "7",
             "34" => "8",
             "35" => "9" );

Hintergrundfarbe

$fill_color = $img->colorAllocate(250,250,250);
$img->fill(0, 0, $fill_color);

Polygone erstellen

$poly1 =GD::Polygon->new();
$poly2 =GD::Polygon->new();
$poly3 =GD::Polygon->new();

Gitternetz

for ($i=10; $i<=100; $i=$i+10) {
  $r = int(rand(255));
  $g = int(rand(255));
  $b = int(rand(255));
  my $color = $img->colorAllocate($r,$g,$b);

$img->dashedLine(0, $i, 300, $i, $color);
}

for ($i=10; $i<=300; $i=$i+10) {
  $r = int(rand(255));
  $g = int(rand(255));
  $b = int(rand(255));
  my $color = $img->colorAllocate($r,$g,$b);

$img->dashedLine($i, 0, $i, 100, $color);
}

Zeichen + Polygone

for ($i=1; $i<7; $i++) {
  $r = int(rand(150));
  $g = int(rand(150));
  $b = int(rand(150));
  my $color = $img->colorAllocate($r,$g,$b);

$size = (int(rand(15)) +25);

$rech = $size%2;
  if ($rech eq "0") {
    $angle = "0.".int(rand(5));
  }
  else {
    $angle = "-0.".int(rand(5));
  }

$x = 40*$i;
  $y = (int(rand(50)) +35);

$zahl = (int(rand(35)) +1);

$font_zahl = int(rand(5));

if ($font_zahl eq "0") {
    $img->stringFT($color,'./arial.ttf',$size,$angle,$x,$y, "$zeichen{$zahl}");
  }
  elsif ($font_zahl eq "1") {
    $img->stringFT($color,'./verdana.ttf',$size,$angle,$x,$y, "$zeichen{$zahl}");
  }
  elsif ($font_zahl eq "2") {
    $img->stringFT($color,'./courir.ttf',$size,$angle,$x,$y, "$zeichen{$zahl}");
  }
  elsif ($font_zahl eq "3") {
    $img->stringFT($color,'./comic.ttf',$size,$angle,$x,$y, "$zeichen{$zahl}");
  }
  else {
    $img->stringFT($color,'./timesnewroman.ttf',$size,$angle,$x,$y, "$zeichen{$zahl}");
  }

# Polygonpunkte festlegen #
  $poly1_x = int(rand(300));
  $poly1_y = int(rand(100));

$poly1->addPt($poly1_x,$poly1_y);

$poly2_x = int(rand(300));
  $poly2_y = int(rand(100));

$poly2->addPt($poly2_x,$poly2_y);

$poly3_x = int(rand(300));
  $poly3_y = int(rand(100));

$poly3->addPt($poly3_x,$poly3_y);
}

Polygonfarbe festlegen

$r1 = int(rand(255));
$g1 = int(rand(255));
$b1 = int(rand(255));
$farbe_poly1 = $img->colorAllocate($r1,$g1,$b1);

$r2 = int(rand(255));
$g2 = int(rand(255));
$b2 = int(rand(255));
$farbe_poly2 = $img->colorAllocate($r2,$g2,$b2);

$r3 = int(rand(255));
$g3 = int(rand(255));
$b3 = int(rand(255));
$farbe_poly3 = $img->colorAllocate($r3,$g3,$b3);

Polygone zeichnen

$img->polygon($poly1, $farbe_poly1);
$img->polygon($poly2, $farbe_poly2);
$img->polygon($poly3, $farbe_poly3);

Bild ausgeben

print $img->gif;

Gruß
Christian Bliß

--
Selfcode: fo:| ch:{ rl:( br:> n4:~ ie:% mo:} va:) de:< zu:| fl:( ss:) ls:> js:{
0 50

CAPTCHA so in Ordnung?

Christian Bliß
  • meinung
  1. 0
    Klawischnigg
    1. 0
      Christian Bliß
  2. 0
    _roro
    1. 0
      Christian Bliß
      1. 0
        _roro
        1. 1
          Christian Bliß
          1. 0
            _roro
            1. 0
              Christian Bliß
              1. 0
                Rouven
                1. 0
                  Christian Bliß
                  1. 0
                    Rouven
                    1. 0
                      Christian Bliß
                      1. 0
                        Marc Reichelt
              2. 0
                _roro
  3. 0
    Henrico Hamstar
    1. 0
      Christian Bliß
      1. 0
        Henrico Hamstar
  4. 0
    Gunnar Bittersmann
    1. 0

      CAPTCHAs: niemand will sie, viele haben sie - Alternativen?

      Marc Reichelt
      1. 0
        Jeena Paradies
        1. 0
          Marc Reichelt
      2. 1
        Schuer
      3. 0
        Maxx
        1. 0
          Jonathan
        2. 0
          Struppi
      4. 0
        Tim Tepaße
        1. 0
          Jonathan
          1. 0
            Maxx
            1. 0
              Jonathan
              1. 0
                Tim Tepaße
                1. 0
                  Jonathan
    2. 0
      Christian Bliß
      1. 0
        Gunnar Bittersmann
        1. 0
          Jonathan
  5. 0

    Btw...

    _roro
    1. 0
      Marc Reichelt
      1. 0
        _roro
        1. 1
          Marc Reichelt
    2. 1
      Siggi
      1. 0
        Henrico Hamstar
        1. 0
          Siggi
          1. 0
            Mathias Brodala
    3. 0
      Henrico Hamstar
  6. 0
    Jonathan
    1. 0
      Christian Bliß
      1. 0
        Jonathan
        1. 0
          Christian Bliß
          1. 0
            Jonathan
      2. 0
        Længlich