Ergebnis 1 bis 6 von 6

Thema: Captcha bedingung zum posten

  1. #1
    Gizzl0r
    Gast

    Standard Captcha bedingung zum posten

    Hi,
    Habe folgendes Problem.
    Ich bastel gerade an nem kleinen gästebuch und habe das problem das er die captcha eingabe nicht berücksichtigt also is sozusagen noch nicht aktiv.
    Mir fehlen bedingungen für die if else abfrage und ich weiss nicht welche.
    Da ich noch nicht so lange php mache bitte ich euch um hilfe.
    hier hab ich mal die ganze Datei.

    Code:
    <?php
     session_start&#40;&#41;;
    ?>
    <html>
      <head>
        <title>Gästebuch</title>
      </head>
      <body text="#FFFFFF" style="font-family&#58; verdana; font-size&#58; 11px;">
    <center>
    <?php
    require_once 'TEXT/captcha.php';
    $captcha = Text_CAPTCHA&#58;&#58;factory&#40;'Image'&#41;;
    $options = array&#40;'font_size'=>'20',
                     'font_path'=>'./',
                     'font_file'=>'default.ttf'&#41;;
    $captcha->init&#40;150, 50, NULL, $options&#41;;
    $image = $captcha->getCAPTCHAAsJPEG&#40;&#41;;
    $handle = fopen&#40;'captcha.jpg', 'w'&#41;;
    fwrite&#40;$handle, $image&#41;;
    fclose&#40;$handle&#41;;
    ?>
    <?php
    $_SESSION&#91;'captcha_phrase'&#93; = $captcha->getPhrase&#40;&#41;;
    ?>
    
    <?php
    if &#40;isset&#40;$_POST&#91;'captcha_phrase'&#93;, $_SESSION&#91;'captcha_phrase'&#93;&#41; &&
        strlen&#40;$_SESSION&#91;'captcha_phrase'&#93;&#41; == 0 &&
        $_POST&#91;'captcha_phrase'&#93; === $_SESSION&#91;'captcha_phrase'&#93;&#41;
    
    
    
    
    
    
    
    
    
    
    
    &#123;
        &#91;color =RED&#93; ///////////////////////////////////HIER DIE BEDINGUNG  &#91;/color&#93;
    &#125;
    else
    &#123;
        &#91;color =RED&#93;///////////////////////////////////// HIER DIE BEDINGUNG&#91;/color&#93;
    &#125;
    ?>
    
    
    
    
    
    
    
    
    
    <form action="eintrag-einfuegen.php" method="post">
    
    <table border="0" cellpadding="3" cellspacing="1" bgcolor="#111">
            <tr>
              <td colspan="2" bgcolor="#333333" align="center">Gästebuch</td>
            </tr>
            <tr>
              <td bgcolor="#333333" >Dein Name&#58;</td>
              <td bgcolor="#FF4400"  ><input type="text" size="33" name="Name" style="font-family&#58; verdana; font-size&#58; 11px;" /></td>
            </tr>
            <tr>
              <td bgcolor="#333333">Deine Titel&#58;</td>
              <td bgcolor="#FF4400"><input type="text" size="33" name="Titel" style="font-family&#58; verdana; font-size&#58; 11px;" /></td>
            </tr>
              <td bgcolor="#333333" valign="top">Eintrag&#58;</td>
              <td bgcolor="#FF4400"><textarea name="Eintrag" rows="5" cols="30" style="font-family&#58; verdana; font-size&#58; 11px;"></textarea></td>
            </tr>
    	<tr>
    	<td bgcolor="#333333"  valign="top">Code&#58;</td>
              <td bgcolor="#FF4400"><input type="text" name="captcha_phrase" />
    
    	[img]captcha.jpg[/img]
    	</tr>
            <tr>
            <tr>
              <td colspan="2" bgcolor="#333333" align="center"><input type="submit" value="Eintragen!" style="font-family&#58; Verdana; font-size&#58; 11px;" /></td>
            </tr>
          </table>
    </form></center>
    </body>
    </html> 
    <?php
    
    
    
    
    
    
    ?>
    Achtung: Dies ist ein alter Thread im HTML und Webmaster Forum
    Diese Diskussion ist älter als 90 Tage. Die darin enthaltenen Informationen sind möglicherweise nicht mehr aktuell. Erstelle bitte zu deiner Frage ein neues Thema im Forum !!!!!

  2. #2
    Forum Guru
    Registriert seit
    28.12.2004
    Ort
    Ringgenberg(bei Interlaken) / Schweiz
    Beiträge
    4.787
    Danke
    0
    Bekam 0 mal "Danke" in 0 Postings

    Standard

    was den das für ne captcha kalsse ?!

    die kenne ich ja garnicht....

  3. #3
    Forum Guru
    Registriert seit
    13.01.2005
    Ort
    Schweiz
    Beiträge
    5.240
    Danke
    0
    Bekam 0 mal "Danke" in 0 Postings

    Standard

    solltest vielleicht noch die captcha.php posten

  4. #4
    Fortgeschrittene/r
    Registriert seit
    03.03.2006
    Beiträge
    195
    Danke
    0
    Bekam 0 mal "Danke" in 0 Postings
    Für die nächste Zeit erstmal inaktiv.

  5. #5
    Gizzl0r
    Gast

    Standard

    <?php
    /**
    *
    * Require Image_Text class for generating the text.
    *
    */
    require_once 'Image/Text.php';

    /**
    * Text_CAPTCHA_Driver_Image - Text_CAPTCHA driver graphical CAPTCHAs
    *
    * Class to create a graphical Turing test
    *
    * TODOs:
    * + refine the obfuscation algorithm
    * + learn how to use Image_Text better (or remove dependency)
    *
    *
    * @license PHP License, version 3.0
    * @author Christian Wenz <wenz@php.net>
    */

    class Text_CAPTCHA_Driver_Image extends Text_CAPTCHA
    {

    /**
    * Image object
    *
    * @access private
    * @var resource
    */
    var $_im;

    /**
    * Image_Text object
    *
    * @access private
    * @var resource
    */
    var $_imt;

    /**
    * Width of CAPTCHA
    *
    * @access private
    * @var int
    */
    var $_width;

    /**
    * Height of CAPTCHA
    *
    * @access private
    * @var int
    */
    var $_height;

    /**
    * Further options (for Image_Text)
    *
    * @access private
    * @var array
    */
    var $_options;

    /**
    * init function
    *
    * Initializes the new Text_CAPTCHA_Driver_Image object and creates a GD image
    *
    * @param int $width Width of image
    * @param int $height Height of image
    * @param string $phrase The "secret word" of the CAPTCHA
    * @param array $options further options (for Image_Text)
    * @access public
    * @return mixed true upon success, PEAR error otherwise
    */
    function init($width = 200, $height = 80, $phrase = null, $options = null)
    {
    if (is_int($width) && is_int($height)) {
    $this->_width = $width;
    $this->_height = $height;
    if (empty($phrase)) {
    $this->_createPhrase();
    } else {
    $this->_phrase = $phrase;
    }
    if (empty($options)) {
    $this->_options = array(
    'font_size' => 24,
    'font_path' => './',
    'font_file' => 'COUR.TTF'
    );
    } else {
    $this->_options = $options;
    if (!isset($this->_options['font_size'])) {
    $this->_options['font_size'] = 24;
    }
    if (!isset($this->_options['font_path'])) {
    $this->_options['font_path'] = './';
    }
    if (!isset($this->_options['font_file'])) {
    $this->_options['font_file'] = 'COUR.TTF';
    }
    }
    $retval = $this->_createCAPTCHA();
    if (PEAR::isError($retval)) {
    return PEAR::raiseError($retval->getMessage());
    } else {
    return true;
    }
    } else {
    return PEAR::raiseError('Use numeric CAPTCHA dimensions!');
    }
    }

    /**
    * Create random CAPTCHA phrase, Image edition (with size check)
    *
    * This method creates a random phrase, maximum 8 characters or width / 25, whatever is smaller
    *
    * @access private
    */
    function _createPhrase()
    {
    $len = intval(min(8, $this->_width / 25));
    $this->_phrase = Text_Password::create($len);
    }


    /**
    * Create CAPTCHA image
    *
    * This method creates a CAPTCHA image
    *
    * @access private
    */
    function _createCAPTCHA()
    {
    $options['canvas'] = array(
    'width' => $this->_width,
    'height' => $this->_height
    );
    $options['width'] = $this->_width - 20;
    $options['height'] = $this->_height - 20;
    $options['cx'] = ceil(($this->_width) / 2 + 10);
    $options['cy'] = ceil(($this->_height) / 2 + 10);
    $options['angle'] = rand(0, 30) - 15;
    $options['font_size'] = $this->_options['font_size'];
    $options['font_path'] = $this->_options['font_path'];
    $options['font_file'] = $this->_options['font_file'];
    $options['color'] = array('#FFFFFF', '#000000');
    $options['max_lines'] = 1;
    $options['mode'] = 'auto';
    $this->_imt = new Image_Text(
    $this->_phrase,
    $options
    );
    if (PEAR::isError($this->_imt->init())) {
    return PEAR::raiseError('Error initializing Image_Text (font missing?!)');
    }
    $this->_imt->measurize();
    $this->_imt->render();
    $this->_im =& $this->_imt->getImg();
    $white = imagecolorallocate($this->_im, 0xFF, 0xFF, 0xFF);
    //some obfuscation
    for ($i=0; $i<3; $i++) {
    $x1 = rand(0, $this->_width - 1);
    $y1 = rand(0, round($this->_height / 10, 0));
    $x2 = rand(0, round($this->_width / 10, 0));
    $y2 = rand(0, $this->_height - 1);
    imageline($this->_im, $x1, $y1, $x2, $y2, $white);
    $x1 = rand(0, $this->_width - 1);
    $y1 = $this->_height - rand(1, round($this->_height / 10, 0));
    $x2 = $this->_width - rand(1, round($this->_width / 10, 0));
    $y2 = rand(0, $this->_height - 1);
    imageline($this->_im, $x1, $y1, $x2, $y2, $white);
    $cx = rand(0, $this->_width - 50) + 25;
    $cy = rand(0, $this->_height - 50) + 25;
    $w = rand(1, 24);
    imagearc($this->_im, $cx, $cy, $w, $w, 0, 360, $white);
    }
    }

    /**
    * Return CAPTCHA as image resource
    *
    * This method returns the CAPTCHA as GD2 image resource
    *
    * @access public
    * @return im image resource
    */
    function getCAPTCHA()
    {
    return $this->_im;
    }

    /**
    * Return CAPTCHA as PNG
    *
    * This method returns the CAPTCHA as PNG
    *
    * @access public
    */
    function getCAPTCHAAsPNG()
    {
    if (is_resource($this->_im)) {
    ob_start();
    imagepng($this->_im);
    $data = ob_get_contents();
    ob_end_clean();
    return $data;
    } else {
    return PEAR::raiseError('Error creating CAPTCHA image (font missing?!)');
    }
    }

    /**
    * Return CAPTCHA as JPEG
    *
    * This method returns the CAPTCHA as JPEG
    *
    * @access public
    */
    function getCAPTCHAAsJPEG()
    {
    if (is_resource($this->_im)) {
    ob_start();
    imagejpeg($this->_im);
    $data = ob_get_contents();
    ob_end_clean();
    return $data;
    } else {
    return PEAR::raiseError('Error creating CAPTCHA image (font missing?!)');
    }
    }

    }

  6. #6
    Gast

    Standard

    das is die pear captcha......

Ähnliche Themen

  1. Posten und empfangen
    Von Gast im Forum PHP Forum - Apache - CGI - Perl - JavaScript und Co.
    Antworten: 9
    Letzter Beitrag: 02.11.2007, 17:16
  2. Link posten erlaubt?
    Von im Forum Computer - Internet Forum
    Antworten: 0
    Letzter Beitrag: 12.08.2007, 20:29
  3. Vorschläge posten und abstimmen...
    Von CHIEFmaster im Forum PHP Forum - Apache - CGI - Perl - JavaScript und Co.
    Antworten: 31
    Letzter Beitrag: 10.07.2006, 21:08
  4. Posten von Email-Adressen
    Von Ronald im Forum Forum-Hilfe.de intern
    Antworten: 12
    Letzter Beitrag: 30.10.2005, 20:59
  5. WHERE bedingung
    Von cookie im Forum PHP Forum - Apache - CGI - Perl - JavaScript und Co.
    Antworten: 4
    Letzter Beitrag: 11.09.2005, 01:20

Stichworte

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •